OnPlayerSpawn: Difference between revisions
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 | void onPlayerSpawn ( spawnpoint theSpawnpoint, team theTeam ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | ==Parameters== | ||
* The source of this event refers to the player who spawned. | *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== | ==Example== | ||
This example plays a sound when a player spawns | This example plays a sound when a player spawns. | ||
<syntaxhighlight lang="lua">addEventHandler ( "onPlayerSpawn", | <syntaxhighlight lang="lua"> | ||
function player_Spawn ( | -- add the player_Spawn function as a handler for onPlayerSpawn | ||
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
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled