OnPlayerSpawn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (See Also for server events)
Line 32: Line 32:
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn )
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn )
</syntaxhighlight>
</syntaxhighlight>
<section name="Example 1" class="server" show="true">
This example spawn the player in a specific place in the map.
<syntaxhighlight lang="lua">
function Spawn()
spawnPlayer(source, 0, 0, 0) --Change the positions
end    --End function
addEventHandler("onPlayerSpawn", getRootElement(), Spawn)
</syntaxhighlight>
</section>


{{See also/Server event|Player events}}
{{See also/Server event|Player events}}

Revision as of 16:21, 17 November 2016

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 )
Click to collapse [-]
Example 1

This example spawn the player in a specific place in the map.

function Spawn()
spawnPlayer(source, 0, 0, 0) --Change the positions
end    --End function
addEventHandler("onPlayerSpawn", getRootElement(), Spawn)

See Also

Player events


Event functions