Skip to main content

Exports

Use exports.wasabi_carlock from the correct runtime. A client plate argument is not interchangeable with a server player ID or a vehicle entity handle.

warning

Server grants/removals are trusted resource APIs. Authorize the player, transaction, and vehicle in your calling resource. Do not wrap these exports in unrestricted client-triggered events. HasKey checks key possession, not database vehicle ownership.

Client exports​

HasKey
local hasKey = exports.wasabi_carlock:HasKey('ABC123')
  • plate: string vehicle plate.
  • Returns boolean; invalid plates return false.
  • Awaits a server response and checks physical or virtual possession.
  • The optional second target argument is compatibility-only and may only be the local player's server ID. It cannot inspect another player's keys.
GetAllKeys
local keys = exports.wasabi_carlock:GetAllKeys()
if keys then
for plate, hasKey in pairs(keys) do
if hasKey then print(plate) end
end
end

Returns a virtual-key map such as { ['ABC123'] = true }, or false when unavailable. This is not an array and does not enumerate physical inventory keys. Use HasKey for possession in either mode. An optional target argument may only identify the local player's server ID.

GiveKeys / GiveKey
local queued = exports.wasabi_carlock:GiveKeys('ABC123')
local sent = exports.wasabi_carlock:GiveKeys('ABC123', targetServerId)

GiveKey is an alias with the same arguments.

ParameterTypeRequiredDescription
platestringYesVehicle plate
targetServerIdnumberNoTransfer recipient; not a model or entity

Without a target, returns true when a self-grant request is queued, not when the key has been granted. Returns false for local rejection. Requests wait for vehicle/network readiness within keyGrantTimeout and still require server authorization. Terminal failure warnings are printed even with debug disabled.

With a target, returns true when a transfer request is sent, not confirmed. The server checks the feature switch, key possession, recipient eligibility, range, and routing bucket. givingKeys.removeFromGiver determines whether the giver retains the key.

Do not repeatedly call the export just because HasKey has not changed immediately. Where your server already authorizes the purchase or spawn, use the server grant API instead.

RemoveKeys / RemoveKey
local removed = exports.wasabi_carlock:RemoveKeys('ABC123')

RemoveKey is an alias. plate is a string. Returns a boolean, without forwarding the server failure reason. Requires manageKeys.enabled and manageKeys.allowSelfRemoval. The optional second target argument only accepts the local player's server ID.

Physical-key removal can fail after some matching keys have already been removed. A false result does not guarantee that nothing changed.

ToggleLock
local success, reason, locked = exports.wasabi_carlock:ToggleLock()
-- Or target a specific nearby plate:
local success, reason, locked = exports.wasabi_carlock:ToggleLock('ABC123')

With no plate, selects the closest streamed vehicle within locking.distance for which the player has a key. With a string plate, selects only a matching vehicle in range, without falling back to another vehicle.

Returns true, nil, locked on success (locked is a boolean), or false, reason on rejection. Server permission, range, session, and cooldown checks still apply. This toggles the lock; it is not an unconditional unlock API.

A second argument is reserved for internal inventory-use correlation; do not pass it from integrations.

OpenVehicleControls
local opened, reason = exports.wasabi_carlock:OpenVehicleControls('full')
-- 'compact' is also supported; omit the argument to use the configured default.

Opens controls for the player's current occupied vehicle, subject to key/access checks. Optional view is 'compact' or 'full'; omitted or invalid values use the configured default.

Returns true when opened, or false, reason on failure. This export is registered only when vehicleControl.enabled is true. Calling it when disabled produces a missing-export error, not a false result.

ManageKeysMenu
local opened = exports.wasabi_carlock:ManageKeysMenu()

Returns true when the virtual-key menu opens, or false when it cannot open (for example, no keys). Registered only in effective virtual-key mode with manageKeys.enabled = true; otherwise it is absent.

There is no GiveKeyMenu export in V3. Use the configured virtual-mode /givekey command or the transfer form of GiveKeys.

Server exports​

In these examples, playerId is a player server ID, plate is a string, and vehicle is a valid server-side vehicle entity obtained by your integration.

HasKey
local hasKey = exports.wasabi_carlock:HasKey(playerId, 'ABC123')

Returns boolean for physical or virtual key possession. Invalid plates or unavailable players return false.

GetAllKeys
local keys = exports.wasabi_carlock:GetAllKeys(playerId)

Returns the player's virtual-key map (plate → boolean), or false when unavailable. Does not enumerate physical inventory keys.

GiveKeys / GiveKey
local success, reason = exports.wasabi_carlock:GiveKeys(
playerId,
GetVehicleNumberPlateText(vehicle),
GetEntityModel(vehicle)
)
ParameterTypeRequiredDescription
playerIdnumberYesRecipient server ID
platestringYesVehicle plate
modelnumber or stringNoModel hash or spawn name, not entity handle

GiveKey is an alias. Returns success (boolean) and an optional failure reason (string). Pass the model when known so the correct profile key item and display label can be resolved. Without a model, profile resolution falls back to the configured default.

Trusted grants do not apply the client self-grant ownership/proximity policy. Repeated grants in metadata mode can create additional physical keys; ensure the calling purchase/spawn flow does not accidentally grant twice.

RemoveKeys / RemoveKey
local success, reason = exports.wasabi_carlock:RemoveKeys(playerId, 'ABC123')

RemoveKey is an alias. Removes matching keys from the specified player, not all holders of that plate. Trusted removals are not restricted by the client management settings.

Returns a boolean and optional reason. Physical keys must be non-stackable. An explicit inventory failure returns partial_removal after an earlier confirmed removal, or inventory_failed otherwise. Other failures include player_not_found and missing_key. Completed removals are not rolled back or automatically retried. Notifications and onKeyRemoved run only on complete success under the provider's return contract.

Inventory adapter exports​

These are provider callbacks, not general-purpose key-grant or lock APIs.

ExportRuntime / registrationContract
useKeyItem(event, item, inv, slot)Server, effective metadata mode with Ox InventoryConfigure server.export = 'wasabi_carlock.useKeyItem' on key definitions. Processes Ox's usingItem callback and returns false to stop the remaining use pipeline, not to report lock failure. Other event phases return no value.
useTgiannKeyItem(src, itemData)Server, after TGIANN key-use registrationOnly accepts the TGIANN invoking resource. Returns false to stop configured key use, including rejected key actions; true lets unrelated items continue. This is not a lock-success result.

Follow Installation for exact provider setup. Neither export is guaranteed to exist when its provider/feature is inactive.

Compatibility hooks​

The client vehiclekeys:client:SetOwner event is retained and queues the same validated self-grant flow:

TriggerEvent('vehiclekeys:client:SetOwner', 'ABC123')

The resource also supplies compatibility handlers for client qbx_vehiclekeys:HasKeys(vehicle) and server qbx_vehiclekeys:GiveKeys(target, vehicle). These accept vehicle entity handles, unlike Carlock's own plate-based exports. This is not a complete replacement for every QB/QBX vehicle-key API; audit each integration. See QBCore / Qbox issues.