np_prophandler v1.2.0 ​
One place where resources get their props from. A resource registers a prop once, and np_prophandler owns the rest: whether a player should see it, spawning and deleting it, hiding it at range, loading and releasing its model, replacing it when something else deletes it, and cleaning up when the owning resource stops. One streaming loop and one set of limits replace the distance loops each resource used to run on its own.
It is standalone. A framework is only used for job and gang conditions. np_hud, ox_target or qb-target show the interaction prompts, and np_admin gates the debug command and edits the settings. None of them is required. There is no database and no NUI.
Register once, the handler does the rest ​
-- server, in your resource
exports.np_prophandler:registerProp({
id = 'np_manufacturing:laptop_1',
model = 'prop_laptop_01a',
coords = vector4(-337.2, -136.5, 39.0, 70.0),
collision = false,
spawnDistance = 40.0,
interact = { label = 'Open', icon = 'laptop', event = 'np_manufacturing:workshop:open' },
data = { workshop = 1 },
})
From then on:
| Step | Who does it |
|---|---|
| Availability | np_prophandler. A prop is available to a player when it is enabled, its routing bucket matches and its job, gang and hour conditions match |
| Spawn / despawn | np_prophandler. Each client creates the prop inside spawnDistance, nearest first, and deletes it a while after the player has left |
| Render / derender | np_prophandler. Out of range, the prop is hidden at once and deleted later. An optional renderDistance hides it while it is still in range |
| Models | np_prophandler. One ref-counted loader with a timeout. Models missing from the game files are never requested again |
| Clean-up | np_prophandler. Everything a resource registered is removed when that resource stops |
| Reacting | Your resource. Listen to np_prophandler:spawned or the interact event. Do not delete the entity yourself; remove or disable the prop instead |
Kinds of props ​
| Kind | Where it lives | Use it for | Page |
|---|---|---|---|
| Streamed props | A local object on each client near it | Vending machines, lab equipment, workshop laptops, drops | Streamed props |
| Networked props | One OneSync object, created by the server while players are near | Crates and objects whose physics or position others must share | Networked props |
| Attached props | A local copy on every client that can see the ped | Phone in hand, carried box, ID card | Attached props |
| Immediate local props | A local object, created now | Placement ghosts, previews | Immediate local props |
| World models | The map itself | Hiding a map bench, swapping a sign | World models |
| Doors | The game's door system | Lockable doors, double doors and gates (up to 8 parts), with the lock state on the server | Doors |
On top of these, startPlacement is the placement tool every resource uses to let players put an
object into the world: a ghost on the crosshair, a move / rotate gizmo, keys and help text.
Its counterpart for peds is np_npchandler.
Used by ​
These np_* resources list np_prophandler in their dependencies and spawn their props through it: np_banking, np_billiards, np_cctv, np_darts, np_drugs, np_environmental, np_farming, np_fishing, np_fuel, np_gangs, np_golf, np_identification, np_inventory, np_manufacturing, np_metal-scanner, np_passwords, np_phone, np_prison, np_screens, np_shops, np_spy-pigeon, np_surveillance, np_vending.
Start np_prophandler before them. What each one registers is listed in
Migrating from CreateObject.
How it works ​
- Registry on the server. Props, world models and doors are registered through server exports. Each entry
belongs to the resource that called the export (
GetInvokingResource()). Only that resource can change or remove it. - Sync. A client gets one snapshot when it starts, then small state messages with consecutive revisions. A client that misses one asks for a new snapshot. See Events → Sync.
- Streaming on the client. Props sit in a 2D grid. A pass looks only at nearby cells and is skipped while the player stands still and nothing changed. See Streamed props.
- Interaction. A prop takes one
interactoption or a list of up to six, each with its own key, event and conditions. Client predicates (canInteract,setCanInteract) hide an option per player. See Interaction & availability. - Placement. One placement tool for every resource: the ghost follows the crosshair, a gizmo moves and turns it, and the caller validates the spot and handles the confirm. See Placing objects.
- Ready event.
np_prophandler:readyfires on the server and the client on every start of np_prophandler. Register in a handler for it and once on your own start. See Installation. - Conditions are not security.
jobs,gangs,hoursand client predicates decide what a player is shown. Doors re-check jobs and gangs on the server before a toggle. Anything else a prop triggers must be validated by your own server code.
Status ​
Not yet run on a live server
Version 1.2.0 was written against stubbed natives. The plain Lua specs in tests/ pass (validation, ownership and
clean-up, snapshots, streaming with hysteresis and delayed delete, the render tier, buckets, conditions, budgets,
model failures, local props, interaction providers and option lists, client predicates, networked and dynamic
networked props, attachments, world models, doors and gates, the ready event, the placement gizmo, the np_admin
permission gate and diagnostics). Nothing has been checked in game yet: not the natives, not the look, not the performance with real
player counts.
What needs a live test before you rely on it:
CreateObjectNoOffseton the server,SetEntityOrphanMode, entity state bags on server-created objects, and the recreation afterentityRemoved.- Server
GetEntityRotation/SetEntityCoordson server-created objects a client controls (dynamic props,setPropCoords), and how fast a client's moves reach the server. AddDoorToSystem/DoorSystemSetDoorState/RemoveDoorFromSystem.CreateModelHide/CreateModelHideExcludingScriptObjects/CreateModelSwap/RemoveModelHide/RemoveModelSwapparameters, and thatRemoveModelHidealso lifts a hide that keeps script objects.SetObjectTextureVariation, andSetEntityVisibleplus collision off for the render tier.AttachEntityToEntityflags on copies attached to other players' peds, and how fast player state bags follow scope changes.- np_hud's
ShowPromptwith several keys, the ox_target and qb-target option shapes, and both passing the distance tocanInteract. - The placement gizmo: the mouse cursor (
SetMouseCursorActiveThisFrame, controls 239 / 240), the screen hit tests and drag maths,SetEntityDrawOutline,GetShapeTestResultIncludingMaterial, the key glyphs in the help text, and how it feels (gizmo size, speeds, steps).
Known limits of the current version:
- After a missed state message, a client may wait up to
server.snapshotMinIntervalMs+ 5 s (35 s by default) for its new snapshot. - Every client holds every prop, world entry and door definition (up to
maxDefinitions, 4096) and filters locally. There is no per-area interest management. - Networked props: the server cannot check whether a model exists, so a bad model creates an entity clients cannot
draw. At the
maxActivecap, creation order is registry order, not nearest first. - A
dynamicnetworked prop is followed once per networked pass (1 s). An entity moved and deleted within one pass comes back where the previous pass saw it. createLocalandattachdo not wait for the model. Exports cannot wait across resources, so an unloaded model means entity0at first.- Doors have one built-in toggle and a binary lock state. There is no hold-open, automatic rate or double-door swing setting.
- The server has no in-game clock, so door toggles re-check jobs, gangs, bucket and distance, but not
hours.
Not supported:
- Vehicles. np_prophandler handles objects and doors only.
- Only attachments on the player's own ped can be synced. An attachment to a vehicle or another ped (
entity) is local, so others do not see np_fuel's nozzle in the fuel cap. A synced attachment cannot be moved: detach it and attach it again. - Attachments use rotation order 1, offsets up to 5 m and at most 32 per client (
attachments.maxLocal). np_manufacturing re-attaches its vehicle parts with rotation order 2 itself. - There is no client export to change an
addLocalPropentry. Remove it and add it again.
Versions ​
1.2.0 ​
Every 1.1.0 call works unchanged. New:
- The object placement gizmo:
startPlacement,updatePlacement,setPlacementValid,checkPlacement,confirmPlacement,cancelPlacement,stopPlacement,getPlacement,isPlacingand the local eventnp_prophandler:placement. - The
placementconfig block and the np_admin category Placement.
1.1.0 ​
Every 1.0.0 call works unchanged. New:
interactlists: up to six options per prop, each with its ownname, key, event, minigame andjobs/gangs/hours. The option name is the 5th event argument andredeemInteractiontakes it. See Interaction.- Client predicates:
canInteracton client entries,setCanInteractandsetDoorCanInteract.createLocaltakesinteracttoo. keepScriptObjectsonhideWorldModel.- Doors with up to 8 parts as one door (double doors, gates).
dynamicnetworked props withgetPropCoords,setPropCoordsandspawnProp.- The
np_prophandler:readyevent on the server and the client.