SAFScriptsDocs

Custom servers

SAF Traffic 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 Traffic asks your server. 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.SpeedUnit = 'kmh'
Config.Schedule.Enabled = true

Server hooks

FunctionWhat it doesDefault
Bridge.IsStaff(src)Who can use the panel and staff commandsConsole, traffic.staff ACE and Config.StaffGroups
Bridge.GetName(src)Name shown in the logThe player's FiveM name, console for the console
Bridge.Log(src, by, text)Where changes are loggedServer console
Bridge.Notify(src, msg, kind)A message to the playerSent to the client notify
Bridge.Announce(targets, title, text)How players hear about a closure or jam. targets is a list of player ids, or -1 for everyoneSent to each target's client

Client hooks

FunctionWhat it doesDefault
Bridge.Notify(msg, kind, title)Notification styleox_lib, then the framework's own, then the GTA feed
Bridge.Announce(title, text)How an announcement showsA warning notification

Your own staff system

custom/server/staff.lua
local base = Bridge.IsStaff
function Bridge.IsStaff(src)
    if exports['my-admin']:IsAdmin(src) then return true end
    return base(src)
end

Send changes to Discord

custom/server/log.lua
local hook = 'https://discord.com/api/webhooks/your/webhook'

function Bridge.Log(src, by, text)
    print(('[saf-traffic] %s: %s'):format(by, text))
    PerformHttpRequest(hook, function() end, 'POST',
        json.encode({ content = ('**%s**: %s'):format(by, text) }),
        { ['Content-Type'] = 'application/json' })
end

Announcements on your CAD or news ticker

custom/server/announce.lua
function Bridge.Announce(targets, title, text)
    exports['my-cad']:PostBolo(title .. ': ' .. text)
    TriggerClientEvent('saf-traffic:client:announce', -1, title, text)
end
SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

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