np_vehiclehandler ​
One server-owned lifecycle for vehicles created by the np_* resources. It tracks a vehicle by a stable string ID, creates and configures its OneSync entity, applies approved state on clients, and captures tuning changes from the current network owner.
Vehicles can be transient, registered for spatial streaming, or opted into persistent parking. Persistent records use oxmysql and can be restored after a resource or server restart. Persistence is opt-in: ordinary vehicles registered with this handler are not automatically written to the database. The current manifest requires oxmysql even if you only use transient exports.
What it handles ​
| Capability | What it does |
|---|---|
| Server lifecycle | Create, update, resolve and remove handler-managed vehicles. The server owns identity, model, routing bucket and transform. |
| Spatial streaming | For persistent world parking, creates an entity near players in the same routing bucket and removes the entity after it is no longer needed. The record remains. |
| Tuning snapshots | Captures approved vehicle properties from the current network owner and restores them on the next entity generation. |
| Vehicle behavior | Applies configured handling, door, suspension and other supported behavior through client natives. |
| Local helpers | Create and clean up local preview/display vehicles, inspect seats and support optional NPC driver helpers. |
| Integrations | Optional bridges for np_mechanic, np_fuel, vehicle keys, and engine-start vetoes. |
Identity and lifecycle ​
Use a stable application ID such as a garage record ID or a generated VIN. The handler also assigns a plate when one is not supplied. Server exports accept the stable ID, plate, entity handle or network ID where documented; prefer the stable ID in new code.
spawn(opts) creates a transient vehicle. registerPersistent(id, def) creates a durable world record. registerStreamed(id, def) is the convenience form for a persistent vehicle that should enter and leave the world according to nearby players. For a persistent vehicle that should stay as an entity, set streamed = false.
The np_vehiclehandler:started server event fires after stored records are loaded and existing handler entities have been adopted. It fires again after handler restart. Reconcile stable IDs in that event; check isReady() for the case where your resource starts afterward. See Installation.
Persistence is opt-in ​
Only records with persistent = true (or registered through the persistent exports) are stored. The schema from sql/install.sql must exist before using persistent parking. A persistent record is kept when its streamed entity is out of range; explicitly removing the record deletes its saved row so it will not reappear after a restart.
Persistence restores handler-owned data such as identity, transform, vehicle properties, state, behavior and metadata. It does not make arbitrary client-side changes durable: tuning capture is accepted only from the current owner under a one-time server token, and the handler validates the bounded snapshot before storing it.
Status and engine limits ​
This resource is written against FiveM natives and stub-based tests. It has not been checked on a live FiveM server. In particular, validate server vehicle creation and OneSync ownership migration on the artifact you run. The server cannot read every native vehicle property itself; client snapshots are therefore constrained and accepted only through the owner-validated capture flow.
It does not replace a garage, ownership database or key system. Integrate those resources explicitly, and authorize every gameplay action in your own server code.
Next steps ​
Installation · Configuration · Persistent parking · Tuning and properties · Behavior, attachments and helpers · Exports · Events · Integrations · Compatibility and migration · Performance