FiveM Docs
Core Resources

esx_menu_dialog

esx_menu_dialog reference for ESX Legacy. Ask players for a text or number value with ESX.UI.Menu.Open('dialog'), data fields, callbacks and input rules.

esx_menu_dialog is the input box of ESX Legacy. It shows a title, one text field (or a larger text area) and Submit/Cancel buttons. Use it when you need a single value from the player, such as an amount of money, a plate or a short message. You open it with ESX.UI.Menu.Open('dialog', ...).

Overview

Resourceesx_menu_dialog
SideClient only
Menu typedialog
Dependencieses_extended, esx_lib (loaded via @esx_lib/imports.lua)
UIjQuery + Mustache page in html/

The resource has no configuration file. The dialog takes mouse and keyboard focus about 200 ms after opening and releases it when the last dialog closes.

The manifest only lists es_extended, but the client loads @esx_lib/imports.lua. Start esx_lib first.

Opening a dialog

ESX.UI.Menu.Open('dialog', namespace, name, data, submit, cancel, change, close)
NameTypeDescription
namespacestringUsually GetCurrentResourceName().
namestringUnique dialog name inside the namespace.
datatableDialog data, see below.
submitfunction(data, menu)?Submit button or Enter.
cancelfunction(data, menu)?Cancel button or Escape.
changefunction(data, menu)?Runs on every keystroke with the current text in data.value.
closefunction()?Runs after menu.close().

The returned menu object and the generic helpers (ESX.UI.Menu.Close, CloseAll, IsOpen) are documented on the esx_menu_default page.

Dialog data

FieldTypeDescription
titlestringText in the header. Escaped, so HTML is shown as text.
typestring?'default' (single-line input, default) or 'big' (multi-line text area).
valuestring?Prefilled value.

Callback data

FieldDescription
data.valueWhat the player typed. On submit it is always a string.
data.title, data.typeCopied from your dialog data.
data._namespace, data._nameMenu identifiers.

Input rules on submit

Before your submit callback runs, the resource processes the value:

  1. If the text parses as a number, it is rounded to the nearest integer.
  2. If that number is 0 or negative, the dialog shows the notification "That input is not allowed!" and does not call submit.
  3. The value is trimmed and converted to a string.

So " 12.6 " arrives as "13", "-5" and "0" never arrive, and text like "ABC 123" passes through trimmed.

Example

client/main.lua
local function askDepositAmount()
    ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'bank_deposit', {
        title = 'Deposit amount',
    }, function(data, menu)
        local amount = tonumber(data.value)

        if not amount then
            ESX.ShowNotification('Enter a valid number', 'error')
            return
        end

        menu.close()
        TriggerServerEvent('my_bank:deposit', amount)
    end, function(data, menu)
        menu.close()
    end)
end

A multi-line dialog with a prefilled value:

ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'edit_note', {
    title = 'Note',
    type = 'big',
    value = currentNote,
}, function(data, menu)
    menu.close()
    TriggerServerEvent('my_notes:save', data.value)
end, function(data, menu)
    menu.close()
end)

Validate on the server

The rounding and the positive-number check run on the client. A cheater can trigger your server event with any value, so check the amount again on the server.

Controls

KeyAction
EnterSubmit
EscapeCancel
MouseSubmit / Cancel buttons

Common issues

  • Comparing data.value to a number fails: it is a string. Use tonumber(data.value).
  • Players cannot enter 0: by design. If you need zero or negative values, read them in a change callback or use esx_context number inputs.
  • Dialog stays open after Submit: call menu.close() in submit and cancel.
  • Mouse cursor stays after closing: focus is only released when no dialog is left open. Make sure every dialog you open is closed, or call ESX.UI.Menu.CloseAll().

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