OnPlayerSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 15: Line 15:
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">addEventHandler ( "onPlayerSpawn", getElementRoot(), "player_Spawn" ) --add an event for player_Spawn
function onPlayerSpawn ( spawnpoint, team ) --when a player spawns
function player_Spawn ( spawnpoint, team ) --when a player spawns
   playSoundFrontEnd ( source, 16 ) --play a sound for him
   playSoundFrontEnd ( source, 16 ) --play a sound for him
end</syntaxhighlight>
end</syntaxhighlight>

Revision as of 19:01, 22 April 2007

This event is called when a player spawns.

Syntax

void onPlayerSpawn ( spawnpoint spawnpoint, team )      

Variables

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

Example

This example plays a sound when a player spawns

addEventHandler ( "onPlayerSpawn", getElementRoot(), "player_Spawn" ) --add an event for player_Spawn
function player_Spawn ( spawnpoint, team ) --when a player spawns
  playSoundFrontEnd ( source, 16 ) --play a sound for him
end