Exports and events ​
The server exports are the supported integration boundary. Register a vehicle from trusted server code before granting keys or applying access rules.
local vehicleId = exports.np_vehiclekeys:RegisterVehicle(vehicleEntity, {
vehicleId = tostring(databaseVehicle.id),
plate = GetVehicleNumberPlateText(vehicleEntity),
owner = ownerIdentifier,
ownerType = 'char',
})
local canDrive = exports.np_vehiclekeys:HasKey(source, vehicleId, 'drive')
local keyId = exports.np_vehiclekeys:GiveKey(source, vehicleId, {
item = false,
reason = 'my_resource',
})
Check the resource's server/exports.lua for the full callable signatures. The API includes registration and lookup, key issue/copy/revoke, temporary and shared access, access checks, lock control, vehicle transfer and locksmith operations. Compatibility aliases are provided for common QB key exports.
Client exports expose HasKey(vehicle, 'drive'), HasKeys(vehicle), ToggleLock and OpenKey. A client cache miss returns nil; gameplay authorization belongs on the server.
Server events include lock state changes, key issue/revocation and access lifecycle notifications. The np_vehiclekeys:* state bags publish the registered stable vehicle ID and replicated lock state for presentation. Never accept a client state bag as authority for identity or ownership.
Plate lookup returns no result when multiple registered identities match. Resolve by stable ID in new integrations.