From the reference libraryRedM

autodoc_client_functions

jo_libs/modules/prompts/prompt-nui/autodoc/autodoc_client_functions.md

autodoc_client_functions

JO Functions > jo.promptNui.createGroup()

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

JO Functions > jo.promptNui.createGroup() > Syntax

jo.promptNui.createGroup(title, position)

JO Functions > jo.promptNui.createGroup() > Parameters

title : string|boolean

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

position : string <BadgeOptional />

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

JO Functions > jo.promptNui.createGroup() > Return Value

Type : GroupClass

A new instance of a prompt group.

JO Functions > jo.promptNui.createGroup() > Example

-- 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 Functions > jo.promptNui.isCompleted()

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

JO Functions > jo.promptNui.isCompleted() > Syntax

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

JO Functions > jo.promptNui.isCompleted() > 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 <BadgeOptional />

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

JO Functions > jo.promptNui.isCompleted() > Return Value

Type : boolean

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

JO Functions > jo.promptNui.isCompleted() > Example

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 Functions > jo.promptNui.isDisplayed() > Syntax

jo.promptNui.isDisplayed()

GroupClass Methods > GroupClass:addPrompt()

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

GroupClass Methods > GroupClass:addPrompt() > Syntax

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

GroupClass Methods > GroupClass:addPrompt() > 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. <br> Set it to false if no hold time is required

page : number <BadgeOptional />

The page number to add the prompt to<br> defaults to 1.

GroupClass Methods > GroupClass:addPrompt() > Return Value

Type : PromptClass

The newly created prompt object.

GroupClass Methods > GroupClass:addPrompt() > Example

-- 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 Methods > 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. <br>

GroupClass Methods > GroupClass:display() > Syntax

GroupClass:display(page)

GroupClass Methods > GroupClass:display() > Parameters

page : number <BadgeOptional />

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

GroupClass Methods > GroupClass:display() > Example

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


GroupClass Methods > GroupClass:forceDisplay() > Syntax

GroupClass:forceDisplay()

GroupClass Methods > GroupClass:forceDisplay() > Example

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


GroupClass Methods > GroupClass:forceHide() > Syntax

GroupClass:forceHide()

GroupClass Methods > GroupClass:forceHide() > Example

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


GroupClass Methods > GroupClass:hide()

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

GroupClass Methods > GroupClass:hide() > Syntax

GroupClass:hide()

GroupClass Methods > GroupClass:hide() > Example

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


GroupClass Methods > GroupClass:isVisible()

Returns whether the group is currently visible. <br>

GroupClass Methods > GroupClass:isVisible() > Syntax

GroupClass:isVisible()

GroupClass Methods > GroupClass:isVisible() > Return Value

Type : boolean

true if the group is visible, false otherwise

GroupClass Methods > GroupClass:isVisible() > Example

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


GroupClass Methods > GroupClass:new() > Syntax

GroupClass:new()

GroupClass Methods > 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. <br>

GroupClass Methods > GroupClass:refreshNUI() > Syntax

GroupClass:refreshNUI(property)

GroupClass Methods > GroupClass:refreshNUI() > Parameters

property : string

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

GroupClass Methods > GroupClass:refreshNUI() > Example

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 Methods > GroupClass:setNextPageKey()

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

GroupClass Methods > GroupClass:setNextPageKey() > Syntax

GroupClass:setNextPageKey(key)

GroupClass Methods > GroupClass:setNextPageKey() > Parameters

key : string

The key string to be used for pagination.

GroupClass Methods > GroupClass:setNextPageKey() > Example

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


GroupClass Methods > GroupClass:setPosition()

Sets the display position for the prompt group. <br>

GroupClass Methods > GroupClass:setPosition() > Syntax

GroupClass:setPosition(position)

GroupClass Methods > GroupClass:setPosition() > Parameters

position : string

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

GroupClass Methods > GroupClass:setPosition() > Example

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


GroupClass Methods > GroupClass:setTitle()

Sets the title for the prompt group. <br>

GroupClass Methods > GroupClass:setTitle() > Syntax

GroupClass:setTitle(title)

GroupClass Methods > GroupClass:setTitle() > Parameters

title : string

The title to assign to the group.

GroupClass Methods > GroupClass:setTitle() > Example

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() > Syntax

PromptClass:getLabel()

PromptClass Methods > PromptClass:getLabel() > Return Value

Type : string

The text label assigned to the prompt.


PromptClass Methods > PromptClass:isVisible()

Returns whether the prompt is currently visible. <br>

PromptClass Methods > PromptClass:isVisible() > Syntax

PromptClass:isVisible()

PromptClass Methods > PromptClass:isVisible() > Return Value

Type : boolean

true if the prompt is visible, false otherwise


PromptClass Methods > PromptClass:new() > Syntax

PromptClass:new()

PromptClass Methods > 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. <br>

PromptClass Methods > PromptClass:refreshNUI() > Syntax

PromptClass:refreshNUI(property)

PromptClass Methods > PromptClass:refreshNUI() > Parameters

property : string

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

PromptClass Methods > PromptClass:refreshNUI() > Example

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 Methods > PromptClass:setEnabled()

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

PromptClass Methods > PromptClass:setEnabled() > Syntax

PromptClass:setEnabled(enabled)

PromptClass Methods > PromptClass:setEnabled() > Parameters

enabled : boolean

true to enable the prompt, false to disable it.

PromptClass Methods > PromptClass:setEnabled() > Example

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


PromptClass Methods > PromptClass:setHoldTime()

Sets the key hold duration for the prompt. <br>

PromptClass Methods > PromptClass:setHoldTime() > Syntax

PromptClass:setHoldTime(holdTime)

PromptClass Methods > PromptClass:setHoldTime() > Parameters

holdTime : number|boolean

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

PromptClass Methods > PromptClass:setHoldTime() > Example

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


PromptClass Methods > 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. <br>

PromptClass Methods > PromptClass:setKeyboardKeys() > Syntax

PromptClass:setKeyboardKeys(keyboardKeys)

PromptClass Methods > PromptClass:setKeyboardKeys() > Parameters

keyboardKeys : table|string

A table of key strings or a single key string.

PromptClass Methods > PromptClass:setKeyboardKeys() > Example

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


PromptClass Methods > PromptClass:setLabel()

Sets the label text for the prompt. <br>

PromptClass Methods > PromptClass:setLabel() > Syntax

PromptClass:setLabel(label)

PromptClass Methods > PromptClass:setLabel() > Parameters

label : string

The text label to assign to the prompt.

PromptClass Methods > PromptClass:setLabel() > Example

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 Methods > PromptClass:setVisible()

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

PromptClass Methods > PromptClass:setVisible() > Syntax

PromptClass:setVisible(visible)

PromptClass Methods > PromptClass:setVisible() > Parameters

visible : boolean

true to show the prompt, false to hide it.

PromptClass Methods > PromptClass:setVisible() > Example

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

GroupClass Methods > GroupClass:addPrompt() > Syntax

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

GroupClass Methods > GroupClass:addPrompt() > 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. <br> Set it to false if no hold time is required

page : number <BadgeOptional />

The page number to add the prompt to<br> defaults to 1.

price : table|integer|number|boolean <BadgeOptional />

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

GroupClass Methods > GroupClass:addSeparator()

Adds a visual separator to the group on a specified page. <br>

GroupClass Methods > GroupClass:addSeparator() > Syntax

GroupClass:addSeparator(page)

GroupClass Methods > GroupClass:addSeparator() > Parameters

page : number <BadgeOptional />

The page number to add the separator to<br> defaults to 1.


PromptClass Methods > PromptClass:setPrice()

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

PromptClass Methods > PromptClass:setPrice() > Syntax

PromptClass:setPrice(price)

PromptClass Methods > PromptClass:setPrice() > Parameters

price : table|integer|number|boolean|nil

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


Back to documentation