esx_notify
esx_notify reference for ESX Legacy. Show NUI notifications with ESX.ShowNotification, the Notify export or server events, plus types, positions and config.
esx_notify is the default notification UI of ESX Legacy. It draws small toast
notifications with a type (success, error, info, warning), an optional title
and a configurable screen position. You rarely call it directly:
ESX.ShowNotification on the client and xPlayer.showNotification on the
server both end up in this resource.
Overview
| Resource | esx_notify |
| Side | Client only (server code uses events or xPlayer) |
| Dependencies | es_extended (loads @es_extended/imports.lua) |
| UI | NUI page (nui/index.html), jQuery, Material Symbols icons |
| Required | Yes, ESX.ShowNotification errors when it is missing |
Configuration
Config.lua has two keys.
| Key | Default | Description |
|---|---|---|
Config.notificationSoundEnabled | true | Plays a short generated tone per notification. The pitch depends on the type. |
Config.position | "middle-right" | Default position when a call passes no valid position. |
Valid positions: top-right, top-left, top-middle, bottom-right,
bottom-left, bottom-middle, middle-left, middle-right. Any other value
falls back to Config.position.
Notification types
| Type | Icon |
|---|---|
success | check circle |
error | error |
info | info (also used for unknown types) |
warning | warning triangle |
Functions
ESX.ShowNotification
Client wrapper in es_extended. This is the call you use in almost every script.
ESX.ShowNotification(message, notifyType, length, title, position)| Name | Type | Description |
|---|---|---|
message | string | Text to show. Supports color codes and ~br~. |
notifyType | string? | success, error, info or warning. Default "info". |
length | number? | Duration in milliseconds. Default 5000. |
title | string? | Bold title above the message. Default "New Notification". |
position | string? | One of the positions above. Default Config.position. |
ESX.ShowNotification("You bought a ~g~water bottle~s~.", "success", 3000, "Shop")
ESX.ShowNotification("Inventory full!~br~Some items were dropped.", "warning", 4000, "Inventory", "bottom-left")xPlayer.showNotification
Server side, the xPlayer object has the same signature. It triggers the
client event esx:showNotification, which calls ESX.ShowNotification.
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
xPlayer.showNotification("Your paycheck has arrived.", "info", 5000, "Bank")
endNotify export
The raw export. Note the different argument order: type and length come first.
exports["esx_notify"]:Notify(notifyType, length, message, title, position)| Name | Type | Description |
|---|---|---|
notifyType | string | Notification type. Non-string values become "info". |
length | number | Duration in ms. Invalid values (negative, NaN, infinite, non-number) become 3000. |
message | any | Converted with tostring. ~br~ becomes a line break. |
title | string? | Optional title. |
position | string? | Optional position. |
exports["esx_notify"]:Notify("error", 4000, "You don't have enough money!", "Transaction failed")Events
| Event | Side | Arguments |
|---|---|---|
esx:showNotification | Client (net, registered by es_extended) | message, type, length, title, position |
ESX:Notify | Client (net, registered by esx_notify) | type, length, message, title, position |
Trigger them from the server when you have no xPlayer at hand:
TriggerClientEvent("esx:showNotification", playerId, "Server restart in 5 minutes", "warning", 10000, "Server")Formatting
The NUI escapes HTML, so you cannot inject markup. Two formatting helpers exist:
~br~(or a literal<br>) inserts a line break.- Color codes:
~r~red,~b~blue,~g~green,~y~yellow,~p~purple,~c~grey,~m~dark grey,~u~black,~o~orange.
~s~ does not reset the color
In 1.16.4 the NUI script removes every ~s~ before it applies colors. A color
code therefore colors the rest of the message, not just the next word. Put the
colored part at the end of the message, or split the information into title and
message.
Debug commands
When Config.EnableDebug is true in es_extended, esx_notify registers test
commands: /oldnotify, /notify, /notify1, /notify2, /notify3 and
/notify4. They are not available on a normal server.
Common issues
- Nothing shows up. Check that
esx_notifyis started afteres_extendedand that no other resource overridesESX.ShowNotification. - Wrong text in the title or a number as the message. You passed the
ESX.ShowNotificationargument order to the export, or the other way around. - Replacing esx_notify with another UI. Keep a resource named
esx_notifyor edites_extended/client/modules/ui/notifications.lua; es_extended only checks for this resource name.
Related
Frequently asked questions
Independent documentation
Last updated on
esx_multicharacter
esx_multicharacter gives ESX Legacy players multiple characters per account. Config, slot commands, database tables, events and fixes for common errors.
esx_progressbar
esx_progressbar reference for ESX Legacy. Show timed progress bars with animations, freeze, onFinish and onCancel via ESX.Progressbar or the export.