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:
Config.NotifySystem = 'qb' -- 'qb' | 'ox_lib' | 'codem-notification' | 'esx'| Value | Shown with | Notes |
|---|---|---|
'qb' (default) | QBCore's own notify | |
'ox_lib' | ox_lib notify | |
'codem-notification' | codem-notification | The title is "5CODE Admin". |
'esx' | ESX's own notification | The 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).
- Add one
elseifbranch above the lastelse. - Set
Config.NotifySystemto the same name. Write it in lower case in the file: the panel reads the setting in lower case. - Restart
5code-adminpanel.
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)
endmy-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 send | Notification | Chat line |
|---|---|---|
| A private message (Message on a player) | <staff name>: <message> | The staff member's name and the message |
| A heads-up before a sit | Staff (ticket #12): <message> | The same sender and the message |
| An announcement (World page) | The message | ANNOUNCEMENT 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:addSuggestionevent. - 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 runs | What the panel does | Support |
|---|---|---|
| qb-weathersync | Tells qb-weathersync the new weather, time or blackout. | Supported |
| Renewed-Weathersync | The same. It answers the calls of qb-weathersync, so there is nothing to set up. | Supported |
| Another sync script | Add it at the marked places in bridge/world.lua. | Stub / snippet |
| No sync script | Sets 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 ]].
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
endDo 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.
| Function | Gets | Must return |
|---|---|---|
World.SetWeather(weather) | A GTA weather name in capital letters, for example RAIN or EXTRASUNNY | true when the weather was set |
World.SetTime(hour, minute) | Hour 0 to 23, minute 0 to 59 | true when the time was set |
World.SetBlackout(on) | true or false | true |
What staff press: World. The settings on this page: General.