Esc to clear, Enter to open the best match, click an export to open it in its page
Vehicles

Garages API

Server exports for garages. A garage is a place and its bays; which cars are in it is each vehicle's own garage field. New to garages? Read Garages first.

Reading

GetGarage(key) / GetGarages()SERVER#

One garage by key, or every garage. Both return copies.

ParamTypeDescription
keystringThe garage's key (GetGarage only)
Returns: GetGarage → { garageId, key, resource, name, x, y, z, heading, spawnX, spawnY, spawnZ, spawnHeading, blipSprite, blipColor } or nil, plus private = true and managedBy for a property's garage. GetGarages → { [key] = garage }
Get garage keys from here, not from config.lua: a hardcoded key fails with "Wrong garage" once someone renames a garage.
GetNearestGarage(x, y, z, maxRange)SERVER#

The garage closest to a point, measured to its marker or nearest bay, so a far bay of a big car park still counts. Never returns a private garage.

ParamTypeDescription
x, y, znumberThe point
maxRangenumber?Only a garage within this many metres
Returns: string|nil key, number|nil distance
local c = GetEntityCoords(GetPlayerPed(source))
local key = exports.whip_core:GetNearestGarage(c.x, c.y, c.z, 15.0)
if key then exports.whip_core:DespawnVehicle(vehicleId, { garage = key, refuseOccupied = true }) end
GetGarageVehicles(key)SERVER#

The vehicles stored in one garage, as GetVehicle snapshots.

ParamTypeDescription
keystringThe garage's key
Returns: table[]; {} for a key that names no garage

Managing garages

CreateGarage / UpdateGarage / DeleteGarageSERVERWAITS#

Make, change and remove garages at runtime; blips and markers update on every client. A new garage gets one bay, at the spawn point; add more in /whip → Vehicles → Garages. Update changes only the fields you send.

FieldTypeDescription
keystringUnique; set at creation, never changed
namestringShown on the blip
x, y, z, headingnumberThe garage marker
spawnX, spawnY, spawnZ, spawnHeadingnumberThe first bay (default the marker)
blipSprite, blipColornumberMap blip style
Returns: CreateGarage(data) → table|false, string|nil; UpdateGarage(key, data), DeleteGarage(key) → boolean, string|nil. A garage another running resource made is refused; one made in /whip, by a property, or by a stopped resource is open to any
local garage, err = exports.whip_core:CreateGarage({
    key = 'impound', name = 'Impound Lot', x = 409.3, y = -1623.1, z = 29.3, heading = 230.0,
})
exports.whip_core:UpdateGarage('impound', { name = 'City Impound' })
exports.whip_core:DeleteGarage('impound')
Deleting a garage keeps its cars. DeleteGarage moves them to the nearest other garage (or the default one) and tells online owners where. In /whip, a garage with cars can't be deleted until the admin picks the public garage they move to.
SetVehicleGarage(vehicleId, garageKey)SERVERWAITS#

Move a stored vehicle to another garage: an impound releasing a car, a dealer delivering to the buyer's garage. DespawnVehicle with a garage refuses a car already put away ("Vehicle is already stored"); this moves it.

ParamTypeDescription
vehicleIdnumber|tableA vehicle reference
garageKeystringThe garage it now belongs to
Returns: boolean ok, string|nil err
It doesn't check access. Ask CanUseGarage before moving a player's car into a property garage; if they can't use it, WHIP moves the car to a public garage the next time access changes.
CanUseGarage(key, who)SERVER#

May this person use this garage? Always true for a public one. A private garage (a property's, keyed property:<id>) is for its owner and keyholders only: hidden bays, no blip, and its bay events refuse anyone else.

ParamTypeDescription
keystringThe garage
whonumber|tableA person: server id, or { charId = n }
Returns: true, or false, why ('No such garage', 'That garage belongs to …')
local ok, why = exports.whip_core:CanUseGarage(garageKey, source)
if not ok then return false, why end
exports.whip_core:SetVehicleGarage(vehicleId, garageKey)