Commands#
Every command is typed in game. Most come with a default key, which each player can rebind in Settings → Key Bindings → FiveM; the names and keys are read from config/main.lua.
Command | Key | Who | Description |
|---|---|---|---|
|
| Everyone | Lock or unlock the nearest car you have access to. Key: |
|
| Everyone | Switch the engine of the car you are driving on or off. Key: |
|
| Everyone | Hotwire the car you are sitting in. Key: |
|
| Everyone | Rob the NPC driver you are aiming at. Key: |
|
| Everyone | Open the key transfer menu. |
|
| Everyone | The quick menu, inside a vehicle. |
| — | Everyone | A standard lockpick on the nearest locked car. The item is still required. |
| — | Everyone | Remove every key for a car you do not own. |
| — | Everyone | The same, from a menu. |
|
| Carrying a tracker | The list of tracked cars. |
| — | Allowed jobs | Scan the nearest car. |
| — | Boat drivers | Lower or raise the anchor. |
| — | Admins | Give the key of your current car to that player, or to the nearest one within 8 m. |
|
| Admins | The admin vehicle manager. |
Keys marked (off) are only bound when their
EnableKeyMapping(orEnableMenuKeyMapping) setting istrue; the command works either way. TheF7key goes away withConfig.KeyTransfer.EnableKeyMapping = false.
Client Exports#
For your own scripts on the client — garages, job menus, radial menus, HUDs.
Keys: GiveKeys, RemoveKeys, GetKey
-- Give the local player the key for a car
exports['qs-vehiclekeys']:GiveKeys(plate, model, bypassKeyCheck)
-- Take it away
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
-- Does the local player have access? (a key, the master key or ownership)
local hasKey = exports['qs-vehiclekeys']:GetKey(plate, model)
-- The same three, for the car the player is sitting in
exports['qs-vehiclekeys']:GiveKeysAuto()
exports['qs-vehiclekeys']:RemoveKeysAuto()
local hasKey = exports['qs-vehiclekeys']:GetKeyAuto()bypassKeyCheck = true adds a key even when the player already holds one. GetKey waits for the server's answer — call it from a thread, never from a per-frame loop.
Can this player drive it? CanUseVehicle
local canUse = exports['qs-vehiclekeys']:CanUseVehicle(vehicle)true for exempt models, cars this player hotwired, and cars they have access to. The answer is cached for five seconds.
Locks: OpenCar, CloseCar, DoorLogic, GetDoorState
exports['qs-vehiclekeys']:OpenCar(vehicle) -- unlock
exports['qs-vehiclekeys']:CloseCar(vehicle) -- lock
-- Full control: flips the lock, with every effect optional
exports['qs-vehiclekeys']:DoorLogic(vehicle, skipAnimation, forcedDoorStatus, skipNotification, skipSound, skipFlickerLights)
-- The native lock status, or -1 when the car does not exist
local state = exports['qs-vehiclekeys']:GetDoorState(vehicle)DoorLogic treats forcedDoorStatus as the car's current state and flips it: pass 1 to lock, 2 to unlock, nil to toggle. The new state is synced to every player. None of these check for a key — gate them in your own script.
Engine: toggleEngine, isEngineRunning
exports['qs-vehiclekeys']:toggleEngine() -- toggle the car being driven
exports['qs-vehiclekeys']:toggleEngine(true, vehicle) -- force a given car on
exports['qs-vehiclekeys']:toggleEngine(false, vehicle) -- or off
local running = exports['qs-vehiclekeys']:isEngineRunning(vehicle) -- vehicle optionaltoggleEngine respects Config.Engine.RequireKey and returns false when the player may not start that car.
Hotwire: disableHotwire
exports['qs-vehiclekeys']:disableHotwire(true) -- stop blocking cars for this player
exports['qs-vehiclekeys']:disableHotwire(false) -- back to normalFor races, events and jobs that hand out their own cars. It lasts until it is switched back or the player reconnects.
Key transfer: RequestKeyTransfer
local ok, message = exports['qs-vehiclekeys']:RequestKeyTransfer({
targetId = 12, -- the receiver's server id
plate = 'ABC 123',
model = 'SULTAN',
})Plays the hand-over and gives the receiver a copy, with the same checks as the menu. message is a translated sentence to show either way.
Lockpicks, plates, trackers, diagnostics and the anchor
exports['qs-vehiclekeys']:UseLockpick(false) -- true = advanced
exports['qs-vehiclekeys']:UsePlate('XYZ 789') -- the player needs that plate item
local format = exports['qs-vehiclekeys']:GetPlateFormat()
-- { PlateLetters = 3, PlateNumbers = 3, PlateUseSpace = true }
exports['qs-vehiclekeys']:UseGpsTrackerItem() -- fit a tracker to the nearest car
exports['qs-vehiclekeys']:OpenTrackerMenu() -- the list of tracked cars
exports['qs-vehiclekeys']:OpenDiagnostic() -- scan the nearest car
local anchored = exports['qs-vehiclekeys']:ToggleBoatAnchor()Each runs the same checks as its item or command — the item in the inventory, the job, the distance. UseRentalPapers is reserved and always returns false.
qb-vehiclekeys compatibility: HasKeys
local hasKeys = exports['qs-vehiclekeys']:HasKeys(vehicleOrPlate) -- nil = the current vehicleAn owner without a key is given one. See Replacing Other Key Scripts.
ox_inventory item exports
Registered only when ox_inventory is the inventory, for items' client.export:
'qs-vehiclekeys.useKey' -- vehiclekeys (standalone servers)
'qs-vehiclekeys.useLockpick' -- carlockpick (standalone servers)
'qs-vehiclekeys.useAdvancedLockpick' -- caradvancedlockpick (standalone servers)
'qs-vehiclekeys.usePlate' -- plate
'qs-vehiclekeys.useGps' -- vehiclegps
'qs-vehiclekeys.useTracker' -- vehicletrackerServer Exports#
How another resource hands out, takes back and checks keys — a garage, a dealership, a heist reward, a job depot.
GiveServerKeys
local ok = exports['qs-vehiclekeys']:GiveServerKeys(source, plate, model, bypassKeyCheck)Returns true when a key was added; false when the plate or model is empty, the inventory refused it, or — without bypassKeyCheck — the player already holds a key for that plate. Alias: GiveKeysServer.
RemoveServerKeys
local ok = exports['qs-vehiclekeys']:RemoveServerKeys(source, plate, model)Removes one key with that plate and model — or, when no model matches, one with that plate. Alias: RemoveKeysServer.
GetServerKey and HasVehicleAccess
local holdsKey = exports['qs-vehiclekeys']:GetServerKey(source, plate, model)
local canUse = exports['qs-vehiclekeys']:HasVehicleAccess(source, plate, model) -- model optionalGetServerKey is strict: a key item with exactly this plate and model. HasVehicleAccess is the check the script itself uses — the master key, any key with that plate, or ownership while OwnerAccessWithoutKey is on. Alias for the first: GetKeyServer.
CleanUnusedKeys
local removed = exports['qs-vehiclekeys']:CleanUnusedKeys(source)What /cleankeys does, without the notification: removes every key for a car the player does not own and returns how many went. Exists while Config.CleanKeys.Enabled is on.
qb-vehiclekeys compatibility: GiveKeys, RemoveKeys, HasKeys, SetLockState
exports['qs-vehiclekeys']:GiveKeys(source, vehicleOrPlate, skipNotification)
exports['qs-vehiclekeys']:RemoveKeys(source, vehicleOrPlate, skipNotification)
local ok = exports['qs-vehiclekeys']:HasKeys(source, vehicleOrPlate)
exports['qs-vehiclekeys']:SetLockState(vehicle, 'lock') -- or 'unlock'The same arguments as Qbox's key script, so calls written for it only need the resource name changed.
Events#
Client events you can trigger#
From the server with TriggerClientEvent(name, source, ...), or on the client with TriggerEvent — handy for radial menus:
Event | Arguments | Does |
|---|---|---|
|
| Lock or unlock the car with that plate, or the nearest. |
|
| Start a lockpick. The item is still required. |
| — | Open the key transfer menu. |
| — | Fit a tracker to the nearest car. |
| — | Open the list of tracked cars. |
| — | Scan the nearest car. |
| — | Measure the nearest car's window tint. |
|
| Start a plate swap with that plate item. |
|
| Show a Vehicle Keys notification. |
Server events and callbacks#
Name | Arguments | Does |
|---|---|---|
|
| Fired on the server after a plate swap. Listen with |
|
| From the client: set a car's lock state for everyone and remember it by plate. |
|
| From the client: give another player a key the sender holds. |
|
| ox_lib callback: the last lock state set on that plate, or |
Giving and removing keys has server events too, but use the exports: they keep the player's client in step, so a key handed over is usable the same instant.
About Plates and Models#
Every export cleans what it is given: plates and models are trimmed and upper-cased, so 'abc 123 ' and 'ABC 123' are one key. The model on a key is the name GTA reports for the vehicle (GetDisplayNameFromVehicleModel), which for most cars is the spawn name in capitals. Access is decided by the plate, so a key cut with the spawn name still opens a car whose display name differs — only GetServerKey insists on the model too.



