Skip to content

Reading & Writing Netprops

Access Source engine networked properties (netprops) via direct field lookups on entity objects.


Fields not defined as built-in API methods resolve directly against the entity’s receive tables:

local me = entity.get_local_player()
if not me then return end
-- Read netprops
local health = me.m_iHealth
local origin = me.m_vecOrigin
local flags = me.m_fFlags
-- Modify netprops
me.m_flFlashDuration = 0
  1. Short Property Names: Use bare names (e.g. m_iHealth, not DT_BasePlayer.m_iHealth).
  2. Recursive Lookup: Traverses nested datatables automatically.
  3. Invalid Properties: Non-existent properties return nil. Writing to invalid properties is ignored.

Source Data Type Lua Type Notes
int, short, byte, char number Packed integers are unpacked automatically.
float number Single precision float.
Vector vector vector(x, y, z)
QAngle qangle qangle(pitch, yaw, roll)
string / char* string Null-terminated string.
EHANDLE number Entity handle (pass to entity.from_handle).
Array / Datatable Array Wrapper 0-based memory wrapper.

Netprop arrays return 0-based memory wrappers:

local me = entity.get_local_player()
if not me then return end
-- m_hMyWeapons is a 64-element handle array
local weapons = me.m_hMyWeapons
for i = 0, 63 do
local handle = weapons[i]
if handle == -1 or handle == 0xFFFFFFFF then
break
end
local weapon = entity.from_handle(handle)
if weapon then
print(string.format("Slot %d: %s", i, weapon:get_classname()))
end
end
local res = entity.get_player_resource()
if res then
for i = 1, globals.max_players do
local kills = res.m_iKills[i]
local deaths = res.m_iDeaths[i]
local ping = res.m_iPing[i]
end
end