FiveM Docs
es_extendedClient

Client UI

ESX Legacy client UI functions for notifications, help text, TextUI, progress bars, the context menu and ESX.UI.Menu, with parameters and examples.

The client UI functions show feedback to the player: GTA notifications and help text, the ESX notify, TextUI, progress bar and context menu resources, and the classic ESX.UI.Menu system used by older menu resources. All of them run on the client.

Overview

Resourcees_extended
SideClient
Sourceclient/modules/ui/*.lua
Optional dependenciesesx_notify, esx_textui, esx_progressbar, esx_context, menu resources

ESX.ShowNotification, ESX.TextUI, ESX.Progressbar and the context functions call exports of separate resources. If the resource was not present when es_extended started, the call raises Resource [name] is Missing!.

Notifications

ESX.ShowNotification

ESX.ShowNotification(message, notifyType, length, title, position)

Shows a notification through esx_notify.

NameTypeDescription
messagestringText. ~br~ becomes a line break.
notifyTypestring?info (default), success, error or warning.
lengthnumber?Duration in milliseconds. Default 5000.
titlestring?Title. esx_notify shows "New Notification" when empty.
positionstring?top-right, top-left, top-middle, bottom-right, bottom-left, bottom-middle, middle-left or middle-right. Falls back to the esx_notify config.

Returns: nothing

ESX.ShowNotification('Vehicle stored in the garage', 'success', 4000, 'Garage')

From the server, use xPlayer.showNotification(...) or trigger esx:showNotification with the same arguments.

ESX.ShowAdvancedNotification

ESX.ShowAdvancedNotification(sender, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndex)

Shows a native GTA feed notification with a picture, like a phone message.

NameTypeDescription
senderstringTitle line.
subjectstringSubtitle line.
msgstringMessage body.
textureDictstringTexture dictionary of the picture, for example CHAR_BANK_MAZE. Used as dictionary and texture name.
iconTypenumberSmall icon next to the title (1 chat, 2 email, 3 friend request, 7 arrow, 8 RP, 9 dollar).
flashbooleanPassed to the ticker native.
saveToBriefboolean?Store in the pause menu brief. Default true.
hudColorIndexnumber?Background HUD color.

Returns: nothing

ESX.ShowAdvancedNotification('Maze Bank', 'Transfer', 'You received $2,500', 'CHAR_BANK_MAZE', 9, false, true, 140)

ESX.ShowHelpNotification

ESX.ShowHelpNotification(msg, thisFrame, beep, duration)

Shows the black help box in the top left corner.

NameTypeDescription
msgstringText. Input tokens such as ~INPUT_CONTEXT~ work.
thisFrameboolean?Show only for the current frame. Call it every frame in a loop.
beepboolean?Play the beep sound. Default true. Ignored with thisFrame.
durationnumber?Duration in ms. Default -1 (until replaced). Ignored with thisFrame.

Returns: nothing

CreateThread(function()
    while isNearShop do
        ESX.ShowHelpNotification('Press ~INPUT_CONTEXT~ to open the shop', true)
        Wait(0)
    end
end)

ESX.ShowFloatingHelpNotification

ESX.ShowFloatingHelpNotification(msg, coords)

Shows a help bubble anchored at a world position. Call it every frame.

NameTypeDescription
msgstringText.
coordsvector3World position.

Returns: nothing

local shop = vector3(25.7, -1347.3, 29.5)

CreateThread(function()
    while true do
        local sleep = 500
        if #(GetEntityCoords(ESX.PlayerData.ped) - shop) < 3.0 then
            sleep = 0
            ESX.ShowFloatingHelpNotification('Shop', shop)
        end
        Wait(sleep)
    end
end)

ESX.DrawMissionText

ESX.DrawMissionText(msg, time)

Shows subtitle text at the bottom of the screen, like mission instructions.

NameTypeDescription
msgstringText.
timenumberDuration in milliseconds.

Returns: nothing

ESX.DrawMissionText('Deliver the package to ~y~Sandy Shores~s~', 6000)

ESX.UI.ShowInventoryItemNotification

ESX.UI.ShowInventoryItemNotification(add, item, count)

Shows the small "+1 Bread" / "-1 Bread" item popup of the built-in inventory UI. The server triggers it through the secure event esx:showInventoryItemNotification.

NameTypeDescription
addbooleantrue for added, false for removed.
itemstringLabel to display.
countnumberAmount.

Returns: nothing

TextUI

ESX.TextUI

ESX.TextUI(message, notifyType)

Shows a persistent text box through esx_textui until you hide it.

NameTypeDescription
messagestringText to show.
notifyTypestring?Style, default info.

Returns: nothing

ESX.HideUI

ESX.HideUI()

Hides the TextUI box.

local point = ESX.Point:new({
    coords = vector3(441.0, -981.0, 30.7),
    distance = 2.0,
    enter = function()
        ESX.TextUI(('[%s] Open armory'):format(ESX.GetInteractKey()))
    end,
    leave = function()
        ESX.HideUI()
    end,
})

Progress bar

ESX.Progressbar

ESX.Progressbar(message, length, options)

Starts a progress bar through esx_progressbar. Only one can run at a time.

NameTypeDescription
messagestringLabel.
lengthnumber?Duration in ms. Default 3000.
optionstable?See below.
OptionTypeDescription
FreezePlayerboolean?Freeze the ped while running.
animationtable?{ type = 'anim', dict = '...', lib = '...' } or { type = 'Scenario', Scenario = '...' }.
onFinishfunction?Called when the bar completes.
onCancelfunction?Called when the bar is cancelled.

Returns: boolean, false if another progress bar is running.

ESX.Progressbar('Repairing vehicle', 8000, {
    FreezePlayer = true,
    animation = { type = 'Scenario', Scenario = 'PROP_HUMAN_BUM_BIN' },
    onFinish = function()
        TriggerServerEvent('mechanic:repairDone')
    end,
    onCancel = function()
        ESX.ShowNotification('Repair cancelled', 'error')
    end,
})

ESX.CancelProgressbar

ESX.CancelProgressbar()

Cancels the running progress bar and calls its onCancel.

Context menu

These wrap the esx_context exports. ESX strips HTML tags from the title, description, label and inputPlaceholder fields of every element before it opens or refreshes the menu. Element format and callbacks are documented on esx_context.

ESX.OpenContext

ESX.OpenContext(position, elements, onSelect, onClose, canClose)
NameTypeDescription
positionstringleft, center or right.
elementstable[]Menu elements.
onSelectfunction?function(menu, element) when an element is selected.
onClosefunction?function(menu) when the menu closes.
canCloseboolean?Whether the player may close it with Escape. Default true.
ESX.OpenContext('right', {
    { unselectable = true, icon = 'fas fa-car', title = 'Garage' },
    { icon = 'fas fa-warehouse', title = 'Store vehicle', value = 'store' },
    { icon = 'fas fa-key', title = 'Take out vehicle', value = 'take' },
}, function(menu, element)
    if element.value == 'store' then
        StoreVehicle()
    end
    ESX.CloseContext()
end)

ESX.PreviewContext

ESX.PreviewContext(position, elements, onSelect, onClose, canClose)

Opens the context menu as a preview without taking NUI focus.

ESX.CloseContext

ESX.CloseContext()

Closes the open context menu.

ESX.RefreshContext

ESX.RefreshContext(elements, position)

Replaces the elements of the open context menu.

ESX.UI.Menu

ESX.UI.Menu is the classic menu API. Menu resources such as esx_menu_default, esx_menu_dialog and esx_menu_list register a type, and scripts open menus of that type.

ESX.UI.Menu.RegisterType

ESX.UI.Menu.RegisterType(menuType, open, close)
NameTypeDescription
menuTypestringType key, for example default or dialog.
openfunctionfunction(namespace, name, data) that renders the menu.
closefunctionfunction(namespace, name) that hides it.

Returns: nothing

ESX.UI.Menu.Open

ESX.UI.Menu.Open(menuType, namespace, name, data, submit, cancel, change, close)
NameTypeDescription
menuTypestringRegistered type.
namespacestringUsually GetCurrentResourceName(). Menus of a stopped resource are closed automatically.
namestringMenu name, unique within the namespace.
datatableMenu data, for example title, align, elements.
submitfunction?function(data, menu) when an element is selected.
cancelfunction?function(data, menu) when the player backs out.
changefunction?function(data, menu) when the selection or a value changes.
closefunction?Called after menu.close().

Returns: the menu object with type, namespace, resourceName, name, data and these methods:

MethodDescription
menu.close()Close this menu.
menu.update(query, newData)Merge newData into every element that matches all keys of query.
menu.refresh()Re-render with the current menu.data.
menu.setElement(i, key, val)Set one key on element i.
menu.setElements(elements)Replace all elements.
menu.setTitle(title)Change the title.
menu.removeElement(query)Remove the first element that matches a key of query.

After update, setElement, setElements, setTitle or removeElement, call menu.refresh() to show the change.

ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory', {
    title = 'Armory',
    align = 'top-left',
    elements = {
        { label = 'Pistol', value = 'WEAPON_PISTOL' },
        { label = 'Nightstick', value = 'WEAPON_NIGHTSTICK' },
    },
}, function(data, menu)
    TriggerServerEvent('police:takeWeapon', data.current.value)
    menu.close()
end, function(data, menu)
    menu.close()
end)

ESX.UI.Menu.Close

ESX.UI.Menu.Close(menuType, namespace, name, cancel)

Closes a specific menu. With cancel = true the menu's cancel callback runs instead of close.

ESX.UI.Menu.CloseAll

ESX.UI.Menu.CloseAll(cancel)

Closes every open menu. With cancel = true, each menu's cancel callback runs.

ESX.UI.Menu.GetOpened

ESX.UI.Menu.GetOpened(menuType, namespace, name)

Returns: the menu object, or nil if it is not open. ESX.UI.Menu.IsOpen is an alias, so it also returns the menu (truthy) or nil.

if ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'armory') then
    ESX.UI.Menu.Close('default', GetCurrentResourceName(), 'armory')
end

ESX.UI.Menu.GetOpenedMenus

ESX.UI.Menu.GetOpenedMenus()

Returns: the internal array of open menus (ESX.UI.Menu.Opened). Closed menus leave nil holes, so iterate with pairs.

Common issues

  • "Resource [esx_context] is Missing!": the helper resource is not installed or starts after es_extended. Fix the start order in server.cfg.
  • Menu does not open: no resource registered the menu type. Start the matching menu resource.
  • HTML in context titles disappears: ESX strips tags on purpose. Use plain text.

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.
Edit on GitHub

Last updated on

On this page