GM/PlayerInitialSpawn

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Hook |Name=PlayerInitialSpawn |Parent=GM |Description=Called when the player spawns for the first time. |Realm=Server }} {{Arg |type=Player |name=player |desc=The pl...")
 
Line 11: Line 11:
 
}}
 
}}
 
{{Example
 
{{Example
| Description = Prints the name of the player joining.
+
|Description=Prints the name of the player joining.
| Code = function GM:PlayerInitialSpawn(ply)
+
|Code=function GM:PlayerInitialSpawn(ply)
print( ply:GetName().." joined the server.\n" )
+
print( ply:GetName().." joined the server.\n" )
 
end
 
end
 +
 
-- That way you are overriding the default hook
 
-- That way you are overriding the default hook
 
-- you can use hook.Add to make more functions get called when this event occurs
 
-- you can use hook.Add to make more functions get called when this event occurs
 
local function spawn(ply)
 
local function spawn(ply)
print( ply:GetName().." joined the game.\n")
+
print( ply:GetName().." joined the game.\n")
 
end
 
end
 
hook.Add( "PlayerInitialSpawn", "some_unique_name", spawn )
 
hook.Add( "PlayerInitialSpawn", "some_unique_name", spawn )
| Output = <somebody> joined the game
+
|Output=<somebody> joined the game
 
}}
 
}}

Revision as of 17:24, 23 February 2014

 GM:PlayerInitialSpawn( )

Contents

Description

Called when the player spawns for the first time.

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