Game, entities and players
The match, players, the local player and the constants that go with them.
game
Match state, the drawn camera and world-to-screen projection, CS2 frame and network stats. Read-only.
Everything here needs Allow game scripting in Scripts > Security (on by default).
game.connected() -> booleanTrue while in a match (the snapshot is valid).
boolean
if not game.connected() then return endgame.map() -> stringThe current map ("" when not in game).
string
log.info(game.map())game.curtime() -> numberGame time in seconds.
number
local t = game.curtime()game.tickcount() -> integerGame tick count.
integer
local t = game.tickcount()game.fps() -> number | nilCS2's frame rate over the last second (its frame counter), not the overlay's (time.fps). nil when not in game or not measured yet.
number | nil
local f = game.fps()game.frametime_var() -> number | nilStandard deviation of CS2's frame time over the last second, in ms (net_graph's var). nil when not in game or not measured yet.
number | nil
local var = game.frametime_var()game.net() -> table | nilThe net channel as net_graph showed it: {loss = percent, choke = percent (incoming), sv_ms = the server's frame time, sv_var_ms = its standard deviation}. nil when not connected or not readable.
table | nil
local n = game.net() if n then log.info(n.loss .. "% loss") endgame.camera() -> table | nilThe drawn camera: {origin = vec3, angles = vec3, fov = number}.
table | nil
local cam = game.camera()game.view_matrix() -> number[] | nilThe camera's 4x4 view-projection matrix, 16 numbers row-major (the one world_to_screen uses: the drawn camera in paint, the refreshed one in tick / events).
number[] | nil
local m = game.view_matrix() local w = m[13] * x + m[14] * y + m[15] * z + m[16]game.freeze_period() -> boolean | nilTrue in freezetime or the team intro (C_CSGameRules, as of the last drawn frame). nil when not in game or not read yet.
boolean | nil
if game.freeze_period() then return endgame.binding(command) -> table | nilCS2's key bindings of a command (read from cs2 every 2 s): {keys = CS2 key names, vks = virtual keys (for input.is_down), vk = the key the native features use (keyboard first) | nil, wheel = -1 / 1 bound to the wheel down / up else 0, live = false while cs2's table is unreadable (then its default key)}. Commands: "+reload", "+lookatweapon" (inspect), "+use", "+jump", "+duck", "+sprint" (walk), "+attack", "+attack2", "+forward", "+back", "+left", "+right", "drop", "slot1".."slot10", "lastinv", "invnext", "invprev", "buymenu", "+showscores", "+spray_menu", "+radialradio", ... (as typed in a bind, case-insensitive). nil when not in game.
| Name | Type | Description |
|---|---|---|
command | string |
table | nil
local b = game.binding("+reload") if b and b.vk then log.info(input.key_name(b.vk)) endgame.action_down(command) -> boolean | nilA key bound to the command is held now (wheel binds never are). false while a menu text field has focus; nil when not in game.
| Name | Type | Description |
|---|---|---|
command | string |
boolean | nil
if game.action_down("+lookatweapon") then endgame.ffa() -> booleanFree for all (mp_teammates_are_enemies).
boolean
if game.ffa() then endgame.damage_scale() -> table | nilThe server's damage scales: {ct_head, t_head, ct_body, t_body} (mp_damage_scale_*).
table | nil
local ds = game.damage_scale()game.world_to_screen(pos) -> number, number | nilProjects a world point with the drawn camera (the one the ESP uses).
| Name | Type | Description |
|---|---|---|
pos | vec3 |
number, number | nil
local x, y = game.world_to_screen(p.origin)game.screen_size() -> number, numberOverlay size in pixels.
number, number
local w, h = game.screen_size()Everything here needs Allow game scripting in Scripts > Security (on by default).
entities.local_player() -> LocalPlayer | nilThe local player (valid for this frame).
LocalPlayer | nil
local me = entities.local_player()entities.players([filter]) -> Player[]Listed players, far to near. filter: "enemies", "teammates", "alive" or nil (all). Dormant players are not listed.
| Name | Type | Description |
|---|---|---|
filteroptional | string |
Player[]
for _, p in ipairs(entities.players("enemies")) do endentities.player(index) -> Player | nilThe listed player with this controller index.
| Name | Type | Description |
|---|---|---|
index | integer |
Player | nil
local p = entities.player(3)entities.projectiles() -> table[]Grenades in flight / burning: {kind = "he"|"flash"|"smoke"|"molotov"|"inferno"|"decoy", index, origin, velocity, center (smoke cloud / fire centre), remaining, detonated, active, thrower, spawn_time, detonate_time, expire_time, lifetime (inferno, else -1), fire_points = vec3[] (inferno only)}. Times are game.curtime() seconds.
table[]
for _, g in ipairs(entities.projectiles()) do endentities.items() -> table[]Dropped weapons: {index (entity, for scene.item), name, origin, ammo}.
table[]
for _, it in ipairs(entities.items()) do endentities.bomb() -> table | nilThe C4: {carried, carrier = index (carried only), planted, ticking, time_left, defuse_left, being_defused, site, origin, blow_time, timer_length, defuse_length}.
table | nil
local b = entities.bomb()entities.dormant() -> table[]Alive players out of the PVS (not in entities.players) that were listed while a game script ran (others are left out): {index, name, team, is_enemy, origin = last listed position, since = seconds since then}.
table[]
for _, d in ipairs(entities.dormant()) do endentities.spectators() -> table[]Spectators: {name, mode, watching_local}.
table[]
for _, s in ipairs(entities.spectators()) do endPlayer
A listed player (entities.players / entities.player). Valid only for the frame it was listed in.
Everything here needs Allow game scripting in Scripts > Security (on by default).
Controller entity index.
integer
Player name.
string
SteamID64 as a string.
string
2 = T, 3 = CT.
integer
Health 0..100.
integer
Armor 0..100.
integer
Money.
integer
Ping in ms.
integer
Health above 0.
boolean
On the other team (or anyone in FFA).
boolean
The local player.
boolean
Standing on the ground.
boolean
Crouching.
boolean
Scoped in.
boolean
Defusing the bomb.
boolean
Flashed.
boolean
Spawn protected.
boolean
Has a helmet.
boolean
Has a defuse kit.
boolean
Spotted by anyone on the radar.
boolean
The game's radar spotted bit for the local player (m_bSpottedByMask), not a line of sight: Player:is_visible() traces the map.
boolean
Controller indices of the players who spot this one (the radar mask).
integer[]
game.curtime() of the last sound others hear (footsteps, landing, ...; m_flEmitSoundTime). See the player_sound event.
number
game.curtime() of the last shot (m_flLastFiredWeaponTime). See the weapon_fire event.
number
Simulation time of the last update the client got (m_flSimulationTime).
number
Number of hitbox capsules (Player:hitbox / Player:capsule take 1..hitbox_count).
integer
Distance to the camera in units.
number
Feet position.
vec3
Eye position.
vec3
Pitch, yaw, roll in degrees.
vec3
Velocity in units/s.
vec3
Body centre.
vec3
Collision box minimum (relative).
vec3
Collision box maximum (relative).
vec3
{name = "ak47", type = weapon_type.*, ammo, max_ammo, reloading, item_def, full_auto, damage, armor_ratio, headshot_mult, range, range_modifier, recoil_index, next_attack_tick}.
table
Player:bone(id) -> number, number, number | nilWorld position of a bone (bone.head, bone.pelvis, ...).
| Name | Type | Description |
|---|---|---|
id | integer |
number, number, number | nil
local x, y, z = p:bone(bone.head)Player:bone_screen(id) -> number, number | nilScreen position of a bone.
| Name | Type | Description |
|---|---|---|
id | integer |
number, number | nil
local x, y = p:bone_screen(bone.head)Player:bone_rot(id) -> number, number, number, number | nilWorld rotation of a bone as a quaternion x, y, z, w.
| Name | Type | Description |
|---|---|---|
id | integer |
number, number, number, number | nil
local qx, qy, qz, qw = p:bone_rot(bone.head)Player:hitbox(i) -> table | nilHitbox capsule i (1-based, as aim and trigger use them): {index, a = vec3, b = vec3, radius, group = hitgroup.*, bone, name}.
| Name | Type | Description |
|---|---|---|
i | integer |
table | nil
local h = p:hitbox(1)Player:hitboxes() -> table[]Every hitbox capsule (as Player:hitbox). Built once per player per logic pass and shared by the calls in it: do not modify it.
table[]
for _, h in ipairs(p:hitboxes()) do endPlayer:capsule(i) -> number, number, number, number, number, number, number, integer | nilHitbox capsule i as plain numbers ax, ay, az, bx, by, bz, radius, group: no tables, so the cheap way to walk every capsule of every player each frame (Player:hitboxes costs ~0.8 us a capsule).
| Name | Type | Description |
|---|---|---|
i | integer |
number, number, number, number, number, number, number, integer | nil
for i = 1, p.hitbox_count do local ax, ay, az, bx, by, bz, r = p:capsule(i) endPlayer:is_visible() -> boolean | nil, stringMap line of sight from the eye to the head, chest, pelvis, hands or feet (the ESP's visibility check, cached per frame). Without a loaded map or with the trace off it is the spotted bit. Counts as one world ray; nil, "ray budget" past the cap.
boolean | nil, string
if p:is_visible() then endPlayer:unseen_ms() -> integer | nilms since a visibility check last found this player visible (the ESP's, aim's or this script's is_visible); nil when never.
integer | nil
if (p:unseen_ms() or 1e9) < 500 then endPlayer:box() -> number, number, number, number | nilScreen box x1, y1, x2, y2 (the ESP's box).
number, number, number, number | nil
local x1, y1, x2, y2 = p:box()Player:screen() -> number, number | nilScreen position of the feet.
number, number | nil
local x, y = p:screen()Player:set_material(m [, opts]) -> booleanDraw this player with m instead of the configured chams (also when chams are off for it) for 1 s, or opts.lease seconds (at most 3600): renew it (each tick) to keep it. nil clears. Needs "Allow custom shaders" (and game).
| Name | Type | Description |
|---|---|---|
m | Material | nil | |
optsoptional | table |
boolean
Needs Allow custom shaders in Scripts > Security (off by default).
for _, p in ipairs(entities.players()) do if p.is_enemy then p:set_material(holo) end endEverything here needs Allow game scripting in Scripts > Security (on by default).
Alive.
boolean
Team.
integer
Team of the spectated player while dead.
integer
Health.
integer
Armor.
integer
On the ground.
boolean
Flash overlay 0..255.
number
Shots in the current spray.
integer
Feet position.
vec3
Eye position.
vec3
View angles.
vec3
Velocity.
vec3
Aim punch angles.
vec3
Active weapon (as Player.weapon).
table
Observer mode while dead (2 = first person, 3 = chase, 4 = roaming), 0 alive.
integer
Controller index of the listed player we spectate while dead.
integer | nil
Controlling a bot (takeover).
boolean
Entity index under the crosshair (m_iIDEntIndex), 0 or -1 for none.
integer
The controller's tick base.
integer
game.curtime() the pawn may attack again.
number
Mouse sensitivity factor of the current zoom (m_flFOVSensitivityAdjust).
number
Pawn flags (bit 0 = on ground).
integer
Controller index.
integer | nil
Name.
string | nil
Bone ids: origin, pelvis, spine_0..3, neck, head, clavicle_l/r, shoulder_l/r, elbow_l/r, hand_l/r, hip_l/r, knee_l/r, foot_l/r, chest.
integer
Needs Allow game scripting in Scripts > Security (on by default).
p:bone_screen(bone.head)Hitgroups: generic, head, chest, stomach, left_arm, right_arm, left_leg, right_leg, neck.
integer
Needs Allow game scripting in Scripts > Security (on by default).
if e.hitgroup == hitgroup.head then endWeapon types: knife, pistol, smg, rifle, shotgun, sniper, lmg, c4, taser, grenade, equipment, healthshot.
integer
Needs Allow game scripting in Scripts > Security (on by default).
if p.weapon.type == weapon_type.sniper then end