Notifications
Send notifications to a player from the server side.
SendNotify
KOJA.Server.SendNotify(data)
| Field | Type | Description |
|---|---|---|
source | number | Player server ID |
type | string? | "success", "error", "info", "warning" |
title | string? | Notification title |
desc | string | Notification body text |
time | number? | Duration in milliseconds |
icon | string? | Icon name (backend-specific) |
color | string? | Accent colour (backend-specific) |
The backend used is determined by Config.Notify — the same setting as the client.
Examples
-- Success
KOJA.Server.SendNotify({
source = source,
type = 'success',
title = 'Job Completed',
desc = 'You received $500.',
time = 5000,
})
-- Error
KOJA.Server.SendNotify({
source = source,
type = 'error',
desc = 'You do not have enough money.',
})
-- Info
KOJA.Server.SendNotify({
source = source,
type = 'info',
title = 'Server',
desc = 'Maintenance in 5 minutes.',
time = 10000,
})
Notify all players
koja-lib does not expose a "broadcast" helper. Use a standard server event:
-- Notify every connected player
for _, playerId in ipairs(KOJA.Server.GetPlayers()) do
KOJA.Server.SendNotify({
source = playerId,
type = 'warning',
desc = 'Server restart in 10 minutes.',
time = 8000,
})
end
Backends
| Config.Notify | Backend |
|---|---|
"esx" | ESX showNotification |
"qb" | QBCore QBCore.Functions.Notify |
"ox" | exports.ox_lib:notify |
"lib" | koja-lib built-in notification |
Related pages
- Police — Functions for checking how many police officers are online.
- Callbacks — The callback system allows server scripts to handle requests from clients and vice versa.
- Licenses — Check whether a player holds a specific driving or skill license.
- Money — Functions for reading and modifying a player's money on the server.
- Inventory — Server-side inventory functions.
- Player — Functions for reading player information on the server.
- Server API — back to the section overview