Skip to content

np_logistics API ​

All exports are server-side. Calls from another resource are trusted resource calls; player actions use the NUI RPC path and are independently feature, ownership, range, and rate checked. The current host API level is 1 (npAddon.host({ api = 1 })). Registrations from sibling resources should occur in npAddon.attach('np_logistics', fn, { api = 1 }).

Supply orders ​

  • order(spec) -> orderId | nil, err: spec = { sink, from, to, kind?, cargo?, payer?, budget?, deadline?, npcFallback?, legs?, meta? }. The calling resource must own a registered sink. Budget is server validated and bounded.
  • Compatibility overload order(venueId, lines) -> orderId | nil, err is provided for the current np_commerce implementation. It posts an unfunded np_commerce sink order; new callers should use structured order(spec) with an explicit payer and budget.
  • createCourierLeg(spec) -> orderId | false, err: compatibility export consumed by current np_commerce. Accepts an order-shaped table with from, to/stash, cargo/items, payer, budget/reward, and optional order wrapper.
  • cancelOrder(orderId, reason) -> bool
  • getOrder(orderId) -> order | nil
  • getOrders(filter?) -> order[]

Register a sink with registerSink(id, { deliver, cancelled?, partial? }). deliver(order, contract) runs only when the final leg completes. Sinks are owner tracked and removed on resource stop.

Contracts and legs ​

  • postContract(src, spec) -> contractId | nil, err
  • getContracts(filter?) -> contract[]
  • getContract(id) -> contract | nil
  • acceptLeg(src, contractId, legSeq) -> bool, reason?
  • abandonLeg(src, contractId, legSeq) -> bool, reason?
  • completeLeg(src, contractId, legSeq, result) -> bool, reason?

Payouts and refunds use durable logistics_payouts rows with a unique payout reference. Funded player contracts transfer from the dedicated personal escrow holding account to the recipient's personal account. Without np_banking, posting debits framework bank money and online settlement credits the framework bank; offline payouts remain pending and retry when the player logs in. A framework credit interrupted after entering processing is uncertain and requires manual reconciliation rather than an automatic duplicate payment.

Units, places, and reputation ​

  • createUnit(type, spec) -> unitId | nil, err
  • getUnit(id) -> unit | nil
  • getUnitStash(id) -> stashId | nil
  • getUnitsAt(placeId) -> unit[]
  • sealUnit(id, sealId?) -> bool, reason?
  • breakSeal(id, src) -> bool, reason?
  • registerPlace(def) -> bool, reason?; unregisterPlace(id) -> bool
  • registerBin(placeId, def) -> binId | false, reason?
  • scheduleShip(def) -> shipId | nil, err; getShipSchedule() -> ship[]
  • getRep(cid) -> record; addRep(cid, delta, reason) -> rep
  • inspectCargo(src, stationId, unitIds, declaredKg, result) -> bool, record | reason
  • spawnVehicle(model, coords, heading, kind?, metadata?) -> entity, vehicleId | nil, err
  • hitchTrailer(src, truckEntity, trailerEntity) -> bool, reason?
  • unhitchTrailer(src, truckEntity, trailerEntity) -> bool, reason?

A place definition is { id, type, label, coords = { x, y, z }, ownerFaction?, sink?, meta? }. Bins are { code, capacityKg }.

Extension registrations ​

  • registerSink(id, def)
  • registerCargoType(id, def)
  • registerNpcFreightSource(id, generatorFn)
  • registerDockRig(id, def)
  • registerInspectionCheck(id, checkFn)
  • addHook(name, fn); supported veto points include beforeAccept, beforeHitch, beforeSeal, beforeBreakSeal, beforeHijack, beforeDeliver, and beforeNpcFallback.
  • registerMailboxProvider(id, { deliverToMailbox, dropAtDoor })
  • registerPremises(faction, premises) / releasePremises(faction, premises) for np_housing venue callbacks.
  • deliverToMailbox(propertyId, item, meta) / dropAtDoor(propertyId, item, meta) forward to a registered mailbox provider.

Server events use TriggerEvent and are not network events: np_logistics:orderCreated, contractPosted, legAccepted, legCompleted, contractDelivered, contractFailed, unitSealBroken, cargoStolen, inspection, shipArrived, and shipLeft.

Exports present in source ​

order, createCourierLeg, cancelOrder, getOrder, getOrders, postContract, getContracts, getContract, acceptLeg, abandonLeg, completeLeg, createUnit, getUnit, getUnitStash, getUnitsAt, sealUnit, breakSeal, registerPlace, unregisterPlace, registerBin, scheduleShip, getRep, addRep, registerSink, registerCargoType, registerNpcFreightSource, registerDockRig, registerInspectionCheck, addHook, registerMailboxProvider, registerPremises, releasePremises, deliverToMailbox, dropAtDoor, inspectCargo, getShipSchedule, spawnVehicle, hitchTrailer, unhitchTrailer.

Implementation notes above reflect the checked-in adapters. Live FiveM verification remains outstanding.