Garry's Mod Wiki



Called when a player connects to the server.

This is only called serverside AND clientside for the listen server host. In other cases it's called serverside.


number bot
0 if the player isn't a bot, 1 if they are.
string networkid
The SteamID the player has. Will be BOT for bots and STEAM_0:0:0 in single-player.
string name
The name the player has.
number userid
The UserID the player has.
number index
The entity index of the player, minus one.
string address
The IPAddress of the connecting player. Will be none for bots and loopback for listen server and single-player hosts.



Announce to everyone that a player has connected.

gameevent.Listen( "player_connect" ) hook.Add("player_connect", "AnnounceConnection", function( data ) for i, ply in ipairs( player.GetAll() ) do ply:ChatPrint( .. " has connected to the server." ) end end)
Output: Player1 has connected to the server.