Skip to main content
The Entities module exposes the game’s entity list. Every entity is backed by a cached snapshot that is refreshed each frame - reads are fast and safe to call in per-frame callbacks without worrying about memory access.
Entity objects are lazy - they hold an index, not a pointer. The actual data is fetched from the per-frame cache on first property access. Always check .isValid before reading fields in contexts where an entity might have just died or despawned.

Overview

Fetching entities

Get all entities, look up by index, or grab players.

Query builder

Chain class filters and iterators - forEach, map, filter, first.

Entity object

Reserved properties, helper methods, schema fields, and raw-buffer API.

Supported field types

How the engine maps every C++ type to a JS value.

Fetching entities

Entities.getByIndex


Returns an Entity handle for a given entity list index. The entity may or may not be valid - always check .isValid.

Entities.getEntities


Returns every entity currently in the snapshot as a flat array.
Prefer Entities.find() when you only need a specific class - it avoids allocating the full array and skips irrelevant entities early.

Entities.getPlayers


Returns all player pawns in the game (C_CSPlayerPawn and C_CSObserverPawn). Each element is the pawn entity - use .controller to reach the CCSPlayerController.

Entities.getLocalPlayer


Returns the local player’s pawn entity, or null if not in-game.

Query builder

Entities.find() returns a Query - a lazy, chainable object that filters entities from the snapshot. Nothing is read until you call a terminal method (toArray, forEach, first, count, map, some, every).

Entities.find



Query methods


Entity object

Every value returned by the Entities API is an Entity - a dynamic proxy that reads fields directly from the per-frame entity cache.

Reserved properties

These are always present regardless of the entity’s class:

Entity methods

Available on all entities.

.isEnemy


Returns whether other is an enemy. Respects mp_teammates_are_enemies.

.getOrigin


Returns the entity’s world-space position.

.getVelocity


Returns the entity’s current velocity.

.getBoundingBox


Returns screen-space [mins, maxs] for the entity, or null if it’s behind the camera.

.getModelName


Returns the path to the entity’s model (for example "characters/models/ctm_fbi/ctm_fbi.vmdl"). Returns null if the scene node or model is invalid.

.getBone / .getBones


Access the entity’s skeleton. getBones() returns every bone as an array; getBone(id) returns a single bone by index and only reads the 32 bytes for that bone, which is much cheaper if you need just one. Both return null when the scene, model, or bone array is invalid. getBone also returns null when id is out of range.

.getHitbox / .getHitboxes


Access the entity’s hitboxes. getHitboxes() returns every hitbox; getHitbox(id) returns a single hitbox by index (0 .. length - 1) and only touches the one bone needed to resolve start / end. getHitboxes() returns null on error or [] when the model has no hitboxes. getHitbox returns null when id is out of range or the bone / model is invalid.
Static fields (cached per model):Dynamic fields (recomputed each call):

Player methods

Available on player pawns (C_CSPlayerPawn, C_CSObserverPawn).

.controller


The CCSPlayerController linked to this pawn.

.getEyePosition


Returns the eye position (origin + view offset).

.isVisible


Traces from this entity’s eye position to other’s origin.

Weapon methods

Available on weapons (C_BasePlayerWeapon).

.getWeaponData


Returns weapon VData — damage, range, spread, weaponType, price, and all schema fields.

Schema fields

Any field in the entity’s C++ class hierarchy is accessible by name directly on the entity object. The engine resolves the field through the full inheritance chain automatically.
Builtin fields (bool, int32, float, etc.) are writable - you can set them directly: player.m_iHealth = 100. All other field types (pointers, nested structs, vectors, handles) are read-only.

CUtlVector fields

Fields of type CUtlVector (or CNetworkUtlVectorBase) return a UtlVector object - a lazy wrapper around the native array that reads elements on demand.

Raw buffer API

Every entity (and nested struct) exposes low-level read methods for reading raw bytes at a fixed byte offset from the entity’s base address. Useful for fields not exposed in the generated schema.

.toString()


Supported field types

The engine maps every C++ schema type to a JavaScript value automatically.

Recipes

Find the closest visible enemy

Iterate all controllers and their pawns

List all weapons on the map

Read schema field + raw fallback