game
Helpers for the current match, local player, screen projection, and view angles.
State
game.in_game(): boolean
- Returns if you are currently in a game.
game.is_connected(): boolean
- Returns if you are connected to a server.
game.is_paused(): boolean
- Returns if the game is paused.
game.max_clients(): number | nil
- Returns the max client count for the server.
game.latency(flow?: number): number | nil
- Returns net latency in milliseconds.
flowis optional:0(default) uses network latency,1uses engine latency.
print(secret.game.latency()) -- ms
print(secret.game.latency(1)) -- engine latency, ms
game.avg_data(flow?: number): number | nil
- Returns the average network throughput in bytes per second.
flowis optional:0(default) for outgoing,1for incoming.- Divide by
1024if you want kilobytes per second.
local out_bps = secret.game.avg_data(0) or 0
local in_bps = secret.game.avg_data(1) or 0
print(string.format("in: %.2fk/s out: %.2fk/s", in_bps / 1024, out_bps / 1024))
game.avg_loss(flow?: number): number | nil
- Returns average packet loss as a fraction from
0to1(multiply by100for percent). flowis optional:0for outgoing,1(default) for incoming.
local loss_pct = (secret.game.avg_loss(1) or 0) * 100
game.avg_choke(flow?: number): number | nil
- Returns average packet choke as a fraction from
0to1(multiply by100for percent). flowis optional:0(default) for outgoing,1for incoming.
local choke_pct = (secret.game.avg_choke(0) or 0) * 100
game.net_address(): string | nil
- Returns the current net channel address.
game.is_loopback(): boolean
- Returns if the current connection looks like loopback / localhost.
game.get_screen_size(): number, number
- Returns screen width and height.
local w, h = secret.game.get_screen_size()
game.map_name(): string | nil
- Returns the full map name.
game.map_short(): string | nil
- Returns the short map name (e.g.
de_dust2).
if secret.game.in_game() then
print(secret.game.map_short())
end
Locals
game.local_player(): entity | nil
- Returns your local player pawn. See entities.
game.local_controller(): entity | nil
- Returns your local player controller.
game.local_origin(): { x: number, y: number, z: number } | nil
- Returns your origin as a table with
x,y,z.
local o = secret.game.local_origin()
if o then
print(o.x, o.y, o.z)
end
Screen / angles
game.world_to_screen(x: number, y: number, z: number): boolean, number?, number?
- Converts a world position to screen coordinates.
- Returns
true, sx, syon success, otherwisefalse.
local ok, sx, sy = secret.game.world_to_screen(x, y, z)
if ok then
print(sx, sy)
end
game.get_view_angles(): number, number, number
- Returns pitch, yaw, roll.
game.set_view_angles(pitch: number, yaw: number, roll: number)
- Sets your view angles.
local p, y, r = secret.game.get_view_angles()
secret.game.set_view_angles(p, y + 1, r)
Players
game.players(): table
- Returns a 1-based list of players with
handle,x,y,z,health,name. - For entity methods use entities.
for _, p in ipairs(secret.game.players()) do
print(p.name, p.health)
end