cengine_client

Usage: game.engine:{method}

An instance of this type provides a way to interface with Source 2's Engine-to-Client service.

get_last_timestamp

Method

Returns last timestamp, in seconds.

Arguments

None.

Returns

Type
Description

float

Timestamp, in seconds.

Example

local last_time = game.engine:get_last_timestamp();

get_last_server_tick

Method

Returns last server tick number.

Arguments

None.

Returns

Type
Description

int

Server tick number.

Example

local server_tick = game.engine:get_last_server_tick();

in_game

Method

Returns whether the client is currently in game.

Arguments

None.

Returns

Type
Description

bool

In-game status.

Example

if game.engine:in_game() then
    print("I'm in game!");
end

is_connected

Method

Returns whether the client is currently connected to a game server.

Arguments

None.

Returns

Type
Description

bool

true if connected.

Example

if game.engine:is_connected() then
    print("I'm connected!");
end

get_netchan

Method

Returns the Network Channel used for network communication.

Arguments

None.

Returns

Type
Description

Network channel, or nil if does not exist.

Example

local chan = game.engine:get_netchan();

client_cmd

Method

Executes a client-sided console command.

Arguments

Name
Type
Description

cmd

string

Command to execute.

bool

unrestricted

Whether should the execution preserve any restrictions. Defaults to false.

Returns

Nothing.

Example

game.engine:client_cmd('say Hello!');

get_screen_size

Method

Returns client window screen size.

Arguments

None.

Returns

Type
Description

int

Width.

int

Height.

Example

local w, h = game.engine:get_screen_size();

Last updated