GM/PlayerInitialSpawn

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Made the note a proper note)
m (Added info about PlayerSpawn)
Line 1: Line 1:
 
{{Hook
 
{{Hook
 
|Description=Called when the player spawns for the first time.
 
|Description=Called when the player spawns for the first time.
 +
 +
For the next player spawns use {{HookFunction|GM|PlayerSpawn}}.
  
 
{{Note|This hook is called before the player has fully loaded, when the player is still in seeing the "Sending Client Info" screen. For example, trying to use the {{ClassFunction|Entity|GetModel}} function will return the default model ("player/default.mdl")}}
 
{{Note|This hook is called before the player has fully loaded, when the player is still in seeing the "Sending Client Info" screen. For example, trying to use the {{ClassFunction|Entity|GetModel}} function will return the default model ("player/default.mdl")}}

Revision as of 21:37, 31 August 2018

 GM:PlayerInitialSpawn( )

Contents

Description

Called when the player spawns for the first time.

For the next player spawns use GM:PlayerSpawn.

NOTE

This hook is called before the player has fully loaded, when the player is still in seeing the "Sending Client Info" screen. For example, trying to use the Entity:GetModel function will return the default model ("player/default.mdl")

Arguments

Player player

The player who spawned.

Examples

Example

Prints the name of the player joining.

function GM:PlayerInitialSpawn(ply)
	print( ply:GetName().." joined the server.\n" )
end

-- That way you are overriding the default hook
-- you can use hook.Add to make more functions get called when this event occurs
local function spawn(ply)
	print( ply:GetName().." joined the game.\n")
end
hook.Add( "PlayerInitialSpawn", "some_unique_name", spawn )

Output:

<somebody> joined the game
Personal tools
Navigation