Skip to content

Installation ​

Requirements ​

  • A recent FiveM server artifact (Lua 5.4, state bags).
  • OneSync for networked props and for other players to see synced attachments. Streamed props, world models and doors work without it.

Nothing else is required. There is no database and no NUI, so there is nothing to build.

Optional integrations ​

Everything below is detected at runtime with GetResourceState, and every call into it is wrapped in pcall.

Kind Resources What it adds
Framework es_extended, then qbx_core, then qb-core Job and gang for the jobs / gangs conditions. Without one, those conditions never match. ESX has no gangs; forks that add gang to the player are read
Interaction np_hud, then ox_target, then qb-target Shows the interact option: np_hud's prompt, or a target option. With none of them, interact options are not shown unless interaction.fallback = true
Staff np_admin The np_prophandler.debug permission node for prophandler_debug, and live settings. See Configuration → Editable in np_admin

The framework is picked again on every check, so the order in server.cfg does not matter for detection. Set framework in the config to force one.

Steps ​

  1. Put the resource in resources/ as np_prophandler. Other resources call its exports by that name (exports.np_prophandler:registerProp(…)).
  2. Add it to server.cfg before the resources that use it:
    cfg
    set onesync on
    
    ensure es_extended       # or qbx_core / qb-core, optional
    ensure np_hud            # or ox_target / qb-target, optional
    ensure np_admin          # optional
    ensure np_prophandler
    # np_inventory, np_phone, np_shops … and every other resource that uses it, after it
  3. Open shared/config.lua. The defaults are a working setup. See Configuration.

Registering: np_prophandler:ready ​

The registry lives in memory. When np_prophandler restarts, it is empty, and every resource that uses it must register its props, world models and doors again. Register once on your own start (when np_prophandler is already started) and again on np_prophandler:ready, instead of watching onResourceStart:

lua
-- server
local function registerAll()
  exports.np_prophandler:registerProps(myProps)
  exports.np_prophandler:registerDoor(myDoor)
end
AddEventHandler('np_prophandler:ready', registerAll)          -- { enabled, epoch }
if GetResourceState('np_prophandler') == 'started' then registerAll() end

-- client: local props, predicates and attachments go with np_prophandler too
AddEventHandler('np_prophandler:ready', function()
  exports.np_prophandler:addLocalProp(myLocalProp)
end)

The server raises np_prophandler:ready (a local event) on every start, once registrations are accepted, with { enabled, epoch } (epoch is new on every start). The client raises it once its exports are up, before the first snapshot arrives, so local props and predicates can be added right away. It is the same pattern as np_npchandler:ready. See Events.

Exports from a resource that isn't running throw. The np_* resources that use np_prophandler list it in their dependencies (Used by), so they do not start without it. If np_prophandler is optional for your own resource, check GetResourceState('np_prophandler') == 'started' or wrap the call in pcall, and keep your own fallback.

Check it works ​

  1. Run prophandler_debug in the server console. It prints the framework, the number of registered props (networked and active), world entries, doors and attachments, and the sync revision.
  2. As a player allowed np_prophandler.debug, run /prophandler_debug. F8 prints the client counts every 5 seconds:
    [np_prophandler] props 12 (available 12) | spawned 3 hidden 1 loading 0 failed 0 | networked 0 | locals 0 | attached 0 + remote 0 | world 0/0 | doors 0/0 | models 2
    Run it again to stop the print.
  3. Walk away from a prop: it disappears at spawnDistance + despawnMargin and is deleted 10 seconds later.

Turning parts off ​

Want Set
The whole resource off enabled = false (every register export returns false, 'resource_disabled')
No networked props server.networked.enabled = false (registering one returns false, 'networked_disabled')
No interaction prompts interaction.provider = 'none'
Only certain models allowedModels = { prop_vend_soda_01 = true, … }
Only certain models in client-synced attachments server.attachments.clientModels = { prop_npc_phone_02 = true, … }