Skip to content

Server entity API

Server entity access requires game.entity.read. A server entity identity is:

text
sessionId + type + poolId + streamGeneration

Pool IDs are reusable. Never reconstruct a Handle from only a pool ID or use a Handle after entity.streamed_out.

Acquire and enumerate

samp.entity.get(type, poolId, streamGeneration)

Returns the current Entity Handle, or nil when that exact identity is no longer streamed. Invalid types, IDs, or non-positive generations raise an error.

samp.entity.list(type [, startId [, limit]])

Returns { items = EntityHandle[], nextId = integer|nil }.

ArgumentContract
typeplayer, vehicle, object, actor, pickup, or text_label.
startIdPool ID at which scanning begins; default 0.
limitMaximum scan page, 1..128; default 64.
nextIdPass into the next call; nil means enumeration is complete.

items may contain fewer than limit entries because only currently streamed and valid entities are returned. A Handle may become stale immediately after the call.

Common Handle fields and methods

MemberTypeContract
typestringEntity type listed above.
poolIdintegerServer pool ID.
streamGenerationintegerGeneration of this streamed identity.
sessionIdintegerOwning session.
handle:is_valid()function -> booleanSafe stale check.
handle:position()function -> Vector3Current position; raises if stale. For an attached text label this is its configured offset.

Every type-specific method below takes no arguments and raises if the Handle is stale or of the wrong type.

Remote player

MethodReturn
name()UTF-8 string.
npc()boolean.
state()on_foot, passenger, driver, wasted, spawned, none, or unknown.
health()reported finite number.
armor()reported finite number.
vehicle_id()vehicle pool ID or nil. This is an ID, not a Vehicle Handle.

Server vehicle

MethodReturn
model()model ID integer.
health()finite number.
velocity()Vector3.
heading()finite heading number.

Server object

MethodReturn
model()model ID integer.
rotation()Vector3.
moving()boolean.
attachment(){ type = "object" | "vehicle", poolId = integer }ornil.

Actor

MethodReturn
model()model ID integer.
health()finite number.
invulnerable()boolean.
heading()finite heading number.

Pickup

MethodReturn
model()model ID integer.
pickup_type()pickup type integer.

3D text label

MethodReturn
text()UTF-8 string.
color()ARGB color integer in 0xAARRGGBB form.
draw_distance()finite number.
test_los()line-of-sight test boolean.
attachment(){ type = "player" | "vehicle", poolId = integer }ornil.