Give and check vehicle keys, open a house garage, impound a vehicle or start a cleanup from your own resources. Resources written for qbx_vehiclekeys need no changes.
The key exports exist only with enabled = true in data/keys.lua, and the cleanup exports only with enabled = true in data/carwipe.lua.
Server exports
GiveKeys
Gives a player the key of a plate. Does nothing if the player already has it.
exports.cuxial_garages:GiveKeys(source, plate)| Parameter | Type | Description |
|---|---|---|
source | number | Server id of the player. |
plate | string | Plate of the vehicle. Spaces around it are ignored and it is upper-cased. |
Returns: boolean. true when the player ends up with the key.
exports.cuxial_garages:GiveKeys(source, 'ABC12345')HasKeys
Tells whether a player carries the key of a plate.
local has = exports.cuxial_garages:HasKeys(source, plate)| Parameter | Type | Description |
|---|---|---|
source | number | Server id of the player. |
plate | string | Plate of the vehicle. |
Returns: boolean.
if not exports.cuxial_garages:HasKeys(source, plate) then return endRemoveKeys
Removes every key of that plate from the player's inventory.
exports.cuxial_garages:RemoveKeys(source, plate)| Parameter | Type | Description |
|---|---|---|
source | number | Server id of the player. |
plate | string | Plate of the vehicle. |
Returns: boolean. true when at least one key was removed.
exports.cuxial_garages:RemoveKeys(source, plate)ImpoundStoredVehicle
Sends a vehicle to the impound from its database id, without an officer. Made for vehicles that are stored: it does not remove a vehicle that is out in the world.
local result = exports.cuxial_garages:ImpoundStoredVehicle(data)| Parameter | Type | Description |
|---|---|---|
data.id | number | Id of the vehicle in the vehicle table. Required. |
data.cost | number | Fee to retrieve it. Defaults to defaultPrice from data/impound.lua. |
data.reason | string | Reason shown to the owner. Up to 255 characters. |
data.sentBy | string | Name shown as the person who impounded it. Up to 100 characters. |
data.job | string | Job recorded as the origin of the impound. |
data.depot | string | Id of the depot that holds it. Without it, the vehicle can be retrieved at any depot. |
data.fromState | number | State the vehicle must be in. Defaults to stored (1). |
Returns: table. On success { ok = true, cost, depot, depotLabel }. On failure { ok = false, reason }, where reason is 'bad_request', 'no_vehicle' or 'not_stored'.
local result = exports.cuxial_garages:ImpoundStoredVehicle({
id = vehicleId,
cost = 2500,
reason = 'Seized by court order',
sentBy = 'Department of Justice',
job = 'police',
})
if result.ok then print('Impounded for $' .. result.cost) endGetVehicleMdtInfo
Returns the nickname and the impound record of a plate. Made for police tablets.
local info = exports.cuxial_garages:GetVehicleMdtInfo(plate)| Parameter | Type | Description |
|---|---|---|
plate | string | Plate of an owned vehicle. |
Returns: table or nil when the plate has no owner.
| Field | Type | Description |
|---|---|---|
nickname | string | nil | Nickname set by the owner. |
impound | table | nil | nil when the vehicle is not impounded. Otherwise depot, cost, reason, selfRetrievable, sentBy, authorizedBy and date (Unix time). |
local info = exports.cuxial_garages:GetVehicleMdtInfo('ABC12345')
if info and info.impound then
print(('Impounded by %s: %s'):format(info.impound.sentBy, info.impound.reason or '-'))
endStartCarWipe
Starts a vehicle cleanup after a countdown shown to every player.
local ok, message = exports.cuxial_garages:StartCarWipe(seconds)| Parameter | Type | Description |
|---|---|---|
seconds | number | Countdown in seconds. Optional; countdown from data/carwipe.lua by default. |
Returns: boolean, string. false when a cleanup is already in progress. The string is the message to show.
local ok, message = exports.cuxial_garages:StartCarWipe(90)
print(message)CancelCarWipe
Cancels the cleanup in progress.
local ok, message = exports.cuxial_garages:CancelCarWipe()Returns: boolean, string. false when no cleanup is in progress.
IsWipeInProgress
Tells whether a cleanup countdown is running.
local running = exports.cuxial_garages:IsWipeInProgress()Returns: boolean.
Client exports
GiveKeys
Asks the server for the key of a plate for the local player. The server only grants it when the player owns the vehicle or the plate has no owner.
exports.cuxial_garages:GiveKeys(plate, vehicleEntity)| Parameter | Type | Description |
|---|---|---|
plate | string | Plate of the vehicle. |
vehicleEntity | number | Vehicle handle. Optional. When given, the player can use that vehicle at once, without waiting for the item. Use it for vehicles you spawn yourself, such as test drives. |
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
exports.cuxial_garages:GiveKeys(GetVehicleNumberPlateText(vehicle), vehicle)HasKeys
Tells whether the local player carries the key of a plate. It asks the server, so call it from a thread.
local has = exports.cuxial_garages:HasKeys(plate)Returns: boolean.
RemoveKeys
Removes the key of a plate from the local player.
exports.cuxial_garages:RemoveKeys(plate)IsVehicleAccessible
Tells whether the local player can use a vehicle: with its key, or through the shared keys of their job. It asks the server, so call it from a thread.
local allowed = exports.cuxial_garages:IsVehicleAccessible(vehicle)| Parameter | Type | Description |
|---|---|---|
vehicle | number | Vehicle handle. |
Returns: boolean.
if not exports.cuxial_garages:IsVehicleAccessible(cache.vehicle) then return endOpenGarage
Opens a house garage at a position given by your housing resource. The garage is not saved in the database and draws no marker: your resource handles the interaction point.
exports.cuxial_garages:OpenGarage(id, opts)| Parameter | Type | Description |
|---|---|---|
id | string | Unique id of the garage, up to 64 characters. Vehicles stored there stay tied to this id. |
opts.coords | vector4 | Access position, also used as the parking spot when no spawns are given. Required. |
opts.category | string | 'car', 'motorcycle', 'air' or 'sea'. Optional; all categories by default. |
opts.label | string | Name shown in the interface. Optional, up to 48 characters. |
opts.capacity | number | Vehicles per player, from 1 to 100. Optional. Applied only with capacity.enabled = true. |
opts.spawns | table[] | Parking spots as { x, y, z, h }. Optional, up to 16, each within 30 metres of coords. |
exports.cuxial_garages:OpenGarage('house:' .. property.id, {
coords = vector4(x, y, z, heading),
category = 'car',
label = 'Home garage',
capacity = 4,
})StoreVehicle
Stores the vehicle the local player is driving in a house garage. Does nothing if the player is not the driver.
exports.cuxial_garages:StoreVehicle(id, opts)| Parameter | Type | Description |
|---|---|---|
id | string | Id of the garage, the same one used with OpenGarage. |
opts | table | Optional. Same fields as OpenGarage. Without coords, the player's position is used. |
exports.cuxial_garages:StoreVehicle('house:' .. property.id, { category = 'car' })OpenGarage and StoreVehicle only work with externalGarages = true in shared/config.lua. The server also checks that the player is within interactDistance (8 metres by default) of coords, and accepts up to 25 house garages per player and session.
OpenImpound
Opens the impound form for the vehicle nearest to the local player, as /impound does. The player still needs an impound job.
exports.cuxial_garages:OpenImpound()qbx_vehiclekeys compatibility
Cuxial Garages answers these calls under the qbx_vehiclekeys name, so resources that use them keep working:
| Call | Behaviour |
|---|---|
exports.qbx_vehiclekeys:GiveKeys(source, vehicle) | Server. vehicle is a vehicle handle or a plate. |
exports.qbx_vehiclekeys:HasKeys(source, plate) | Server. Same as HasKeys above. |
exports.qbx_vehiclekeys:RemoveKeys(source, plate) | Server. Same as RemoveKeys above. |
lib.callback('qbx_vehiclekeys:server:giveKeys', false, cb, netId) | Called from the client. Grants the key of that vehicle when the player owns it or it has no owner. |
exports.qbx_vehiclekeys:GiveKeys(source, vehicle)State bags
| State bag | On | Meaning |
|---|---|---|
vehicleid | Vehicle | Database id of an owned vehicle delivered by a garage. Vehicles without it count as not owned. |
doorslockstate | Vehicle | Door lock state set by the key system. Above 1 = locked. |
ignoreLocks | Vehicle | Set it to true from your resource to keep a vehicle out of the lock system. |
rentalcode | Vehicle | Ticket code of a rented vehicle. |
Entity(vehicle).state:set('ignoreLocks', true, true)Events
Cuxial Garages triggers these server events locally, with TriggerEvent, so any server resource can listen to them with AddEventHandler.
| Event | Parameters | When |
|---|---|---|
cuxial_garages:server:VehicleSpawned | veh, vehicleId, plate | A vehicle leaves a garage, an impound, a job fleet or a rental. |
cuxial_garages:server:VehicleDeleted | id, plate | Staff delete a vehicle from the admin panel. |
cuxial_garages:server:VehicleTransferred | id, plate, newCitizenId | A vehicle is transferred to another player. |
cuxial_garages:server:PlateChanged | veh, oldPlate, newPlate | A vehicle plate changes while keys are handed over. |
AddEventHandler('cuxial_garages:server:VehicleSpawned', function(veh, vehicleId, plate)
-- veh is the vehicle entity; vehicleId is its database id
end)Custom integrations
Three options point to a resource by name. To use your own resource instead of the default, it must provide these server exports:
| Option | Exports your resource must provide |
|---|---|
dispatch.resource in data/keys.lua | SendDispatchAlert(data) |
license.resource in data/rental.lua | GetAvailableCards() returns a list of { type, label }. GetPlayerLicenses(citizenid) returns a list of { type }. |
finance.resource in shared/config.lua | getPlayerFinancedVehicles(citizenid), getFinanceByPlate(plate) and makeFinancePayment(source, plate) |
The theft alert sent to SendDispatchAlert:
{
title = 'Vehicle theft', -- translated text
type = 'vehicle',
code = '10-72',
coords = { x = 0.0, y = 0.0, z = 0.0 },
vehicle = { plate = 'ABC12345' },
central = true,
}