Skip to content

Immediate local props ​

client

A local object created now, on this client only, and never streamed. Use it for previews and ghosts that your resource moves itself.

Letting the player place something

For a ghost the player moves into place, use startPlacement instead. It owns the ghost, the raycast, the gizmo and the keys.

lua
-- client
local handle, entity = exports.np_prophandler:createLocal({
  model = 'prop_tv_flat_01',
  coords = surface,
  alpha = 180,
  collision = false,
}, function(handle, entity)
  -- optional; runs only if the model was still loading
end)

-- move it yourself
SetEntityCoords(exports.np_prophandler:getLocalEntity(handle), x, y, z, false, false, false, false)

-- done
exports.np_prophandler:deleteLocal(handle)

Model loading ​

createLocal does not wait. Exports cannot wait across resources.

  • If the model is already loaded, the object is created at once and entity is returned.
  • Otherwise entity is 0 and the model loads in the background. The callback runs with (handle, entity) once the object exists, or with entity 0 if loading failed within streaming.modelLoadTimeoutMs (5 s). getLocalEntity(handle) returns the entity as well, 0 until it exists.
  • A model missing from the game files returns false, 'model_missing'.

Deleting the handle while the model loads cancels the creation.

Fields ​

Field Default Notes
model required Model name or hash. Checked against allowedModels when set
coords required vector3, vector4 or a table. The w / heading sets the heading
rotation from the heading { x, y, z } in degrees
frozen true
collision true
placeOnGround false
alpha opaque 0 to 255
invisible false
lodDistance game default 1 to 1000
textureVariation none 0 to 63

| interact | none | One option or a list, with canInteract but no minigame. See below |

Other fields (id, spawnDistance, jobs, …) are refused with 'unknown_field'. For a prop that should stream with distance, use addLocalProp.

Interaction ​

createLocal takes the same interact option or list as a streamed prop, with per-option canInteract. Options cannot have a minigame. The events carry the handle as id: (handle, entity, nil, nil, option). The prompt goes away with deleteLocal.

lua
-- client: a preview the player can confirm or cancel
local handle = exports.np_prophandler:createLocal({
  model = 'prop_tv_flat_01', coords = surface, alpha = 180, collision = false,
  interact = {
    { name = 'place', label = 'Place', icon = 'check', event = 'np_screens:ghost:place' },
    { name = 'cancel', label = 'Cancel', icon = 'xmark', event = 'np_screens:ghost:cancel' },  -- key G
  },
})

Limits and clean-up ​

  • At most locals.max (64) handles per client. Over that, createLocal returns false, 'local_limit_reached'.
  • A handle belongs to the resource that created it. Another resource gets false, 'not_owner' from deleteLocal.
  • Handles are deleted when the owning resource stops, and all of them when np_prophandler stops.