Migrating from CreateObject ​
Most np_* resources create their props themselves: CreateObject, a distance loop, AttachEntityToEntity, and a
clean-up sweep. This page maps each of those patterns onto np_prophandler, and lists what the np_* resources
register with it.
Patterns ​
| You do today | Use instead |
|---|---|
CreateObject near the player in a distance loop, delete when far |
Server registerProp once. Streaming, delayed delete and model loading are done for you. See Streamed props |
A networked CreateObject so others see the object |
Streamed props are already seen by every client near them. Only use networked = true when physics or position must be shared. See Networked props |
Networked CreateObject + AttachEntityToEntity for a prop in the hand |
Client attach({ …, synced = true, key = … }), detach(handle) when done. No networked object, no stray sweep |
| A server-decided carry (pick-up, drop) | Server setPlayerAttachments(src, key, list), nil to drop |
A ghost object for placement, after polling HasModelLoaded, with your own raycast and keys |
Client startPlacement: ghost, raycast, gizmo, keys and help text, your validate and onConfirm |
| A preview your resource moves itself | Client createLocal, move it with SetEntityCoords, deleteLocal when done |
PlaceObjectOnGroundProperly after spawning |
placeOnGround = true in the definition (not for networked props) |
spawned[id] bookkeeping and a loop to find your entities |
np_prophandler:spawned / despawned events and getPropEntity(id) |
A proximity prompt (ShowPrompt, a points loop, ox_target) per object |
The interact option, or a list of up to six. It picks np_hud, ox_target or qb-target by itself |
| A state check before showing a prompt (dead, cuffed, menu open) | A client predicate: canInteract or setCanInteract |
| A job check before showing an object | jobs / gangs / hours in the definition |
CreateModelHide / CreateModelSwap in a loop |
Server hideWorldModel / swapWorldModel. CreateModelHideExcludingScriptObjects: keepScriptObjects = true |
| Your own door lock sync | Server registerDoor and setDoorLocked. A double door or gate is one door with up to 8 parts |
| A networked object players move or carry off | A dynamic networked prop: it comes back where it was left |
Registering again on onResourceStart of np_prophandler |
np_prophandler:ready |
Deleting everything on onResourceStop |
Nothing. Everything a resource registered is removed when it stops |
How the np_* resources use it ​
These resources list np_prophandler in their dependencies. They have no own spawn loop and no fallback.
| Resource | What goes through np_prophandler |
|---|---|
| np_banking | Server registerProps: one streamed ATM per Config.Atm.locations entry with spawn = true (np_banking:atm_<index>). The client maps a scanned ATM to its location with getPropEntity. The ripped-out ATM of a robbery is a dynamic networked prop (np_banking:ripped_<id>, spawnProp): it stays where it was dragged |
| np_billiards | Server registerProps: custom and runtime tables (np_billiards:<tableId>), found on the client with getPropEntity. Balls and the aim-line cue are createLocal props, the cue in hand a synced attach (key cue). Map tables are not touched; their balls, rack and cue are hidden with hideWorldModel and keepScriptObjects |
| np_cctv | Client addLocalProp: cameras and recorders (np_cctv:cam:<id>, np_cctv:rec:<id>) with an interact list (keys E G H K X Y) and a canInteract per option. Cameras and recorders are placed with startPlacement (rotationMode = 'full' and a rotationOffset tilt for cameras) |
| np_darts | Server registerProps: board cabinets (np_darts:<boardId>, per routing bucket). Boards are placed on walls with startPlacement (headingOffset = 180, keepOnConfirm). Darts in the board and darts in flight are createLocal props, the dart in hand a synced attach (key dart) |
| np_drugs | Client addLocalProp: lab equipment (np_drugs:lab_<labId>_<i>), the first piece with interact (event np_drugs:lab:open) and a canInteract. Server registerProps: used syringes (np_drugs:syringe_<dropId>, event np_drugs:use:pickup). Held props with attach: synced on the player, local (entity) on another ped |
| np_environmental | Server registerProps: scene objects of kind prop, hazard and block (np_environmental:<scene>:<obj>). Editor ghosts and dropped boxes with createLocal, the tool in hand a synced attach (key tool) |
| np_farming | Server registerProp: processing stations (np_farming:processing:<locId>, event np_farming:prop:interact). Client addLocalProp: plants, pots, water barrels, hives, threats and pens. setCanInteract hides their options while the player cannot act. Plants, pots and field cells are placed with startPlacement (adjust snapping, keepOnConfirm), the hand prop with attach (key action) |
| np_doors | Server registerDoor / setDoorLocked: every door of the door system (npd_<id>, up to 8 parts, no interact), registered again on np_prophandler:ready; listens to np_prophandler:doorChanged |
| np_fishing | Server registerProps: market stalls (np_fishing:stall_<id>). Rod and shown-off fish are synced attachments (keys rod, fish). Float and dropped fish are createLocal props |
| np_fuel | Server registerProps: EV chargers (np_fuel:ev:<station>:<n>) with an interact option (event np_fuel:client:evCharge) gated by setCanInteract. Pumps keep np_fuel's own prompt. The nozzle in the hand is a synced attach (key nozzle), the nozzle in the fuel cap a local attach to the vehicle |
| np_gangs | The crate in Lester's trial is a synced attach (key trial_crate) |
| np_golf | Balls and tee pegs are createLocal props. The club in hand is a synced attach (key club) |
| np_identification | The card shown in the hand is a synced attach (key card) |
| np_inventory | Server registerProp: one streamed prop per ground drop (np_inventory:drop_<n>, placeOnGround). Props during item use and hand-overs with attach |
| np_manufacturing | Server registerProps: workshop laptops (np_manufacturing:laptop_<workshopId>, event np_manufacturing:workshop:open), hidden with setCanInteract while the console is open. Build parts are local attach calls on the vehicle; their anchor points are set with startPlacement and frame on the vehicle |
| np_metal-scanner | Client addLocalProp: one scanner gate per enabled scanner (np_metal-scanner:scanner:<id>). Placement ghost with createLocal. Wand and detector in the hand are synced attachments (key held) |
| np_passwords | Server registerDoor / setDoorLocked: one door per lock with lock.door (np_passwords:door:<lockId>, up to 8 parts). Server registerProp: keypad props for locks with meta.prop (np_passwords:<lockId>) |
| np_phone | The phone in the hand is a synced attach (key phone) |
| np_prison | Server registerDoor / setDoorLocked: cell doors (np_prison:cell:<facility>:<i>) when Config.Routine.doors.system is 'prophandler', or 'auto' without ox_doorlock or qb-doorlock. Progress bar props with attach (key held) |
| np_screens | Server registerProp: live tripods (np_screens:<tripodId>, in the reporter's routing bucket). The live camera or microphone is a synced attach (key live_rig). Screens are placed with startPlacement (rotationMode = 'full') |
| np_shops | Progress bar props with attach: synced on the player (key held), local on another ped |
| np_spy-pigeon | Server registerProp: loft coops (np_spy-pigeon:<loftId>, event np_spy-pigeon:loft:open). Droppings and the bird-spikes ghost are createLocal props |
| np_surveillance | Server registerProp: planted room bugs, laser mics and USB implants (np_surveillance.device.<id>) |
| np_vending | Server registerProps / updateProp: placed machines (np_vending:machine_<id>). Machines are placed with startPlacement (align = 'stand', keepOnConfirm), "Drink now" with a synced attach (key drink) |
The ones that register props, world models or doors do it again on np_prophandler:ready
when np_prophandler restarts. If you set server.attachments.clientModels, list the models these resources attach
with synced = true (phone, ID card, rod, fish, cue, club, dart, nozzle and the other held props), or those
attachments are refused.
Example: a held item ​
Before:
-- client
local function holdProp(model, bone, pos, rot)
RequestModel(model)
while not HasModelLoaded(model) do Wait(0) end
local ped = PlayerPedId()
local obj = CreateObject(model, GetEntityCoords(ped), true, true, false)
AttachEntityToEntity(obj, ped, GetPedBoneIndex(ped, bone), pos.x, pos.y, pos.z,
rot.x, rot.y, rot.z, true, true, false, true, 1, true)
SetModelAsNoLongerNeeded(model)
return obj
end
After:
-- client
local function holdProp(model, bone, pos, rot)
return exports.np_prophandler:attach({
model = model, bone = bone, offset = pos, rotation = rot,
synced = true, key = 'held',
})
end
-- release
exports.np_prophandler:detach(handle)
Example: workshop laptops ​
Before, every client spawned a laptop per workshop in its own loop. After, the server registers them once:
-- server
local defs = {}
for index, workshop in ipairs(Workshops) do
defs[#defs + 1] = {
id = ('np_manufacturing:laptop_%d'):format(index),
model = workshop.computerModel or 'prop_laptop_01a',
coords = vector4(workshop.point.x, workshop.point.y, workshop.point.z, workshop.heading),
collision = false,
enabled = workshop.enabled,
interact = { label = 'Open', icon = 'laptop', event = 'np_manufacturing:workshop:open' },
data = { workshop = index },
}
end
local count, failures = exports.np_prophandler:registerProps(defs)
for index, reason in pairs(failures) do
print(('laptop %d refused: %s'):format(index, reason))
end
Toggle a workshop with setPropEnabled(id, enabled) instead of deleting and recreating
the object.