Garry's Mod Wiki

client_connected

Description

Called when the connection to a Server has been established.

This is only available in the Menu state because this is called before the Client State has even started.

Members

string address
The Server address. Will be loopback in hosted games.
number ip
The IP of the Server. Will be 0 in hosted games. Use the address instead of this.
number port
The port of the Server. Will be 0 in hosted games.

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. This Binary Module has been used.

require("gameevent") -- using a Binary Module because the Menu State doesn't has gameevent.Listen gameevent.Listen( "client_connected" ) hook.Add( "client_connected", "client_beginconnect_example", function( data ) local address = data.address // The Server address. local ip = data.ip // The Server IP. Use the address instead! local port = data.port // The Server Port. // Called when the connection to a Server has been established. end )