Exports ​
Server exports use a stable string ID wherever possible. Record lookups also accept the assigned plate and some entity/network aliases; use the specific lookup export when a numeric identifier could be ambiguous. Exports from a stopped resource throw. A consumer that uses the vendored wrapper can check available() and receive handler_stopped instead of silently creating a duplicate vehicle.
Server: lifecycle and lookup ​
| Export | Returns | Description |
|---|---|---|
spawn(opts) |
id, netId, entity or nil, reason |
Create and register a vehicle. opts.persistent = true opts into durable storage; streamed = false keeps an active entity. |
registerStreamed(id, def) |
id or nil, reason |
Register a persistent world vehicle that spawns near players in its routing bucket. |
registerPersistent(id, def) |
id or nil, reason |
Register a persistent record. With streamed = false, creates an always-live server entity. |
despawn(id, opts?) |
true or false, reason |
Remove entity and record; deletes persistent storage first. keepRecord = true is for a temporary stream-out. snapshot = true requests and waits for a current owner snapshot before removal. |
despawnVehicle(id, opts?) |
same as despawn |
Compatibility alias. |
adoptExisting(entity, opts?) |
id, netId, entity or nil, reason |
Track an existing server vehicle entity under a stable record. |
isReady() |
boolean |
Whether initialization and database record loading completed. |
getVehicle(value) / getRecord(value) |
record or nil |
Return the public record for an ID or supported alias. |
getByPlate(plate) / getByRealPlate(plate) / getByVIN(vin) |
record or nil |
Lookup by plate, mechanic-resolved real plate, or VIN. |
getByNetId(netId) / getByEntity(entity) |
record or nil |
Explicitly lookup by network ID or server entity handle. |
getId(value) |
stable ID or nil |
Resolve a supported ID/plate/entity/network alias. |
getHandle(value) |
entity, net ID or nil |
Return active entity handle when present, otherwise its network ID. Handle values are server-process local. |
getOwner(value) |
owner value or nil |
Get the stored owner field. |
queryRadius(coords, radius, bucket?) |
record list | Find registered records near a point, optionally filtered by routing bucket. |
spawn accepts model, coords, optional heading/rotation, vehicleType, plate, realPlate, owner, bucket, props, state, behavior, attachment, metadata, persistent and streamed fields. See Persistent parking for lifecycle choices.
Server: updates, attachments and helpers ​
| Export | Returns | Description |
|---|---|---|
setProps(value, props) |
true or false, reason |
Replace saved properties and apply them to the active entity owner. |
updateVehicle(value, patch) |
true or false, reason |
Update supported record fields and apply the new revision. |
setState(value, key, val) |
true or false, reason |
Set one state entry. |
setCustody(value, custody) |
true or false, reason |
Guarded impound/garage handoff. Only calls made from np_impound or np_garages are accepted. Setting { active = true, recordId = ..., status = ... } saves custody state and removes the live entity while keeping its record. Clearing custody resumes always-live records immediately and makes streamed records eligible for the next spatial pass. |
setMetadata(value, key, val) |
true or false, reason |
Set one metadata entry. |
setOwner(value, owner) |
true or false, reason |
Set a string owner or a typed { type, id } owner. Supported types: char, faction, gang, rental and npc. |
setBucket(value, bucket) |
true or false, reason |
Change record and active entity routing bucket. |
setAttachment(child, parent, offset, rotation, opts) |
true or false, reason |
Store a vehicle attachment relationship. |
setTrailer(trailer, tractor, offset, rotation, opts) |
true or false, reason |
Set a trailer relationship; equivalent to setAttachment with trailer mode enabled. |
clearAttachment(value) |
true or false, reason |
Clear the stored attachment. |
setHandling(value, modifiers) |
true or false, reason |
Set behavior handling modifiers. |
setLocked(value, locked) |
true or false, reason |
Update lock behavior. |
giveKeys(source, value) / removeKeys(source, value) |
boolean, optional reason | Grant or revoke keys through np_vehiclekeys when started. Grant has QB/QBX client-event fallbacks; revocation requires np_vehiclekeys. |
canStartEngine(source, value) |
boolean, optional reason | Check the configured server authorization provider and registered server vetoes. With no key provider or veto, the default is allowed. |
registerEngineVeto(name, callback) |
true or false, reason |
Register a server callback (source, id, plate, record) that can return false, reason to deny engine authorization. |
captureSnapshot(value, timeout?) |
true, record or false, reason |
Request current owner properties and await a one-time validated response; the second result is the updated public record. |
flush(value?) |
true or false, reason |
Persist one record or all persistent records. |
onLost(value, callback) |
true or false, reason |
Register a one-shot callback when the entity is unexpectedly lost or the record is removed. Receives a reason and public record. |
isAreaClear(coords, radius, ignore?) |
boolean |
Check whether a position is clear of vehicles. |
findFreeSpot(coords, radius?, steps?, ignore?) |
coords or nil, reason |
Search around a point for a clear vehicle spawn position. |
Exports that mutate ownership, lock state, vehicle properties or position do not authorize the calling player. Check access and business rules in your own server resource before calling them.
Client: property and local helpers ​
| Export | Description |
|---|---|
getProps(vehicle) / GetVehicleProps(vehicle) |
Collect supported ESX-style vehicle properties and optional integration state. |
setProps(vehicle, props) / SetVehicleProps(vehicle, props) |
Apply supported properties to a client vehicle. |
CreateLocal(opts) |
Create a local-only preview/display vehicle. |
createLocal(model, coords, heading, props) |
Positional compatibility form; the options table form is also accepted. |
SetLocalProps(entity, props) / setLocalProps(entity, props) |
Apply properties to a local helper owned by this resource. |
DespawnLocal(entity) / despawnLocal(entity) |
Remove a local helper entity. |
ApplyBehavior(vehicle, behavior) |
Apply supported behavior natives on a controlled vehicle. |
ApplyAttachment(vehicle, attachment) |
Apply the stored attachment to scoped entities. |
GetSeats(vehicle) / getSeats(vehicle) |
Return driver and occupied passenger seat handles. |
GetSeatOf(ped?) |
Return the vehicle and seat of a ped; defaults to the local player ped. |
CanStartEngine(vehicle) / canStartEngine(vehicle) |
Check local veto callbacks and current server authorization for a handled vehicle. |
AddEngineVeto(fn) / RemoveEngineVeto(id) |
Register or remove a local client callback. |
SpawnNpcDriver(vehicle, opts) |
Spawn a networked NPC via np_npchandler when available, or local-only fallback. |
DriveWaypoints(ped, vehicle, points, style?, speed?) |
Drive through an ordered list of waypoint definitions. |
Supported properties include vehicle mod slots 0–49, colors, neon/xenon, extras, liveries, body/engine/fuel/dirt state, damaged doors/windows/tyres and optional deformation/mechanic state. See Tuning and properties.
Vendored compatibility helper ​
Consumers can copy lib/np_vehiclehandler.lua into their resource and load it from the server manifest. It exposes NpVehicleHandlerCompat.available(), spawn, registerStreamed, registerPersistent, despawn, lookup/update methods, idFrom(value, 'entity' | 'netId'), entityFor(id), netIdFor(id) and call(operation, ...). It accepts the compatibility aliases SpawnVehicle and DespawnVehicle, is server-only for lifecycle operations, and never falls back to creating or deleting a second entity. See Compatibility and migration.