From the reference libraryRedM

autodoc_client_functions

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

autodoc_client_functions

JO Functions > jo.prompt.create() > Syntax

jo.prompt.create(group, str, key, holdTime, page)

JO Functions > jo.prompt.create() > Parameters

group : string

The name of the group. Use "interaction" to display the prompt without need to call jo.prompt.displayGroup every frame

str : string

The label of the key

key : string|table

Input (string or list of strings) <br> The input of the key

holdTime : integer <BadgeOptional />

Duration to complete the prompt in ms <br> Use false for classic prompt without holding timer <br> default: false

page : integer <BadgeOptional />

The page of the prompt <br> default: 0

JO Functions > jo.prompt.create() > Return Value

Type : integer

The prompt ID

JO Functions > jo.prompt.create() > Example

local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
local duration = 1000
jo.prompt.create(group, keyLabel, key, duration)


JO Functions > jo.prompt.delete() > Syntax

jo.prompt.delete(group, key, page)

JO Functions > jo.prompt.delete() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.delete() > Example

local group = "interaction"
local key = "INPUT_JUMP"
jo.prompt.deletePrompt(group, key)


JO Functions > jo.prompt.deleteAllGroups()

A function to delete all prompts created <br>

JO Functions > jo.prompt.deleteAllGroups() > Syntax

jo.prompt.deleteAllGroups()

JO Functions > jo.prompt.deleteAllGroups() > Example

local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
local duration = 1000
jo.prompt.create(group, keyLabel, key, duration)
jo.prompt.deleteAllGroups()
print(jo.prompt.isGroupExist('interaction'))
-- Expected output : false


JO Functions > jo.prompt.deleteGroup()

A function to delete a group and all its prompts. <br>

JO Functions > jo.prompt.deleteGroup() > Syntax

jo.prompt.deleteGroup(group)

JO Functions > jo.prompt.deleteGroup() > Parameters

group : string

The name of the group

JO Functions > jo.prompt.deleteGroup() > Example

local group = "shop"
jo.prompt.deleteGroup(group)


JO Functions > jo.prompt.displayGroup()

A function to display a prompt group during this frame. <br> Needs to be called each frame. <br>

JO Functions > jo.prompt.displayGroup() > Syntax

jo.prompt.displayGroup(group, title)

JO Functions > jo.prompt.displayGroup() > Parameters

group : string

The name of the prompt group to display this frame

title : string

The title to display for this prompt group

JO Functions > jo.prompt.displayGroup() > Example

CreateThread(function()
  local group = "shop"
  local title = "Stable shop"
  local keyLabel = "The key"
  local key = "INPUT_JUMP"
  jo.prompt.create(group, keyLabel, key)
  while true do
    jo.prompt.displayGroup(group, title)
    Wait(0)
  end
end)


JO Functions > jo.prompt.doesLastCompletedIs()

A function that returns if it's the last prompt completed. <br>

JO Functions > jo.prompt.doesLastCompletedIs() > Syntax

jo.prompt.doesLastCompletedIs(group, key, page)

JO Functions > jo.prompt.doesLastCompletedIs() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.doesLastCompletedIs() > Return Value

Type : boolean

Return true if key is the last input completed

JO Functions > jo.prompt.doesLastCompletedIs() > Example

local group = "shop"
local key = "INPUT_ENTER"
print(jo.prompt.doesLastCompletedIs(group, key))


JO Functions > jo.prompt.editKeyLabel()

A function to edit the label of a key. <br>

JO Functions > jo.prompt.editKeyLabel() > Syntax

jo.prompt.editKeyLabel(group, key, label, page)

JO Functions > jo.prompt.editKeyLabel() > Parameters

group : string

The name of the group

key : string

The input of the key

label : string

The label of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.editKeyLabel() > Example

local group = "shop"
local key = "INPUT_JUMP"
local label = "The new label"
jo.prompt.editKeyLabel(group, key, label)


JO Functions > jo.prompt.get() > Syntax

jo.prompt.get(group, key, page)

JO Functions > jo.prompt.get() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.get() > Return Value

Type : integer|boolean

The prompt ID or false

JO Functions > jo.prompt.get() > Example

local group = "shop"
local key = "INPUT_JUMP"
print(jo.prompt.get(group, key))


JO Functions > jo.prompt.getAll()

A function to get all registered prompts. <br>

JO Functions > jo.prompt.getAll() > Syntax

jo.prompt.getAll()

JO Functions > jo.prompt.getAll() > Return Value

Type : table

All prompt registered

JO Functions > jo.prompt.getAll() > Example

local groups = jo.prompt.getAll
log(groups)


JO Functions > jo.prompt.getGroup() > Syntax

jo.prompt.getGroup(group)

JO Functions > jo.prompt.getGroup() > Parameters

group : string

The name of the group

JO Functions > jo.prompt.getGroup() > Return Value

Type : integer|boolean

The group ID or false

JO Functions > jo.prompt.getGroup() > Example

local groupName = "MyGroup"
local group = jo.prompt.getGroup(groupName)
log(group)


JO Functions > jo.prompt.getKeyLabel() > Syntax

jo.prompt.getKeyLabel(group, key, page)

JO Functions > jo.prompt.getPage()

A function to get the current page ID for a group. <br>

JO Functions > jo.prompt.getPage() > Syntax

jo.prompt.getPage(group)

JO Functions > jo.prompt.getPage() > Parameters

group : string

The name of the group

JO Functions > jo.prompt.getPage() > Return Value

Type : integer

The page ID

JO Functions > jo.prompt.getPage() > Example

local groupName = "MyGroup"
local page = jo.prompt.getPage(groupName)
log(page)


JO Functions > jo.prompt.getProgress()

A function to return the progress of a prompt. <br>

JO Functions > jo.prompt.getProgress() > Syntax

jo.prompt.getProgress(group, key, page)

JO Functions > jo.prompt.getProgress() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.getProgress() > Return Value

Type : number

Return the percent of the prompt progress

JO Functions > jo.prompt.getProgress() > Example

local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
CreateThread(function()
  while true do
    print(jo.prompt.getProgress(group, key))
    Wait(0)
  end
end)


JO Functions > jo.prompt.isActive()

A function to know if a prompt is active or not. <br>

JO Functions > jo.prompt.isActive() > Syntax

jo.prompt.isActive(group, key, page)

JO Functions > jo.prompt.isActive() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.isActive() > Return Value

Type : boolean

Return true if the prompt is active

JO Functions > jo.prompt.isActive() > Example

local group = "interaction"
local keyLabel = "The key"
jo.prompt.isActive(group, key)
-- Expected output : false


JO Functions > jo.prompt.isCompleted()

A function to test if the prompt is pressed and completed. <br>

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

jo.prompt.isCompleted(group, key, fireMultipleTimes, page)

JO Functions > jo.prompt.isCompleted() > Parameters

group : string

The name of the group

key : string

The input of the key

fireMultipleTimes : boolean <BadgeOptional />

Fire true if the prompt is completed and until another prompt is completed <br> default: false

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

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

Type : boolean

Return true if the key is pressed and completed

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

CreateThread(function()
  local group = "interaction"
  local keyLabel = "The key"
  local key = "INPUT_JUMP"
  local duration = 1000
  jo.prompt.create(group, keyLabel, key, duration)
  while true do
    if jo.prompt.isCompleted(group, key) then
      print('Key completed !')
    end
    jo.prompt.displayGroup(group, title)
    Wait(0)
  end
end)


JO Functions > jo.prompt.isEnabled()

A function to know if the prompt is enabled. <br>

JO Functions > jo.prompt.isEnabled() > Syntax

jo.prompt.isEnabled(group, key, page)

JO Functions > jo.prompt.isEnabled() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.isEnabled() > Return Value

Type : boolean

Return true if the prompt is enabled

JO Functions > jo.prompt.isEnabled() > Example

local group = "interaction"
local keyLabel = "The key"
jo.prompt.isEnabled(group, key)
-- Expected output : false


JO Functions > jo.prompt.isExist()

A function to know if a prompt exists. <br>

JO Functions > jo.prompt.isExist() > Syntax

jo.prompt.isExist(group, key, page)

JO Functions > jo.prompt.isExist() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.isExist() > Return Value

Type : boolean

Return true if the prompt exists

JO Functions > jo.prompt.isExist() > Example

local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
print(jo.prompt.isPromptExist('interaction', 'INPUT_JUMP'))
-- Expected output : true
print(jo.prompt.isGroupExist('new_group', 'INPUT_RELOAD'))
-- Expected output : false


JO Functions > jo.prompt.isGroupExist()

A function to know if a prompt group exists. <br>

JO Functions > jo.prompt.isGroupExist() > Syntax

jo.prompt.isGroupExist(group)

JO Functions > jo.prompt.isGroupExist() > Parameters

group : string

The name of the group

JO Functions > jo.prompt.isGroupExist() > Return Value

Type : boolean

Return true if the group exists

JO Functions > jo.prompt.isGroupExist() > Example

local group = "interaction"
local keyLabel = "The key"
local key = "INPUT_JUMP"
jo.prompt.create(group, keyLabel, key)
print(jo.prompt.isGroupExist('interaction'))
-- Expected output : true
print(jo.prompt.isGroupExist('new_group'))
-- Expected output : false


JO Functions > jo.prompt.isPressed()

A function to know if a key is pressed. <br>

JO Functions > jo.prompt.isPressed() > Syntax

jo.prompt.isPressed(key)

JO Functions > jo.prompt.isPressed() > Parameters

key : string

The input of the key

JO Functions > jo.prompt.isPressed() > Return Value

Type : boolean

Return true if the key is pressed

JO Functions > jo.prompt.isPressed() > Example

local key = "INPUT_FRONTEND_ACCEPT"
print(jo.prompt.isPressed(key))


JO Functions > jo.prompt.isVisible()

A function to check if a prompt is visible. <br>

JO Functions > jo.prompt.isVisible() > Syntax

jo.prompt.isVisible(group, key, page)

JO Functions > jo.prompt.isVisible() > Parameters

group : string

The name of the group

key : string

The input of the key

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.isVisible() > Return Value

Type : boolean

Return true if the prompt is visible

JO Functions > jo.prompt.isVisible() > Example

local group = "shop"
local key = "INPUT_JUMP"
local isVisible = jo.prompt.isVisible(group, key)
log(isVisible)


JO Functions > jo.prompt.setEnabled()

A function to define if the prompt is enabled or not. <br>

JO Functions > jo.prompt.setEnabled() > Syntax

jo.prompt.setEnabled(group, key, value, page)

JO Functions > jo.prompt.setEnabled() > Parameters

group : string

The name of the group

key : string

The input of the key

value : boolean

If the prompt is enabled or not

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.setEnabled() > Example

local group = "shop"
local key = "INPUT_JUMP"
jo.prompt.setEnabled(group, key, false)


JO Functions > jo.prompt.setGroups()

A function to overwrite the prompt groups value. <br>

JO Functions > jo.prompt.setGroups() > Syntax

jo.prompt.setGroups(groups)

JO Functions > jo.prompt.setGroups() > Parameters

groups : table

The prompt group value from other script get with jo.prompt.getAll()

JO Functions > jo.prompt.setGroups() > Example

local groups = exports.resourceName:getPrompt()
jo.prompt.setGroups(groups)


JO Functions > jo.prompt.setVisible() > Syntax

jo.prompt.setVisible(group, key, value, page)

JO Functions > jo.prompt.setVisible() > Parameters

group : string

The name of the group

key : string

The input of the key

value : boolean

If the prompt is visible or not

page : integer <BadgeOptional />

The page of the prompt <br> default: current page

JO Functions > jo.prompt.setVisible() > Example

local group = "shop"
local key = "INPUT_JUMP"
local isVisible = false
jo.prompt.setVisible(group, key, isVisible)


JO Functions > jo.prompt.waitRelease()

A function to wait for the release of pressed key. <br>

JO Functions > jo.prompt.waitRelease() > Syntax

jo.prompt.waitRelease(key)

JO Functions > jo.prompt.waitRelease() > Parameters

key : string

The input of the key

JO Functions > jo.prompt.waitRelease() > Example

CreateThread(function()
  local group = "interaction"
  local keyLabel = "The key"
  local key = "INPUT_JUMP"
  local duration = 1000
  jo.prompt.create(group, keyLabel, key, duration)
  while true do
    if jo.prompt.isCompleted(group, key) then
      print('Key completed !')
      jo.prompt.waitRelease(key)
      print('Key released !')
    end
    jo.prompt.displayGroup(group, title)
    Wait(0)
  end
end)

Back to documentation