SAFScriptsDocs

Custom servers

SAF Garage is coming soon. These docs describe the build that will ship.

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.

FolderUse it for
custom/shared/*.luaChanging Config values
custom/client/*.luaReplacing any client Bridge.* function
custom/server/*.luaReplacing 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

FunctionWhat it doesDefault
Bridge.GetIdentifier(src)Who owns the vehicles. Must stay the same across sessionscitizenid on Qbox and QBCore, identifier on ESX, character id on ND and ox_core, license on standalone
Bridge.IsStaff(src)Who counts as staffgarage.staff ACE and Config.StaffGroups
Bridge.GetVehicleLimit(src)How many vehicles a player can keepConfig.StaffMax for staff, else Config.MaxVehicles
Bridge.CanUseModel(src, info)Which vehicles a player may save and take outEverything except Config.Blacklist and Config.BlockedClasses
Bridge.GiveKeys(src, veh, plate)Server half of the keysqbx_vehiclekeys
Bridge.Notify(src, msg, kind)A message to the playerSent to the client notify

Client hooks

FunctionWhat it doesDefault
Bridge.GiveKeys(veh, plate)Client half of the keysqb-vehiclekeys, wasabi_carlock, MrNewbVehicleKeys, qs-vehiclekeys, Renewed-Vehiclekeys
Bridge.SetFuel(veh, level)Fuel for a car that was just taken outGame 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 outEmpty
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
end

Block 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
end

Keys from another script

custom/client/keys.lua
function Bridge.GiveKeys(veh, plate)
    exports['my-keys']:AddKey(plate)
end
SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

Not affiliated with or endorsed by Rockstar Games, Take-Two Interactive or Cfx.re.