Lua · Variables · Game state
entity
Detailed, read-only data about players, grenades, the bomb, dropped weapons and hostages.
entity.players() returns the same player tables as game.players() with more fields. A field is missing (nil) when the game build does not have it, so check before you use it.
| Function | What it does |
|---|---|
entity.players() | All living players with full detail. |
entity.get(slot) | One player by slot, or nil. |
entity.local_player() | You with full detail, plus view_angles. nil when dead. |
entity.grenades() | Grenades in the world and fires on the ground. Same as nade.list(). |
entity.c4() | The bomb. Same as bomb.state(). |
entity.weapons() | Weapons and items lying on the ground. |
entity.hostages() | Hostages on hostage maps. |
#entity.players
entity.players()All living players with full detail.
Returns
player[]
Player tables with the extra fields below.
#entity.get
entity.get(slot)One player by slot, or nil.
Arguments
slotintegerPlayer slot.
Returns
player | nil
-
#entity.local_player
entity.local_player()You with full detail, plus view_angles. nil when dead.
Returns
player | nil
-
Example
local me = entity.local_player()
if me and me.velocity then
print(math.floor(vec.length(me.velocity)))
end#entity.grenades
entity.grenades()Grenades in the world and fires on the ground. Same as nade.list().
Returns
grenade[]
See nade.
#entity.c4
entity.c4()The bomb. Same as bomb.state().
Returns
bomb
See bomb.
#entity.weapons
entity.weapons()Weapons and items lying on the ground.
Returns
table[]
name (string) and pos (vector) each.#entity.hostages
entity.hostages()Hostages on hostage maps.
Returns
table[]
pos, health, alive, state (text), distance (from you).Extra player fields
| Field | Type | Meaning |
|---|---|---|
scoped | boolean | Looking through a scope. |
defusing | boolean | Defusing the bomb. |
shots_fired | integer | Shots in the current spray. |
flash | number | Length of the last flash in seconds. Above 0 means they were flashed. |
velocity | vector | Speed in units per second on each axis. |
on_ground | boolean | Standing on the ground. |
eye_angles | table | pitch and yaw in degrees. |
visible | boolean | Spotted by you (the game's own spotted flag). |
bones | table | Vectors: head, neck, chest, pelvis, shoulder_l, shoulder_r, elbow_l, elbow_r, hand_l, hand_r, hip_l, hip_r, knee_l, knee_r, ankle_l, ankle_r. head is also set to the real head bone. |
view_angles | table | Only on entity.local_player(): your camera pitch and yaw. |
place | string | Callout of the spot they stand in, for example BombsiteA. |
in_buy_zone | boolean | Standing in a buy zone. |
walking | boolean | Holding the walk key. |
ping | integer | Latency in ms. |
score | integer | Scoreboard score. |
mvps | integer | MVP stars. |
has_defuser | boolean | Carries a defuse kit. |
has_helmet | boolean | Wears a helmet. |
clan | string | Clan tag. |