Resource:Spawnmanager/spawnPlayerAtSpawnpoint: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}} This function spawns the player at a spawnpoint. ==Syntax== <syntaxhighlight lang="lua"> bool spawnPlayerAtSpawnpoint ( player thePlayer, [spawnpoint theSpawnpoint = random...)
 
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 12: Line 12:


===Optional Arguments===
===Optional Arguments===
*'''theSpawnpoint:''' the spawnpoint element at which to spawn the player.  If this is not specified, a random spawnpoint will be used.
*'''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.
*'''useWaves:''' Specifies whether spawn waves will be used from [[Resource:Spawnmanager/setSpawnWave|setSpawnWave]].  If no wave has been set, this will be ignored.


===Returns===
===Returns===
Line 28: Line 28:
for playerKey, playerValue in players do
for playerKey, playerValue in players do
-- Spawn them at the first spawnpoint
-- Spawn them at the first spawnpoint
call(getResourceFromName("spawnmanager", "spawnPlayerAtSpawnpoint", playerValue, spawnpoints[1] )
call(getResourceFromName("spawnmanager"), "spawnPlayerAtSpawnpoint", playerValue, spawnpoints[1] )
end
end
</syntaxhighlight>
</syntaxhighlight>
==See Also==
{{Player_functions}}

Latest revision as of 01:51, 24 October 2008

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