Skip to content

Prompt Nui Client ​

A library to manage NUI-based prompts. This module allows you to create and manage prompt groups with customizable prompts, key bindings, key hold durations, pagination, and visibility controls.

TIP

  • Keyboard Keys Mapping: You can find the complete list of valid key inputs, including special and function keys, in the Keyboard keys mapping section of the Raw Keys module.
  • Keyboard Layouts: To learn more about switching between QWERTY and AZERTY layouts, see the Setting Keyboard Layout section of the Raw Keys module.

JO Functions ​

jo.promptNui.createGroup() ​

Creates a new prompt group with a specified title and optional position.

Syntax ​

lua
jo.promptNui.createGroup(title, position)

Parameters ​

title : string|boolean

The title for the new prompt group. Set to false to have no title

position : string Optional

The screen position for the group.
Allowed values are : "bottom-right","center-right","top-right","bottom-left","center-left","top-left"
default : "bottom-right"

Return Value ​

Type : GroupClass

A new instance of a prompt group.

Example ​

lua
-- Example 1: Create a group with a standard title and a specified position
local group1 = jo.promptNui.createGroup("Main Menu", "top-left")

-- Example 2: Create a group with an icon in the title using HTML tags
local group2 = jo.promptNui.createGroup("<img src='icon.png'> Options", "center-right")

-- Example 3: Create a group without a title by passing nil
local group3 = jo.promptNui.createGroup(nil)

-- Example 4: Create a group with a false title (no title) and a custom position
local group4 = jo.promptNui.createGroup(false, "top-right")

-- Example 5: Create a group with a red title
local group4 = jo.promptNui.createGroup("<span style='color:red'>My Red Menu</span>")

jo.promptNui.isCompleted() ​

Checks whether a specified key has been held for the required duration to trigger an action.
Optionally ensures that the key does not trigger repeatedly unless explicitly allowed.

Syntax ​

lua
jo.promptNui.isCompleted(group, key, fireMultipleTimes)

Parameters ​

group : GroupClass|string

The prompt group to validate against. Retrocompatible: can be the key string.

key : string|boolean|nil

The key identifier to check. Retrocompatible: can be fireMultipleTimes.

fireMultipleTimes : boolean|nil Optional

If true, allows the key to trigger multiple times
defaults to false.

Return Value ​

Type : boolean

True if the key press is complete and valid, otherwise false.

Example ​

lua
CreateThread(function()
  while true do
    if jo.promptNui.isCompleted("A", true) then
      print("G IS COMPLETED")
    end

    if jo.promptNui.isCompleted("K") then
      print("K IS COMPLETED")
    end
    Wait(0)
  end
end)

jo.promptNui.isDisplayed() ​

Syntax ​

lua
jo.promptNui.isDisplayed()

GroupClass Methods ​

GroupClass:addPrompt() ​

Adds a new prompt to the group on a specified page.
Creates or initializes pages as necessary, assigns the prompt's position, and returns the new prompt.

Syntax ​

lua
GroupClass:addPrompt(key, label, holdTime, page, price)

Parameters ​

key : string

A key string for the prompt.

label : string

The descriptive label for the prompt.

holdTime : number|boolean

Duration to hold the key before the prompt triggers.
Set it to false if no hold time is required

page : number Optional

The page number to add the prompt to
defaults to 1.

price : table|integer|number|boolean Optional

The price to display next to the prompt label. Uses the shared pricing structure
defaults to false.

Return Value ​

Type : PromptClass

The newly created prompt object.

Example ​

lua
-- Example 1: Add a prompt using a single key with a hold time, defaults to page 1.
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt1 = group:addPrompt("E", "Interact")

-- Example 2: Add a prompt using a table of keys and specifying page 2.
local prompt2 = group:addPrompt({ "W", "A" }, "Move", false, 2)

-- Example 3: Add a prompt with no hold time (using false) on the default page.
local prompt3 = group:addPrompt("Q", "Quick Action", false)

-- Example 4: Add multiple prompts with different configurations.
local prompt4 = group:addPrompt("F", "Fire", 1000)
local prompt5 = group:addPrompt({ "R", "T" }, "Reload", 750, 1)

-- Example 5: Add a prompt with a red title
local prompt6 = group:addPrompt("O", "<span style='color:red'>Set on Fire</span>")

GroupClass:addSeparator() ​

Adds a visual separator to the group on a specified page.

Syntax ​

lua
GroupClass:addSeparator(page)

Parameters ​

page : number Optional

The page number to add the separator to
defaults to 1.


GroupClass:display() ​

Displays the prompt group on the NUI interface and sets up key listeners for the active page. If the group has multiple pages, it also configures pagination using the nextPageKey.

Syntax ​

lua
GroupClass:display(page)

Parameters ​

page : number Optional

The page number to display
defaults to the group's current page.

Example ​

lua
local group = jo.promptNui.createGroup()
group:display()

GroupClass:forceDisplay() ​

Syntax ​

lua
GroupClass:forceDisplay()

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
group:forceDisplay()

GroupClass:forceHide() ​

Syntax ​

lua
GroupClass:forceHide()

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
group:forceHide()

GroupClass:hide() ​

Hides the prompt group from the NUI interface and removes its active key listeners.

Syntax ​

lua
GroupClass:hide()

Example ​

lua
local group = jo.promptNui.createGroup()
group:hide()

GroupClass:isVisible() ​

Returns whether the group is currently visible.

Syntax ​

lua
GroupClass:isVisible()

Return Value ​

Type : boolean

true if the group is visible, false otherwise

Example ​

lua
local group = jo.promptNui.createGroup()
group:display()
print(group:isVisible()) -- return true
group:hide()
print(group:isVisible()) -- return false

GroupClass:new() ​

Syntax ​

lua
GroupClass:new()

GroupClass:refreshNUI() ​

Refreshes the NUI interface for the group by updating a specified property. This update is only sent if the group is currently visible.

Syntax ​

lua
GroupClass:refreshNUI(property)

Parameters ​

property : string

The group property to update (e.g., "title", "position",..).

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
group:display() -- Make sure the group is visible before refreshing the NUI

-- Example 1: Update the title property directly via refreshNUI
group.title = "Updated Menu"
group:refreshNUI("title")

-- Example 2: Update the position property directly via refreshNUI
group.position = "top-right"
group:refreshNUI("position")

-- Note: Typically you would use setTitle() and setPosition() methods
-- which call refreshNUI internally, but this shows direct usage

GroupClass:setNextPageKey() ​

Sets the key used for navigating to the next page of prompts.

Syntax ​

lua
GroupClass:setNextPageKey(key)

Parameters ​

key : string

The key string to be used for pagination.

Example ​

lua
local group = jo.promptNui.createGroup()
group:setNextPageKey("N")

GroupClass:setPosition() ​

Sets the display position for the prompt group.

Syntax ​

lua
GroupClass:setPosition(position)

Parameters ​

position : string

The screen position for the group.
Allowed values are : "bottom-right","center-right","top-right","bottom-left","center-left","top-left"

Example ​

lua
local group = jo.promptNui.createGroup()
group:setPosition("top-left")

GroupClass:setSuppressNativePrompts() ​

Configures which native RedM prompt types are suppressed while this group is displayed.
Call without an argument or with true to suppress the default types 1 through 12.
Pass false or an empty table to suppress none, or an integer array to suppress only those types.

Syntax ​

lua
GroupClass:setSuppressNativePrompts(value)

Parameters ​

value : boolean|integer[] Optional


GroupClass:setTitle() ​

Sets the title for the prompt group.

Syntax ​

lua
GroupClass:setTitle(title)

Parameters ​

title : string

The title to assign to the group.

Example ​

lua
local group = jo.promptNui.createGroup()

-- Example 1: Set a normal title
group:setTitle("Options")

-- Example 2: Clear the title by passing false
group:setTitle(false)

-- Example 3: Set a title with an icon using HTML tags
group:setTitle("<img src='icon.png'> Options")

PromptClass Methods ​

PromptClass:getLabel() ​

Get the label text for the prompt.

Syntax ​

lua
PromptClass:getLabel()

Return Value ​

Type : string

The text label assigned to the prompt.


PromptClass:isVisible() ​

Returns whether the prompt is currently visible.

Syntax ​

lua
PromptClass:isVisible()

Return Value ​

Type : boolean

true if the prompt is visible, false otherwise


PromptClass:new() ​

Syntax ​

lua
PromptClass:new()

PromptClass:refreshNUI() ​

Refreshes the NUI interface for a prompt, updating a specific property. This update is only performed if the prompt belongs to the currently visible group.

Syntax ​

lua
PromptClass:refreshNUI(property)

Parameters ​

property : string

The property name to update (e.g., "label", "disabled").

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt = group:addPrompt("E", "Interact")
group:display() -- Make sure the group is visible

-- Example 1: Update the label property directly via refreshNUI
prompt.label = "Press E to use"
prompt:refreshNUI("label")

-- Example 2: Update the disabled property directly via refreshNUI
prompt.disabled = true
prompt:refreshNUI("disabled")

-- Example 3: Update the visibility property directly via refreshNUI
prompt.visible = false
prompt:refreshNUI("visible")

-- Note: Typically you would use setLabel(), setEnabled(), setVisible() methods
-- which call refreshNUI internally, but this shows direct usage

PromptClass:setEnabled() ​

Enables or disables the prompt and updates its associated key listeners.

Syntax ​

lua
PromptClass:setEnabled(enabled)

Parameters ​

enabled : boolean

true to enable the prompt, false to disable it.

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt = group:addPrompt("E", "Interact")
prompt:setEnabled(false)

PromptClass:setHoldTime() ​

Sets the key hold duration for the prompt.

Syntax ​

lua
PromptClass:setHoldTime(holdTime)

Parameters ​

holdTime : number|boolean

Duration (in milliseconds) the key must be held before activation; false if not applicable.

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt = group:addPrompt("E", "Interact")
prompt:setHoldTime(500)

PromptClass:setKeyboardKeys() ​

Configures the keyboard keys for the prompt. Ensures that the keys are stored in a table, converting a single key to uppercase if needed.

Syntax ​

lua
PromptClass:setKeyboardKeys(keyboardKeys)

Parameters ​

keyboardKeys : table|string

A table of key strings or a single key string.

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt = group:addPrompt("E", "Interact")
prompt:setKeyboardKeys("A")
-- OR --
prompt:setKeyboardKeys({ "E", "F" })

PromptClass:setLabel() ​

Sets the label text for the prompt.

Syntax ​

lua
PromptClass:setLabel(label)

Parameters ​

label : string

The text label to assign to the prompt.

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt = group:addPrompt("E", "Interact")
prompt:setLabel("Press E to interact")
-- OR --
prompt:setLabel("Press E to <span style='color:red'>interact</span>")

PromptClass:setPrice() ​

Sets the prompt price and formats it with the shared pricing structure.

Syntax ​

lua
PromptClass:setPrice(price)

Parameters ​

price : table|integer|number|boolean|nil

The prompt price. Set it to false if no price is required


PromptClass:setVisible() ​

Sets the visibility of the prompt and updates its enabled state accordingly.

Syntax ​

lua
PromptClass:setVisible(visible)

Parameters ​

visible : boolean

true to show the prompt, false to hide it.

Example ​

lua
local group = jo.promptNui.createGroup("Main Menu", "bottom-right")
local prompt = group:addPrompt("E", "Interact")
prompt:setVisible(false)

Last updated: