GM/PlayerSpawn

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(PlayerInitialSpawn link)
 
Line 14: Line 14:
 
|name=player
 
|name=player
 
|desc=The player who spawned.
 
|desc=The player who spawned.
 +
}}
 +
{{Arg
 +
|type=boolean
 +
|name=transition
 +
|desc={{NextUpdate}}
 +
If true, the player just spawned from a map transition. You probably want to not touch player's weapons if this is set to true from this hook.
 
}}
 
}}
 
{{Example
 
{{Example

Latest revision as of 16:07, 13 August 2019

 GM:PlayerSpawn( )

Contents

Description

Called whenever a player spawns, including respawns.

See GM:PlayerInitialSpawn for a hook called only the first time a player spawns.

See the player_spawn gameevent for a shared version of this hook.

WARNING

By default, in "base" derived gamemodes, this hook will also call GM:PlayerLoadout and GM:PlayerSetModel, which may override your Entity:SetModel and Player:Give calls. Consider using the other hooks or a 0-second timer.

Arguments

Player player

The player who spawned.

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 touch player's weapons if this is set to true from this hook.

Examples

Example

Prints a message when a player spawns.

function GM:PlayerSpawn( ply )
    MsgN( ply:Nick() .. " has spawned!" )
end

Output:

Player1 has spawned!

Examples

Example

Prints a message when a player spawns using a hook.

local function spawn( ply )
	print( ply:Nick().. " has spawned!.")
end
hook.Add( "PlayerSpawn", "some_unique_name", spawn )

Output:

Player1 has spawned!
Personal tools
Navigation