Skip to content

tw.menu

Side: Client

NUI interactive menu system. Cross-framework replacement for vorp_menu.

Functions

tw.menu.open(data, on_click, on_close)

Opens a menu with the given configuration.

ParameterTypeDescription
datatableMenu configuration (see below)
on_clickfunction(data, menu)Called when the player clicks an item
on_closefunction(nil, menu)Called when the player closes the menu

data structure:

FieldTypeDescription
titlestringMenu title
subtitlestring?Subtitle displayed below the title
itemstableArray of menu items

Item structure:

FieldTypeDescription
labelstringDisplay text
valueanyValue passed to the click callback
descstring?Description text
rightLabelstring?Right-aligned label (e.g., price)
disabledboolean?If true, the item is greyed out and not clickable
childtable?Nested menu data (same structure as data)

Callback on_click:

The data parameter contains:

FieldTypeDescription
data.currenttable{ value, label, desc } of the clicked item

The menu parameter is a handle with a :close() method.

Callback on_close:

Called when the menu is closed by the player (Escape). The first parameter is nil, the second is the menu handle.


tw.menu.close()

Closes the currently open menu.


tw.menu.isOpen()

Checks if a menu is currently open.

Returns: boolean

Examples

Basic menu with click handling

lua
tw.menu.open({
    title = "General Store",
    subtitle = "Valentine",
    items = {
        { label = "Bread", value = "bread", desc = "Fresh baked bread", rightLabel = "$1.50" },
        { label = "Coffee", value = "coffee", desc = "Hot black coffee", rightLabel = "$0.75" },
        { label = "Ammo", value = "ammo", rightLabel = "$5.00", disabled = true },
    }
}, function(data, menu)
    local item = data.current
    print("Selected: " .. item.label .. " (value: " .. tostring(item.value) .. ")")
    menu:close()
end, function(_, menu)
    print("Menu closed by player")
end)

Nested menus (child)

lua
tw.menu.open({
    title = "Crafting",
    items = {
        { label = "Weapons", value = "weapons", child = {
            title = "Weapons",
            items = {
                { label = "Knife", value = "knife", rightLabel = "2x Iron" },
                { label = "Bow", value = "bow", rightLabel = "3x Wood" },
            }
        }},
        { label = "Food", value = "food", child = {
            title = "Food",
            items = {
                { label = "Cooked Meat", value = "meat", rightLabel = "1x Raw Meat" },
            }
        }},
    }
}, function(data, menu)
    print("Craft: " .. data.current.value)
    menu:close()
end, function(_, menu)
    print("Closed")
end)

Notes

  • Only one menu can be open at a time. Opening a new menu replaces the current one.
  • The menu is a NUI overlay rendered in the browser layer.
  • Use menu:close() inside callbacks to close the menu after an action.

Premium RedM Scripts — Multi-Framework