OnPlayerSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server event}}
This event is called when a player spawns.
This event is called when a player spawns.


==Syntax==  
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onPlayerSpawn ( float x, float y, float z, float rotation, team theTeam, int model, int interior, int dimension )
float posX, float posY, float posZ, float spawnRotation, team theTeam, int theSkin, int theInterior, int theDimension
</syntaxhighlight>
</syntaxhighlight>


==Parameters==
*'''posX''': The X position the player spawned at
*The '''source''' of this event refers to the player who spawned.
*'''posY''': The Y position the player spawned at
*'''theSpawnpoint''': a [[spawnpoint]] element representing the spawnpoint at which the player was spawned.
*'''posZ''': The Z position the player spawned at
*'''theTeam''': a [[team]] element representing the team of the spawnpoint.
*'''spawnRotation''': The rotation the player spawned with
*'''theTeam''': The team the player spawned with
*'''theSkin''': The skin / model the player spawned with
*'''theInterior''': The interior the player spawned in
*'''theDimension''': The dimension the player spawned in
 
<!-- Add the event's source in the section below -->
==Source==
The [[event system#Event source|source]] of this event is the [[player]] that just spawned.


==Example==   
==Example==   
Line 16: Line 25:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- when a player spawns,
-- when a player spawns,
function player_Spawn ( inSpawnpoint, inTeam )
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension )
-- play a frontend sound for him
-- play a frontend sound for him
playSoundFrontEnd ( source, 16 )
playSoundFrontEnd ( source, 16 )

Revision as of 05:16, 30 December 2007

This event is called when a player spawns.

Parameters

float posX, float posY, float posZ, float spawnRotation, team theTeam, int theSkin, int theInterior, int theDimension
  • posX: The X position the player spawned at
  • posY: The Y position the player spawned at
  • posZ: The Z position the player spawned at
  • spawnRotation: The rotation the player spawned with
  • theTeam: The team the player spawned with
  • theSkin: The skin / model the player spawned with
  • theInterior: The interior the player spawned in
  • theDimension: The dimension the player spawned in

Source

The source of this event is the player that just spawned.

Example

This example plays a sound when a player spawns.

-- when a player spawns,
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension )
	-- play a frontend sound for him
	playSoundFrontEnd ( source, 16 )
end
-- add the player_Spawn function as a handler for onPlayerSpawn
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn )

See also