Revision Difference
GM:PlayerSelectSpawn#527314
<function name="PlayerSelectSpawn" parent="GM" type="hook">
<ishook>yes</ishook>
<description>Called to determine a spawn point for a player to spawn at.</description>
<realm>Server</realm>
<predicted>No</predicted>
<args>
<arg name="ply" type="Player">The player who needs a spawn point</arg>
<arg name="transition" type="boolean">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.</arg>
</args>
<rets>
<ret name="" type="Entity">The spawnpoint entity to spawn the player at</ret>
</rets>
</function>
<example>
<description>Find a random spawn point</description>
<code>
function GM:PlayerSelectSpawn( pl )
local spawns = ents.FindByClass( "info_player_start" )
local random_entry = math.random( #spawns )⤶
return spawns[ random_entry ]⤶
⤶
end⤶
hook.Add("PlayerSelectSpawn", "RandomSpawn", function(pl)
local spawns = ents.FindByClass("info_player_start")
local random_entry = math.random(#spawns)
⤶
return spawns[random_entry]⤶
end)
</code>
</example>