Koja Scripts
KOJA-LIB

Notifications

Send notifications to a player from the server side.

Notifications

Send notifications to a player from the server side.

SendNotify

KOJA.Server.SendNotify(data)
FieldTypeDescription
sourcenumberPlayer server ID
typestring?"success", "error", "info", "warning"
titlestring?Notification title
descstringNotification body text
timenumber?Duration in milliseconds
iconstring?Icon name (backend-specific)
colorstring?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.NotifyBackend
"esx"ESX showNotification
"qb"QBCore QBCore.Functions.Notify
"ox"exports.ox_lib:notify
"lib"koja-lib built-in notification
  • 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