SAFScriptsDocs

Custom servers

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

On this page

bridge/server.lua and bridge/client.lua hold everything SAF Pursuit asks your server. They are open in every edition. Keep your changes in custom/ so updates never overwrite them.

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 client Bridge.* functions
custom/server/*.luaReplacing server Bridge.* functions

Pick the framework by hand

custom/shared/framework.lua
Config.Framework = 'esx'

Config overrides

custom/shared/pursuit.lua
Config.Pit.Assist = 'off'
Config.Pit.MaxMph = 45
Config.Hud.Position = 'bottom-left'
Config.Vehicles.Models = { 'police4', 'fbi', 'fbi2' }

Server hooks

FunctionWhat it doesDefault
Bridge.IsPolice(src)Who can use modes and the PIT assistpursuit.use ACE, or a police job on duty
Bridge.GetJob(src)The player's job and duty, as { name, type, onduty }Read from the framework
Bridge.IsPursuitVehicle(src, veh, class)Which vehicles take a modeEmergency class or a listed model
Bridge.PursuitModels()Extra model hashes that count, sent to every clientFrom Config.Vehicles.Models
Bridge.Log(src, kind, msg)Where mode changes (kind = 'mode') and PITs ('pit') goServer console
Bridge.OnJobChange(cb)Framework events that change police statusQbox, QBCore, ESX, ND Core and ox_core job and load events

Client hooks

FunctionWhat it doesDefault
Bridge.Notify(msg, kind)Notification style. kind is 'inform', 'success' or 'error'ox_lib, then the framework's own, then the game feed

Your own police check

custom/server/police.lua
function Bridge.IsPolice(src)
    return exports['my-mdt']:IsOnDuty(src)
end

If your duty system changes without a framework event, the player's pursuitAllowed state may lag behind. Call the callback from Bridge.OnJobChange when duty changes:

custom/server/duty.lua
function Bridge.OnJobChange(cb)
    AddEventHandler('my-mdt:dutyChanged', function(src) cb(src) end)
end

Send logs to Discord

custom/server/log.lua
function Bridge.Log(src, kind, msg)
    print(('[saf-pursuit] %s'):format(msg))
    exports['my-logs']:Send('pursuit', msg)
end
SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

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