SAFScriptsDocs

Exports & events

On this page

Server exports

Lua
exports['saf-hud']:GetAOP()                -- 'Statewide'
exports['saf-hud']:SetAOP('Sandy Shores')  -- sets and announces it, as 'Server'

exports['saf-hud']:GetSOE('ls')            -- 'green'
exports['saf-hud']:GetSOE()                -- every area: { ls = 'green', ss = 'amber', pb = 'green' }
exports['saf-hud']:SetSOE('ls', 'red')     -- area id, level id

SetAOP and SetSOE work like the commands: the change is saved, synced to every player and announced.

Server events

Lua
AddEventHandler('saf-hud:aopChanged', function(text)
    print('AOP is now ' .. text)
end)

AddEventHandler('saf-hud:soeChanged', function(areaId, levelId)
    print(('SOE for %s is now %s'):format(areaId, levelId))
end)

Both fire after every change, whether it came from a command, the console or an export.

Client exports

Lua
exports['saf-hud']:SetHidden(true)   -- hide the whole HUD (cutscenes, menus, photo mode)
exports['saf-hud']:SetHidden(false)  -- show it again
exports['saf-hud']:IsHidden()        -- true while hidden with SetHidden

To hide the HUD on a condition of your own without calling an export, override Bridge.ShouldHide instead (see Custom servers).

Example: send SOE changes to your CAD

Lua
-- in your own server resource
AddEventHandler('saf-hud:soeChanged', function(areaId, levelId)
    exports['my-cad']:SetBanner(areaId, levelId)
end)
SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

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