Skip to content

Menu Client ​

The Jump On Menu is a NUI menu designed to blend with the menus of Red Dead Redemption II. It works with the keyboard and the mouse, and it's built to stay fast even with hundreds of items.

Every action is attached to an item (onClick, onActive, onChange...) instead of the whole menu, so a menu is just a list of tables. Lists, tile grids, sliders, color palettes, statistics and prices are all included.

Installation ​

  1. Add the jo_libs initiator as a shared script in your fxmanifest.lua:
lua
shared_scripts {
  '@jo_libs/init.lua'
}
  1. Add the menu module in the jo_libs list of your fxmanifest.lua:
lua
jo_libs {
  'menu',
}
  1. Set the jo_libs NUI page as the ui_page of your fxmanifest.lua:
lua
ui_page "nui://jo_libs/nui/index.html"

You can now use the menu with the jo.menu global variable, in your client scripts.

The ui_page is required

The menu can't be loaded without this ui_page.

You can still use your own NUI

nui://jo_libs/nui/index.html is only a container: it displays several NUI pages in the same resource, each one in its own frame. The menu loads itself in it, and you can load your own interface next to it with jo.nui.load instead of using ui_page.

lua
-- fxmanifest.lua
ui_page "nui://jo_libs/nui/index.html"

files {
  "html/**"
}

jo_libs {
  "menu",
  "nui",
}
lua
-- client.lua
-- Load your own page (it can be done once at the start of the resource)
jo.nui.load("my_ui", "nui://" .. GetCurrentResourceName() .. "/html/index.html")

-- Send a message only to your page
SendNUIMessage({
  messageTargetUiName = "my_ui",
  action = "open",
})

A message sent without messageTargetUiName is received by every loaded NUI.

Quick start ​

A menu is created with an ID, filled with items, then sent to the NUI. Once sent, you choose the menu to display and show it.

lua
local function openTailor()
  -- 1. Create the menu
  local menu = jo.menu.create("tailor", {
    title = "Tailor",
    subtitle = "Clothes",
    onBack = function()
      -- Backspace on the first menu: close the menu
      jo.menu.show(false)
    end,
  })

  -- 2. Add the items
  menu:addItem({
    title = "Hats",
    icon = "hats",
    child = "hats", -- opens the "hats" menu
  })
  menu:addItem({
    title = "Leave",
    onClick = function()
      jo.menu.show(false)
    end,
  })

  -- 3. Send the menu to the NUI
  menu:send()

  -- A second menu, opened by the "Hats" item
  local hats = jo.menu.create("hats", { title = "Tailor", subtitle = "Hats" })
  hats:addItem({
    title = "Stetson",
    icon = "hats",
    price = { money = 12.5 },
    onClick = function(currentData)
      print("Buy", currentData.item.title)
    end,
  })
  hats:send()

  -- 4. Choose the menu to display and show it
  jo.menu.setCurrentMenu("tailor")
  jo.menu.show(true)
end

RegisterCommand("tailor", openTailor)

Download the example resource

How it works ​

  • A menu is a table created with jo.menu.create() and identified by its ID. It holds the configuration (title, type, callbacks...) and the list of items.
  • An item is a line (or a tile) of the menu, added with MenuClass:addItem(). All its options are listed in Items.
  • The NUI only knows the menus you send with MenuClass:send(). After changing a menu, send the changes with MenuClass:push() or MenuClass:refresh(). See Update a menu.
  • The current menu is the one displayed by jo.menu.show(). Change it with jo.menu.setCurrentMenu(), or let the player navigate with the child key of the items.
  • The callbacks (onClick, onActive, onChange...) receive the current state of the menu: {menu = menuID, index = activeItemIndex, item = activeItem}. See Events.

Going further ​

PageContent
MenusMenu types, title, image, navigation, display, translations, controls
ItemsIcons, texts, colors, prices, tile options
SlidersDefault, switch, grid, palette, sprite and color sliders
StatisticsText, bars, icons, weapon bars and prices under the description
EventsCallbacks, order of the events, update a menu while it's open
FunctionsReference of all the functions and methods

Last updated: