Skip to content

Events ​

All np_vehiclehandler:* events are resource events unless specifically described as network events. Server events emitted by the handler are useful for integration; they do not replace authorization in the resource that handles a gameplay action.

Ready ​

np_vehiclehandler:started fires on the server after initialization and persistence loading. It fires again after handler restart. Reconcile resource-owned stable IDs on this event; persistent rows are already loaded and should be looked up before registration. If a consumer starts later, check the isReady() server export; see Installation.

Server lifecycle events ​

Event Arguments When
np_vehiclehandler:started none Database records have loaded and the handler is ready for registrations.
np_vehiclehandler:entityCreated id, entity, vehicle The handler creates an entity for a record.
np_vehiclehandler:entityRemoved id, entity, vehicle A tracked entity is intentionally removed.
np_vehiclehandler:entityLost id, vehicle FiveM reports removal outside the handler's normal removal path.
np_vehiclehandler:streamedIn id, entity, vehicle A persistent streamed record gains a world entity.
np_vehiclehandler:streamedOut id, vehicle Its world entity is removed while its persistent record is kept.
np_vehiclehandler:removed id, vehicle The tracked record is removed.
np_vehiclehandler:vehicleReady id, playerSource, vehicle Server event emitted after the owning client acknowledged applying the current revision for an active generation.
np_vehiclehandler:snapshotSaved id, playerSource, vehicle A valid owner snapshot was accepted and saved.

Events are emitted by implementation paths and may be extended as the resource evolves. Consume only the fields you need and prefer exports for reads.

The server protocol event np_vehiclehandler:ready(id, generation, revision) is the owner acknowledgement request. The handler verifies source ownership, active entity and current generation/revision before emitting np_vehiclehandler:vehicleReady.

On the client, np_vehiclehandler:vehicleReady(record) is sent to the owning client after its acknowledgement is accepted. It is a notification that that client applied the current generation; use server-side exports for authoritative lookups.

Network protocol ​

The handler uses npvh:id, npvh:init and npvh:hydrated state-bag keys. The hydration marker is {id,generation,propsRevision} and avoids republishing full initialization data for readiness acknowledgements. The initialization value includes { id, generation, revision, props, state, behavior, attachment, propsRevision, hydratedPropsRevision }. Clients wait for a scoped entity and apply owner-only operations only when they have control. Generation/revision checks discard stale updates, and separate property revisions prevent an ownership migration from replaying an old full tuning snapshot over a driver's live changes.

np_vehiclehandler:apply(netId,id,generation,revision,payload) currently sends nil payload as a lightweight wake; clients use their cached initialization bag and retain support for legacy full payloads.

The internal np_vehiclehandler:apply, :ready, :capture, :snapshot and :dirty messages form the handler's client/server protocol. Do not trigger them from gameplay resources. The server validates current owner, active entity, generation, token and snapshot size before accepting a snapshot; clients cannot authorize spawns, deletes or owner changes.