Skip to the content
Docs

Notifications, Chat & Weather

On this page3

How the panel shows notices, what it writes into the chat, and how it changes weather and time together with your sync script.

Notifications

Notices to players, and the notices staff get outside the panel window, go through one setting:

lua
Config.NotifySystem = 'qb'   -- 'qb' | 'ox_lib' | 'codem-notification' | 'esx'
ValueShown withNotes
'qb' (default)QBCore's own notify
'ox_lib'ox_lib notify
'codem-notification'codem-notificationThe title is "5CODE Admin".
'esx'ESX's own notificationThe kind of notice (information, success, error) is not passed on.

The panel sends three kinds of notice: primary (information), success and error.

Adding another notify script

bridge/notify.lua is open and runs on the player's game. It holds one function: Notify(msg, type).

  1. Add one elseif branch above the last else.
  2. Set Config.NotifySystem to the same name. Write it in lower case in the file: the panel reads the setting in lower case.
  3. Restart 5code-adminpanel.
lua
    elseif sys == 'esx' then
        ESX().ShowNotification(msg)
    elseif sys == 'my-notify' then                                -- your notify script
        exports['my-notify']:Notify(msg, ntype)                   -- use the export from its own docs
    else -- qb
        QB().Functions.Notify(msg, ntype)
    end

my-notify and its export are placeholders. ntype is 'primary', 'success' or 'error'. If your script uses other words, translate them in your branch.

Chat

These messages are shown as a notification and also written into the chat:

What staff sendNotificationChat line
A private message (Message on a player)<staff name>: <message>The staff member's name and the message
A heads-up before a sitStaff (ticket #12): <message>The same sender and the message
An announcement (World page)The messageANNOUNCEMENT and the message
  • The panel uses FiveM's standard chat event (chat:addMessage). A custom chat script may draw these lines in its own way: other colours, another layout.
  • If your chat does not use that event, there is no chat line. The notification is still shown.
  • The help text shown while typing one of the panel's commands uses the standard chat:addSuggestion event.
  • The words "Staff" and "ANNOUNCEMENT" are in the locale file: see Localization.

Weather, time and blackout

Most servers run a script that keeps weather and time the same for everybody. The panel must tell that script. If it only changed the weather itself, the sync script would put its own weather back a few seconds later.

Your server runsWhat the panel doesSupport
qb-weathersyncTells qb-weathersync the new weather, time or blackout.Supported
Renewed-WeathersyncThe same. It answers the calls of qb-weathersync, so there is nothing to set up.Supported
Another sync scriptAdd it at the marked places in bridge/world.lua.Stub / snippet
No sync scriptSets weather, time and blackout itself, for every player.Supported

With no sync script:

  • A player who joins later gets the weather and the blackout the panel set last.
  • The clock is not sent again to players who join later.

PvP on the World page never goes through a sync script. The panel always sets it itself, also for players who join later.

Adding another sync script

bridge/world.lua is open and runs on the server. It has four marked places: -- [[ ADD YOUR WEATHER / TIME SYNC SCRIPT HERE ]].

lua
local function system()
    if GetResourceState('qb-weathersync') == 'started' then return 'qb-weathersync' end
    if GetResourceState('my-weather') == 'started' then return 'my-weather' end
    return nil
end

function World.SetWeather(weather)
    local sys = system()
    if sys == 'qb-weathersync' then
        return exports['qb-weathersync']:setWeather(weather) ~= false
    end
    if sys == 'my-weather' then
        exports['my-weather']:setWeather(weather)     -- use the export from its own docs
        return true
    end
    -- the rest of the function stays as it is
end

Do the same in World.SetTime(hour, minute) and World.SetBlackout(on). my-weather and its exports are placeholders. Leave the lines below the marked place alone: they are what the panel does when no sync script runs.

FunctionGetsMust return
World.SetWeather(weather)A GTA weather name in capital letters, for example RAIN or EXTRASUNNYtrue when the weather was set
World.SetTime(hour, minute)Hour 0 to 23, minute 0 to 59true when the time was set
World.SetBlackout(on)true or falsetrue

What staff press: World. The settings on this page: General.