Garry's Mod Wiki

player_connect_client

Description

Called when a player connects to the server.

This is not called clientside for the local player or in single-player.

Members

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 EntIndex of the player, minus one.

Examples

Example

This is a basic template with the purpose of including all arguments / table variables to make it easily known which values can be accessed.

gameevent.Listen( "player_connect_client" ) hook.Add( "player_connect_client", "player_connect_client_example", function( data ) local name = data.name // Same as Player:Nick() local steamid = data.networkid // Same as Player:SteamID() local id = data.userid // Same as Player:UserID() local bot = data.bot // Same as Player:IsBot() local index = data.index // Same as Entity:EntIndex() minus one // Player has connected; this happens instantly after they join -- do something.. end )