Garry's Mod Wiki

Revision Difference

GM:PlayerSelectSpawn#529396

<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> <arg name="transition" type="boolean">If true, the player just spawned from a map transition (`trigger_changelevel`). 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> 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>