SAFScriptsDocs

Custom servers

On this page

bridge/client.lua and bridge/server.lua are open in every edition. They hold everything SAF Scenes asks your framework and inventory, one short function each. You can edit them, but the better place for your changes is custom/: updates never touch it.

Pick by hand

If you renamed your framework or inventory resource, auto detection can miss it:

custom/shared/config.lua
Config.Framework = 'esx'
Config.Inventory = 'ox_inventory'

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

Server hooks

FunctionWhat it does
Bridge.GetIdentity(src)Who the player is: { id, name }, or nil when not loaded. Scenes are saved under id, so it must stay the same across sessions
Bridge.IsStaff(src)Who counts as staff
Bridge.ItemCount(src, item)How many of an item the player has
Bridge.RegisterUsableItem(item, cb)What happens when a player uses an item
Bridge.Notify(src, msg, kind)A message to the player

Client hooks

FunctionWhat it doesDefault
Bridge.Notify(msg, kind)A message to this playerox_lib notify
Bridge.Progress(label, ms)Progress bar while spraying or cleaning. Return true when finished, false when cancelledox_lib progress bar

Your own framework and inventory

custom/server/myframework.lua
function Bridge.GetIdentity(src)
    local p = exports['my-core']:GetPlayer(src)
    if not p then return nil end
    return { id = p.charId, name = p.name }
end

function Bridge.ItemCount(src, item)
    return exports['my-inventory']:Count(src, item)
end

Your own progress bar

custom/client/progress.lua
function Bridge.Progress(label, ms)
    return exports['my-progress']:Start({ label = label, duration = ms, canCancel = true })
end

Config overrides

custom/shared/config.lua
Config.MaxPerPlayer = 10
Config.BlockedWords = { 'badword' }
Config.Webhook = 'https://discord.com/api/webhooks/...'
SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

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