GM/PlayerSelectSpawn

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
 
Line 3: Line 3:
 
|Realm=Server
 
|Realm=Server
 
|Predicted=No
 
|Predicted=No
|Name=PlayerSelectSpawn
 
|Parent=GM
 
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 10: Line 8:
 
|name=ply
 
|name=ply
 
|desc=The player who needs a spawn point
 
|desc=The player who needs a spawn point
 +
}}
 +
{{Arg
 +
|type=boolean
 +
|name=transition
 +
|desc={{NextUpdate}}
 +
If true, the player just spawned from a map transition. You probably want to not return an entity for that case to not override player's position.
 
}}
 
}}
 
{{Ret
 
{{Ret

Latest revision as of 16:06, 13 August 2019

 GM:PlayerSelectSpawn( )

Contents

Description

Called to determine a spawn point for a player to spawn at.

Arguments

Player ply

The player who needs a spawn point

Arguments

boolean transition

Next Update Change

This feature is only available in the next update.
If true, the player just spawned from a map transition. You probably want to not return an entity for that case to not override player's position.

Returns

Entity

The spawnpoint entity to spawn the player at

Examples

Example

Find a random spawn point

function GM:PlayerSelectSpawn( pl )
    
    local spawns = ents.FindByClass( "info_player_start" )
    local random_entry = math.random( #spawns )
    
    return spawns[ random_entry ]
	
end


Personal tools
Navigation