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.

FunctionWhat 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

slotinteger
Player 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

FieldTypeMeaning
scopedbooleanLooking through a scope.
defusingbooleanDefusing the bomb.
shots_firedintegerShots in the current spray.
flashnumberLength of the last flash in seconds. Above 0 means they were flashed.
velocityvectorSpeed in units per second on each axis.
on_groundbooleanStanding on the ground.
eye_anglestablepitch and yaw in degrees.
visiblebooleanSpotted by you (the game's own spotted flag).
bonestableVectors: 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_anglestableOnly on entity.local_player(): your camera pitch and yaw.
placestringCallout of the spot they stand in, for example BombsiteA.
in_buy_zonebooleanStanding in a buy zone.
walkingbooleanHolding the walk key.
pingintegerLatency in ms.
scoreintegerScoreboard score.
mvpsintegerMVP stars.
has_defuserbooleanCarries a defuse kit.
has_helmetbooleanWears a helmet.
clanstringClan tag.