Skip to content

Streamed props ​

A streamed prop is a local, non-networked object. The server registers it once. Every client that should see it creates its own copy while the player is near and deletes it after the player has left. This is the default kind: a prop without networked = true is streamed.

lua
-- server
local ok, reason = exports.np_prophandler:registerProp({
  id = 'np_shops:vending_1',
  model = 'prop_vend_soda_01',
  coords = vector4(25.7, -1345.6, 29.5, 270.0),
  spawnDistance = 60.0,
  interact = { label = 'Buy a drink', icon = 'bottle-water', event = 'np_shops:vending' },
  data = { machine = 1 },
})
if not ok then print('vending prop refused: ' .. reason) end
lua
-- client
AddEventHandler('np_prophandler:spawned', function(id, entity, data)
  if id == 'np_shops:vending_1' then
    -- the entity exists now; don't delete it yourself
  end
end)

Register many at once with registerProps. It sends one state message for the whole list. removeProps and removeAllProps remove in one message too.

Distance tiers ​

Each pass compares the player's position with every prop in the nearby grid cells. Distances are 3D.

 player ── renderDistance ── spawnDistance ── + despawnMargin ──────────▶
 │ shown │ hidden, kept      │ (hysteresis)  │ hidden at once, deleted
 │       │ (render tier)     │               │ after despawnDelayMs
Tier When What happens
Spawn Within spawnDistance (default 80.0) and available The model is loaded and the object created. Nearest first, at most streaming.maxSpawnsPerTick (4) per pass
Render Optional renderDistance. Beyond it (+ streaming.renderMargin, 3 m, once shown) The object is hidden (invisible, no collision) but not deleted. Inside renderDistance it is shown again. A prop spawned beyond its renderDistance starts hidden
Despawn margin Between spawnDistance and spawnDistance + streaming.despawnMargin (10 m) A spawned prop stays. Standing on the boundary does not spawn and delete it again and again
Delayed delete Beyond spawnDistance + despawnMargin Hidden at once, deleted after despawnDelayMs (default 10000). Coming back before that shows it again without creating a new object

A prop that stops being available (disabled, other routing bucket, a condition no longer matches) is deleted at once, without the delay. A prop whose definition changed through updateProp is deleted and created again.

Budgets ​

  • streaming.maxActive (256) caps the streamed props per client, hidden ones included. At the cap, hidden props waiting for deletion are evicted first, soonest deadline first.
  • A pass is skipped while the player stays within streaming.moveThreshold (2 m) of the last scanned position and nothing changed. A full pass still runs every streaming.revalidateIntervalMs (10 s), so a prop that something else deleted comes back.
  • While nothing is registered at all, the loop runs every streaming.idlePollIntervalMs (2 s) instead of streaming.pollIntervalMs (500 ms).

Models ​

  • One ref-counted loader for every feature. A model is requested on first use and released with SetModelAsNoLongerNeeded when the last user is done.
  • IsModelInCdimage is checked first. A model missing from the game files is never requested again.
  • A model that does not load within streaming.modelLoadTimeoutMs (5 s) is tried again after streaming.retryDelayMs (30 s).

Prop definition ​

The same fields are used by registerProp, updateProp and addLocalProp. Unknown fields are rejected with 'unknown_field'.

Field Default Notes
id required Letters, digits and . _ : -, up to 64 characters. Prefix it with your resource name
model required Model name or hash. Checked against allowedModels when set
coords required vector3, vector4, or a table with x, y, z and optional w / heading
rotation from the heading { x, y, z } in degrees. Overrides the heading
routingBucket all buckets Only players in this bucket get the prop. Networked props: bucket 0 when unset
spawnDistance 80.0 5 to 300
renderDistance none 1 to spawnDistance. Hides the prop beyond it without deleting it
despawnDelayMs 10000 0 to 120000. Hidden props are deleted after this
frozen true
collision true
placeOnGround false PlaceObjectOnGroundProperly after creation. Not for networked props
alpha opaque 0 to 255
invisible false Never drawn, keeps its collision (invisible walls)
lodDistance game default 1 to 1000
textureVariation none 0 to 63 (SetObjectTextureVariation)
enabled true A disabled prop stays registered but is not spawned. See setPropEnabled
jobs, gangs none { police = 0 } (name → minimum grade) or { 'police' }. Matching either one is enough. See Conditions
hours none { from = 22, to = 6 }, in-game hours, wraps past midnight
interact none One option or a list of up to 6. See Interaction
networked false Server registrations only. See Networked props
dynamic false Networked only ('dynamic_requires_networked'): the server follows the entity and creates it again where it was left. See Props that move
data none Small table passed to events: 3 levels deep, 32 entries, strings up to 256 characters. No functions

Validation reasons: 'definition_not_table', 'unknown_field', 'invalid_id', 'invalid_model', 'model_not_allowed', 'invalid_coords', 'invalid_rotation', 'invalid_heading', 'invalid_routing_bucket', 'invalid_spawn_distance', 'invalid_render_distance', 'invalid_despawn_delay', 'invalid_alpha', 'invalid_lod_distance', 'invalid_texture_variation', 'invalid_flag', 'networked_not_allowed', 'networked_place_on_ground', the interact reasons, 'invalid_jobs', 'invalid_gangs', 'invalid_hours', 'invalid_data'.

Client-only streamed props ​

client

A client can add streamed props that only it sees. They use the same definition and the same streaming, and are never sent anywhere.

lua
-- client
exports.np_prophandler:addLocalProp({
  id = 'np_fishing:crate',
  model = 'prop_box_wood02a',
  coords = vector3(-1850.2, -1250.4, 8.6),
  placeOnGround = true,
})

exports.np_prophandler:removeLocalProp('np_fishing:crate')
  • They belong to the calling resource and are removed when it stops. removeAllLocalProps removes all of them.
  • networked = true is refused with 'networked_not_allowed'.
  • interact options may carry canInteract, a client predicate. A minigame is refused ('minigame_server_only').
  • Local and server props have separate id spaces, so neither can replace the other. When both use the same id, the client exports (getPropEntity, getProp, …) return the server prop. Events carry the plain id either way, so prefix ids with your resource name.

Rules ​

  • Don't delete handles you get from the handler. Remove or disable the prop instead. A prop deleted by something else is created again on the next full pass.
  • np_prophandler:despawned is raised before the object is deleted, so the handle is still valid in the handler.
  • Everything a resource registered is removed when that resource stops. When np_prophandler restarts, register again on np_prophandler:ready.