spawnPlayer | Multi Theft Auto: Wiki Skip to content

spawnPlayer

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function spawns the player at an arbitrary point on the map.

Note

setCameraTarget must be used to focus on the player. Also, all players have their camera initially faded out after connect. To ensure that the camera is faded in, please do a fadeCamera after.

OOP Syntax Help! I don't understand this!

Syntax

bool spawnPlayer ( player thePlayer, float x, float y, float z, [ [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = getPlayerTeam(thePlayer ] )
Required Arguments
  • thePlayer: The player you want to spawn.
  • 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.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • int rotation (default: 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = getPlayerTeam(thePlayer): MISSING_PARAM_DESC

Returns

  • bool: value

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

Code Examples

shared

This example spawns all the players in the middle of the game map.

-- Get a table of all the players
local players = getElementsByType ( "player" )
-- Go through every player
for _, player in ipairs(players) do
-- Spawn them at the desired coordinates
spawnPlayer ( player, 0.0, 0.0, 5.0, 90.0, 0 )
fadeCamera ( player, true)
setCameraTarget ( player, player )
end

See Also