Custom servers
On this page
bridge/client.lua and bridge/server.lua are open in every edition. They hold everything SAF Garage asks
your server, one short function each. The better place for your changes is custom/: updates never touch it.
How custom/ works
Files in custom/ load after config.lua and bridge/, so anything defined there replaces the original.
| Folder | Use it for |
|---|---|
custom/shared/*.lua | Changing Config values |
custom/client/*.lua | Replacing any client Bridge.* function |
custom/server/*.lua | Replacing any server Bridge.* function |
To pick a framework by hand, set Config.Framework in a custom/shared/ file.
custom/shared/config.lua
Config.MaxVehicles = 25
Config.SpawnMode = 'garages'Server hooks
| Function | What it does | Default |
|---|---|---|
Bridge.GetIdentifier(src) | Who owns the vehicles. Must stay the same across sessions | citizenid on Qbox and QBCore, identifier on ESX, character id on ND and ox_core, license on standalone |
Bridge.IsStaff(src) | Who counts as staff | garage.staff ACE and Config.StaffGroups |
Bridge.GetVehicleLimit(src) | How many vehicles a player can keep | Config.StaffMax for staff, else Config.MaxVehicles |
Bridge.CanUseModel(src, info) | Which vehicles a player may save and take out | Everything except Config.Blacklist and Config.BlockedClasses |
Bridge.GiveKeys(src, veh, plate) | Server half of the keys | qbx_vehiclekeys |
Bridge.Notify(src, msg, kind) | A message to the player | Sent to the client notify |
Client hooks
| Function | What it does | Default |
|---|---|---|
Bridge.GiveKeys(veh, plate) | Client half of the keys | qb-vehiclekeys, wasabi_carlock, MrNewbVehicleKeys, qs-vehiclekeys, Renewed-Vehiclekeys |
Bridge.SetFuel(veh, level) | Fuel for a car that was just taken out | Game value, ox_fuel state bag, LegacyFuel, cdn-fuel, ps-fuel, lj-fuel, okokGasStation |
Bridge.CanOpen() | Block the menu. Return false, 'reason' | Blocked while dead |
Bridge.OnSpawned(veh, row) | Anything extra after a car is out | Empty |
Bridge.Notify(msg, kind) | Notification style. kind is 'success', 'error' or 'inform' | ox_lib when running, else the framework's own, else the GTA feed |
Limits and allowed vehicles
info holds info.hash, info.code (the spawn code when known) and info.class (GTA vehicle class).
custom/server/rules.lua
local base = Bridge.CanUseModel
function Bridge.CanUseModel(src, info)
if info.class == 18 and not IsPlayerAceAllowed(src, 'garage.emergency') then
return false, 'Emergency vehicles are for on-duty staff.'
end
return base(src, info)
end
function Bridge.GetVehicleLimit(src)
if IsPlayerAceAllowed(src, 'garage.vip') then return 30 end
return Config.MaxVehicles
endBlock the menu while cuffed
custom/client/open.lua
function Bridge.CanOpen()
if IsEntityDead(PlayerPedId()) then return false, 'You can\'t do that right now.' end
if LocalPlayer.state.isCuffed then return false, 'Not while cuffed.' end
return true
endKeys from another script
custom/client/keys.lua
function Bridge.GiveKeys(veh, plate)
exports['my-keys']:AddKey(plate)
end