Garages V2
Exports and Hooks
Client exports, server exports, and custom hook functions available in Garages V2.
On this page4 sections
Client exports
All exports use the sc_garages resource name.
Zone state
inGarageZone
Returns whether the player is inside a garage zone.
local inside = exports.sc_garages:inGarageZone()getCurrentZoneType
Returns the active zone type.
local zoneType = exports.sc_garages:getCurrentZoneType()-- Returns: "Vehicle" | "Planes" | "Boat" | nilgetCurrentZoneName
Returns the active garage zone name.
local zoneName = exports.sc_garages:getCurrentZoneName()getCurrentImpoundName
Returns the active impound name in the current UI context.
local impoundName = exports.sc_garages:getCurrentImpoundName()Vehicle data
getVehiclesData
Returns the last vehicle list used by the UI.
local vehicles = exports.sc_garages:getVehiclesData()UI control
openGarage
exports.sc_garages:openGarage()openImpound
exports.sc_garages:openImpound()openPlaneGarage
exports.sc_garages:openPlaneGarage()openBoatGarage
exports.sc_garages:openBoatGarage()closeGarageUi
exports.sc_garages:closeGarageUi()Server exports
Vehicle CRUD
vehicleExists
local exists = exports.sc_garages:vehicleExists(plate)getVehicle
local row = exports.sc_garages:getVehicle(plate)getPlayerVehicles
local vehicles = exports.sc_garages:getPlayerVehicles(ownerIdentifier)addVehicle
local ok, plateOrReason = exports.sc_garages:addVehicle(ownerIdentifier, plate, model, vtype, garage, props)removeVehicle
local ok = exports.sc_garages:removeVehicle(plate)Plate and transfer
changePlate
local ok, result = exports.sc_garages:changePlate(ownerIdentifier, oldPlate, newPlate)transferVehicle
local ok = exports.sc_garages:transferVehicle(plate, newOwnerIdentifier)Storage state
storeVehicle
local ok = exports.sc_garages:storeVehicle(plate, location)unstoreVehicle
local ok = exports.sc_garages:unstoreVehicle(plate, location)updateVehicleProps
local ok = exports.sc_garages:updateVehicleProps(plate, props, vtype, location)Insurance
setInsurance
local ok = exports.sc_garages:setInsurance(ownerIdentifier, plate, insuranceData)clearInsurance
local ok = exports.sc_garages:clearInsurance(ownerIdentifier, plate)Co-owner
setCoOwner
local ok = exports.sc_garages:setCoOwner(ownerIdentifier, plate, coOwnerIdentifier)clearCoOwner
local ok = exports.sc_garages:clearCoOwner(ownerIdentifier, plate)History
logVehicleHistory
exports.sc_garages:logVehicleHistory(ownerIdentifier, plate, action, details, actorId, actorName, location)getVehicleHistory
local history = exports.sc_garages:getVehicleHistory(plate, limit)getOwnerHistory
local history = exports.sc_garages:getOwnerHistory(ownerIdentifier, limit)Police tow
towVehicle
local result = exports.sc_garages:towVehicle(plate, impoundName, holdHours, actorSrc, reason)-- Returns: { success, reason, holdUntil }setVehicleHold
local result = exports.sc_garages:setVehicleHold(plate, holdHours)-- Returns: { success, holdUntil }releaseVehicleHold
local result = exports.sc_garages:releaseVehicleHold(plate)-- Returns: { success }getVehicleHold
local hold = exports.sc_garages:getVehicleHold(plate)-- Returns: { plate, holdUntil, isActive, remaining } | nilCustom hooks
Custom hook functions are available in client/functions.lua.
Available hooks
Functions.onGarageEnter(zoneName, zoneType)
Called when a player enters a garage zone.
Functions.onGarageExit(zoneName)
Called when a player leaves a garage zone.
Functions.canStoreVehicle(vehicle, plate, zoneType)
Called before vehicle storage.
function Functions.canStoreVehicle(vehicle, plate, zoneType) return true, nilendFunctions.onVehicleStored(plate, zoneType)
Called after a vehicle is stored.
Functions.onVehicleSpawned(plate, spawnCoords)
Called after a vehicle spawns.
Functions.onShowroomEnter(showroomName)
Called when a player enters a showroom.
Functions.onShowroomExit(showroomName)
Called when a player exits a showroom.
Functions.canOpenImpound(impoundName, playerJob)
Called before opening an impound UI.
function Functions.canOpenImpound(impoundName, playerJob) return true, nilendFunctions.onVehicleReleased(plate, fee)
Called after impound release.
Hook example
Restrict storage when fuel is too low:
function Functions.canStoreVehicle(vehicle, plate, zoneType) local fuel = GetVehicleFuelLevel(vehicle) if fuel < 10 then return false, "Vehicle needs at least 10% fuel to store" end return true, nilendLog a custom message when a vehicle spawns:
function Functions.onVehicleSpawned(plate, spawnCoords) print(("Vehicle %s spawned at %.1f, %.1f, %.1f"):format( plate, spawnCoords.x, spawnCoords.y, spawnCoords.z ))end