Resource:Spawnmanager/spawnPlayerAtSpawnpoint: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 31: Line 31:
end
end
</syntaxhighlight>
</syntaxhighlight>
==See Also==
{{Player_functions}}

Revision as of 18:00, 27 October 2007

This function spawns the player at a spawnpoint.

Syntax

bool spawnPlayerAtSpawnpoint ( player thePlayer, [spawnpoint theSpawnpoint = random, bool useWaves ] )             

Required Arguments

  • thePlayer: the player to spawn

Optional Arguments

  • theSpawnpoint: the spawnpoint element at which to spawn the player. If this is not specified, or false is passed, a random spawnpoint will be used.
  • useWaves: Specifies whether spawn waves will be used from setSpawnWave. If no wave has been set, this will be ignored.

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 = getElementsByType ( "spawnpoint" )
-- Go through every player
for playerKey, playerValue in players do
	-- Spawn them at the first spawnpoint
	call(getResourceFromName("spawnmanager"), "spawnPlayerAtSpawnpoint", playerValue, spawnpoints[1] )
end