Called when the player spawns for the first time.
See GM:PlayerSpawn for a hook called every player spawn.
This hook is called before the player has fully loaded, when the player is still in seeing the
Starting Luascreen. For example, trying to use the Entity:GetModel function will return the default model (
Due to the above note, sending net messages to the spawned player in this hook are highly unreliable, and they most likely won't be received. See https://github.com/Facepunch/garrysmod-requests/issues/718.
Current dirty hack without networking:
hook.Add( "PlayerInitialSpawn", "FullLoadSetup", function( ply ) hook.Add( "SetupMove", ply, function( self, ply, _, cmd ) if self == ply and not cmd:IsForced() then hook.Run( "PlayerFullLoad", self ) hook.Remove( "SetupMove", self ) end end ) end )
-- CLIENT hook.Add( "InitPostEntity", "Ready", function() net.Start( "cool_addon_client_ready" ) net.SendToServer() end )
Prints the name of the player joining.
function GM:PlayerInitialSpawn(ply) print( ply:Nick() .. " joined the server." ) end -- That way you are overriding the default hook. -- You can use hook.Add to make more functions get called when this event occurs. hook.Add( "PlayerInitialSpawn", "some_unique_name", function( ply ) print( ply:Nick() .." joined the game." ) end)
Output: Player1 joined the game.