OnPlayerSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 4: Line 4:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onPlayerSpawn ( spawnpoint spawnpoint, team )    
void onPlayerSpawn ( spawnpoint theSpawnpoint, team theTeam )
</syntaxhighlight>  
</syntaxhighlight>  


==Variables==
==Parameters==
* The source of this event refers to the player who spawned.
*The '''source''' of this event refers to the player who spawned.
*'''spawnpoint''':  A spawnpoint element representing the spawnpoint at which the player was spawned.
*'''theSpawnpoint''':  a [[spawnpoint]] element representing the spawnpoint at which the player was spawned.
*'''team''': A team element representing the team of the spawnpoint.
*'''theTeam''': a [[team]] element representing the team of the spawnpoint.


==Example==   
==Example==   
This example plays a sound when a player spawns
This example plays a sound when a player spawns.
<syntaxhighlight lang="lua">addEventHandler ( "onPlayerSpawn", getElementRoot(), "player_Spawn" ) --add an event for player_Spawn
<syntaxhighlight lang="lua">
function player_Spawn ( spawnpoint, team ) --when a player spawns
-- add the player_Spawn function as a handler for onPlayerSpawn
  playSoundFrontEnd ( source, 16 ) --play a sound for him
addEventHandler ( "onPlayerSpawn", getRootElement(), "player_Spawn" )
end</syntaxhighlight>
-- when a player spawns,
function player_Spawn ( inSpawnpoint, inTeam )
-- play a frontend sound for him
playSoundFrontEnd ( source, 16 )
end
</syntaxhighlight>
 
==See also==
{{Event functions}}

Revision as of 19:25, 22 April 2007

This event is called when a player spawns.

Syntax

void onPlayerSpawn ( spawnpoint theSpawnpoint, team theTeam )

Parameters

  • The source of this event refers to the player who spawned.
  • theSpawnpoint: a spawnpoint element representing the spawnpoint at which the player was spawned.
  • theTeam: a team element representing the team of the spawnpoint.

Example

This example plays a sound when a player spawns.

-- add the player_Spawn function as a handler for onPlayerSpawn
addEventHandler ( "onPlayerSpawn", getRootElement(), "player_Spawn" )
-- when a player spawns,
function player_Spawn ( inSpawnpoint, inTeam )
	-- play a frontend sound for him
	playSoundFrontEnd ( source, 16 )
end

See also