Client API
giveKeys
Request a key for the local player by plate (GiveKeys is an alias).
-- plate: string
-- model: string spawn name or number model hash, optional
local result = exports["jg-vehiclekeys"]:giveKeys(plate, model)
-- example
local result = exports["jg-vehiclekeys"]:giveKeys("ABC123", "adder")
if not result.success then
print(result.code)
endreturn {
success = true,
data = {
keyId = "b0e2e0b9-1f7f-4ad4-9f08-6fce7fd6c1a2",
vehicleId = "42",
},
}| Returns | Type | Description |
|---|---|---|
result.success | boolean | Whether a key was supplied, reused or the vehicle was excluded |
result.code | string? | Error code when the request fails |
result.data | table? | Key details when available |
result.data.ignored | boolean? | true when Vehicle Keys excludes this vehicle |
The vehicle must be nearby. Registered vehicles require the player's ownership or an active Advanced Garages share. The selected Limited or Flexible key setup still applies.
removeKeys
Remove the local player's held keys for a plate (RemoveKeys is an alias).
-- plate: string
-- model: string spawn name or number model hash, optional
local result = exports["jg-vehiclekeys"]:removeKeys(plate, model)
-- example
local result = exports["jg-vehiclekeys"]:removeKeys("ABC123", "adder")
if result.success then
print(result.data.removed)
endreturn {
success = true,
data = {
removed = 1,
},
}| Returns | Type | Description |
|---|---|---|
result.success | boolean | Whether removal completed |
result.code | string? | Error code when removal fails |
result.data.removed | number? | Number of held physical copies or virtual grants removed |
Transferred and stashed copies keep their own validity.
hasKeys
Check whether the local player currently holds a valid key for a plate or network ID (HasKeys is an alias).
-- plateOrNetId: string plate or number network ID
local hasKeys = exports["jg-vehiclekeys"]:hasKeys(plateOrNetId)
-- example
local hasKeys = exports["jg-vehiclekeys"]:hasKeys("ABC123")| Returns | Type | Description |
|---|---|---|
hasKeys | boolean | Whether the player has a valid carried physical key or issued virtual grant |
This waits for a server response. Owning the vehicle alone does not count as holding a key. Use hasKeysForEntity for a client entity.
hasKeysForEntity
Check whether the local player holds a valid key for a client vehicle entity.
-- vehicle: number client entity, optional; defaults to the current vehicle
local hasKeys = exports["jg-vehiclekeys"]:hasKeysForEntity(vehicle)
-- example
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local hasKeys = exports["jg-vehiclekeys"]:hasKeysForEntity(vehicle)| Returns | Type | Description |
|---|---|---|
hasKeys | boolean | Whether the local key snapshot contains a valid key for the entity |
This returns immediately and uses the same arguments as Qbox's client HasKeys. It can return false while the key snapshot or vehicle binding is being refreshed.
getKeys
Get the local player's individual key copies and virtual grants (GetKeys is an alias).
local keys = exports["jg-vehiclekeys"]:getKeys()
-- example
for _, key in ipairs(exports["jg-vehiclekeys"]:getKeys()) do
print(key.plate, key.valid)
endreturn {
{
keyId = "b0e2e0b9-1f7f-4ad4-9f08-6fce7fd6c1a2",
vehicleId = "42",
plate = "ABC123",
model = "3078201489",
vehicleName = "Truffade Adder",
design = "truffade",
valid = true,
slot = 3,
},
}| Returns | Type | Description |
|---|---|---|
keys | table[] | Individual key entries, or an empty array when unavailable |
entry.keyId | string | Key serial or virtual grant reference |
entry.vehicleId | string | Vehicle reference used internally by Vehicle Keys |
entry.plate | string | Current saved plate |
entry.model | string|number | Vehicle model |
entry.vehicleName | string | Vehicle display name |
entry.design | string | Fob design |
entry.valid | boolean | Whether this key currently provides access |
entry.expiresAt | number? | Expiry as a Unix timestamp in seconds |
entry.sharedBy | string? | Sharer's citizenid (QBCore/Qbox) or identifier (ESX) |
entry.fleetRuleId | string? | Fleet rule reference |
entry.slot | number? | Physical inventory slot |
entry.virtual | boolean? | true for virtual grants |
Entries can include invalid keys. Check entry.valid before treating an entry as access. Multiple copies of the same vehicle key appear separately.
setEngineState
Request an explicit engine state for a client vehicle entity (SetEngineState is an alias).
-- vehicle: number client entity
-- on: boolean; true starts the engine, false stops it
local result = exports["jg-vehiclekeys"]:setEngineState(vehicle, on)
-- example
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local result = exports["jg-vehiclekeys"]:setEngineState(vehicle, true)return {
success = true,
data = {
netId = 54,
locked = false,
engine = true,
},
}| Returns | Type | Description |
|---|---|---|
result.success | boolean | Whether the requested engine action was authorised |
result.code | string? | Error code when the action fails |
result.data.netId | number? | Vehicle network ID |
result.data.locked | boolean? | Current lock state |
result.data.engine | boolean? | Authorised engine state |
The player must be in the driver's seat. Normal key and immobiliser checks apply. A required Ghost PIN or available hotwire interaction can open after a refused start; the returned result describes the original request.
putAwayKey
Close the current keys UI and put away its held prop (PutAwayKey is an alias).
exports["jg-vehiclekeys"]:putAwayKey()
-- example: call before opening another client interface
exports["jg-vehiclekeys"]:putAwayKey()A ground inspection returns to its saved ground location without giving the player the key.
useKey
Open a physical key's fob through your inventory's item-use callback (UseKey is an alias).
-- Inventory installation hook; data and slot come from your inventory.
-- data: table item data
-- slot: table slot data, optional
exports["jg-vehiclekeys"]:useKey(data, slot)
-- example: inside your inventory's item-use callback
exports["jg-vehiclekeys"]:useKey(item, slot)
-- ox_inventory client export name: "jg-vehiclekeys.useKey"Pass the inventory's original item data so Vehicle Keys can verify the issued serial.
useKeyring
Open a carried keyring through your inventory's item-use callback.
-- Inventory installation hook; data and slot come from your inventory.
-- data: table item data
-- slot: table slot data, optional
exports["jg-vehiclekeys"]:useKeyring(data, slot)
-- example: inside your inventory's item-use callback
exports["jg-vehiclekeys"]:useKeyring(item, slot)
-- ox_inventory client export name: "jg-vehiclekeys.useKeyring"A group of copies for one vehicle opens its fob; a combined ring opens the Keyring menu.
useLockpick
Start the configured lockpicking interaction through your inventory's item-use callback (UseLockpick is an alias).
-- Inventory installation hook; data and slot come from your inventory.
-- data: table item data for the configured lockpicking kit
-- slot: table slot data or number slot index, optional if data.slot is set
exports["jg-vehiclekeys"]:useLockpick(data, slot)
-- example: inside your inventory's item-use callback
exports["jg-vehiclekeys"]:useLockpick(item, slot)
-- ox_inventory client export name: "jg-vehiclekeys.useLockpick"useSecurityItem
Use a configured security item through your inventory's item-use callback.
-- Inventory installation hook; data and slot come from your inventory.
-- data: table item data
-- slot: table slot data or number slot index, optional if data.slot is set
exports["jg-vehiclekeys"]:useSecurityItem(data, slot)
-- example: inside your inventory's item-use callback
exports["jg-vehiclekeys"]:useSecurityItem(item, slot)
-- ox_inventory client export name: "jg-vehiclekeys.useSecurityItem"It supports the configured GPS, alarm, immobiliser, jammer and tracker-removal items.
Last updated 1 November 2026