SpawnPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
This function spawns the player at a spawnpoint or at an arbitary point on the map.
This function spawns the player at a spawnpoint or at an arbitary point on the map.


==Syntax==
==Syntax [spawn at spawnpoint]==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool spawnPlayer ( player thePlayer, spawnpoint theSpawnpoint )             
bool spawnPlayer ( player thePlayer, spawnpoint theSpawnpoint )             
Line 14: Line 14:
Returns ''true'' if the player was spawned successfully, ''false'' otherwise.
Returns ''true'' if the player was spawned successfully, ''false'' otherwise.


==Syntax==
==Syntax [spawn at arbitary point]==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool spawnPlayer ( player thePlayer, float x, float y, float z, int rotation, int skinID )
bool spawnPlayer ( player thePlayer, float x, float y, float z, int rotation, int skinID )

Revision as of 02:25, 29 May 2006

This function spawns the player at a spawnpoint or at an arbitary point on the map.

Syntax [spawn at spawnpoint]

bool spawnPlayer ( player thePlayer, spawnpoint theSpawnpoint )             

Required Arguments

  • thePlayer: the player to spawn
  • theSpawnpoint: the spawnpoint element at which to spawn the player

Returns

Returns true if the player was spawned successfully, false otherwise.

Syntax [spawn at arbitary point]

bool spawnPlayer ( player thePlayer, float x, float y, float z, int rotation, int skinID )

Required Arguments

  • x: The x co-ordinate to spawn the player at
  • y: The y co-ordinate to spawn the player at
  • z: The z co-ordinate to spawn the player at
  • rotation: rotation of the player on spawn
  • skinID: players skin on spawn

Returns

Returns true if the player was spawned successfully, false otherwise.

Example

This example spawns all the players in the map at the first spawnpoint there is.

-- Get a table of all the players
players = getElementsByType ( "player" )
-- Get a table of all the spawnpoints
spawnpoints = getElementByType ( "spawnpoint" )
-- Go through every player
for playerKey, playerValue in players do
	-- Spawn them at the first spawnpoint
	spawnPlayer ( playerValue, spawnpoints[1] )
end

See Also

Shared