GM/PlayerInitialSpawn

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m
Line 12: Line 12:
 
|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.
 
}}
 
}}
 
{{Example
 
{{Example

Revision as of 16:14, 13 August 2019

 GM:PlayerInitialSpawn( )

Contents

Description

Called when the player spawns for the first time.

See GM:PlayerSpawn for a hook called every player spawn.

NOTE

This hook is called before the player has fully loaded, when the player is still in seeing the "Starting Lua" 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.

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.

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