JG Docs
Vehicle Keys

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)
end

ReturnsTypeDescription
result.successbooleanWhether a key was supplied, reused or the vehicle was excluded
result.codestring?Error code when the request fails
result.datatable?Key details when available
result.data.ignoredboolean?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)
end

ReturnsTypeDescription
result.successbooleanWhether removal completed
result.codestring?Error code when removal fails
result.data.removednumber?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")
ReturnsTypeDescription
hasKeysbooleanWhether 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)
ReturnsTypeDescription
hasKeysbooleanWhether 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)
end

ReturnsTypeDescription
keystable[]Individual key entries, or an empty array when unavailable
entry.keyIdstringKey serial or virtual grant reference
entry.vehicleIdstringVehicle reference used internally by Vehicle Keys
entry.platestringCurrent saved plate
entry.modelstring|numberVehicle model
entry.vehicleNamestringVehicle display name
entry.designstringFob design
entry.validbooleanWhether this key currently provides access
entry.expiresAtnumber?Expiry as a Unix timestamp in seconds
entry.sharedBystring?Sharer's citizenid (QBCore/Qbox) or identifier (ESX)
entry.fleetRuleIdstring?Fleet rule reference
entry.slotnumber?Physical inventory slot
entry.virtualboolean?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)

ReturnsTypeDescription
result.successbooleanWhether the requested engine action was authorised
result.codestring?Error code when the action fails
result.data.netIdnumber?Vehicle network ID
result.data.lockedboolean?Current lock state
result.data.engineboolean?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

On this page