Sleepless

Prompts

Prompt Options

Last updated on

Each call to show takes a group table. Each item in prompts is a PromptEntry.

Prompt group

PropertyTypeDefaultDescription
idstringrequiredGroup id. show('id', data) also sets this
positionstring | tableconfig.defaultPositionNamed slot or custom { x, y, origin? }
offset{ x, y }{ x = 0, y = 0 }Extra offset in rem
layout'row' | 'column' | 'auto'config.defaultLayoutArrangement of prompts in the group
separator'slash' | 'line' | 'dot' | 'none'config.separatorDivider between prompts
ordernumber0CSS order when multiple groups share a slot
persistOnPauseboolean?falseKeep this group visible while the pause menu is open
promptsPromptEntry | PromptEntry[]requiredOne prompt or an array
entitynumber?Default entity for prompt canInteract / distance
coordsvector3?Default world coords for prompt canInteract / distance

Prompt entry

A prompt needs a label and at least one of control, keybind, key, keyboard, gamepad, or icon. Prefer control or keybind. Icons are resolved from the live mapping, including player remaps. key / keyboard / gamepad are optional overrides.

PropertyTypeDescription
idstring?Unique id within the group. Defaults to control_N, the keybind name, or the key name
namestring?Alias for id
labelstringVisible label
controlnumber?GTA control index. Presses are tracked, hooks fire, and keyboard/gamepad icons follow the live mapping (including remaps)
disableControlboolean?Disable the GTA control while this prompt is shown, via lib.disableControls
keybindstring | table?ox_lib / FiveM keybind name, or the table from lib.addKeybind. Keyboard icon follows the live bind and updates on remap
keystring | string[]?Optional icon override (E, LMB, LT). Not needed when control or keybind is set
keyboardstring | string[]?Keyboard-only icon override
gamepadstring | string[]?Gamepad-only icon override (Xbox layout)
iconstring | string[]?Raw image path. Skips icon lookup
holdTimenumber?Hold duration in ms. Shows the localized hold string before the button, fills a progress bar, and fires onHold / held
cooldownnumber?Ignore further presses for this many ms after press or hold
disabledboolean?Dimmed, non-interactive
hiddenboolean?Omitted from the HUD
progressnumber?0 to 1 hold fill
onPressedfunction?Hook when control is pressed
onReleasedfunction?Hook when control is released
onHoldfunction?Hook when holdTime completes
onSelectfunction?Action when the prompt fires (press, or hold complete)
exportstring?Export on the registering resource
eventstring?Client event to trigger
serverEventstring?Server event to trigger
commandstring?Command to execute
groupsstring | string[] | table<string, number>?Job / gang / group filter. Same shape as Interact
itemsstring | string[] | table<string, number>?Required items. Hash values are minimum counts
anyItemboolean?If true, any listed item is enough. Default requires all
canInteractfun(entity, distance, coords, name): boolean?Same signature as Interact. Return false to hide
allowInVehicleboolean?Keep the prompt while in a vehicle. Default hides it
entitynumber?Entity passed into canInteract and used for distance
coordsvector3?World coords passed into canInteract and used for distance
distancenumber?Hide when farther than this from entity / coords
{
    id = 'engine',
    label = 'Engine',
    control = 23,
    holdTime = 1500,
}

Actions

One action runs when the prompt fires, in this order:

  1. onSelect
  2. export
  3. event
  4. serverEvent
  5. command

Press fires the action immediately. holdTime waits until the hold completes. onPressed / onHold / onReleased still run as hooks.

{
    id = 'lock',
    label = 'Lock',
    control = 182,
    event = 'myresource:lockVehicle',
}

{
    id = 'engine',
    label = 'Engine',
    control = 23,
    holdTime = 1500,
    serverEvent = 'myresource:toggleEngine',
}

{
    id = 'emote',
    label = 'Wave',
    control = 47,
    command = 'e wave',
}

The callback or event receives:

PropertyTypeDescription
idstringPrompt id
namestringSame as id
labelstringVisible label
groupIdstringGroup id
resourcestringResource that registered the prompt
entitynumber?Present when the group is tied to a target. Client handle, or a network id for serverEvent. 0 for a coord
coordsvector3?World point for that target
distancenumber?Meters from the player to coords
coordIdstring?Set for addCoords targets

export is called as exports[resource][export](nil, data) on the resource that registered the prompt.

Restrictions

Same filters as Interact. A prompt is hidden (and cannot fire) until every check passes. Filters re-run while the group is open.

{
    id = 'lockpick',
    label = 'Lockpick',
    control = 38,
    groups = { police = 0, mechanic = 2 },
    items = { lockpick = 1 },
    allowInVehicle = true,
    canInteract = function(entity, distance, coords, name)
        return distance < 2.0 and not IsPedDeadOrDying(cache.ped, true)
    end,
}
groupsMeaning
'police'Player has that job, gang, or group
{ 'police', 'ambulance' }Any of these names
{ police = 2, mechanic = 0 }That group at least this grade
itemsMeaning
'lockpick'At least one
{ 'lockpick', 'advancedlockpick' }All of these (or any if anyItem = true)
{ lockpick = 1, repairkit = 2 }At least these counts

Jobs and gangs come from the running framework (qbx, qb, esx, ox_core, ND). Item counts use wasabi_inventory when it is started, otherwise ox_inventory.

canInteract is called as canInteract(entity, distance, coords, name), same as Interact. Set entity or coords on the group or the prompt so distance is measured from the player to that point. If neither is set, entity is 0 and coords is the player.

World targets pass the entity or the coord in for you. See World targets.

Live remapping

Open prompts keep their icons in sync with the player's current binds.

SourcePropertyWhat updates
GTA controlcontrolKeyboard and gamepad icons via GetControlInstructionalButton. Remaps in Settings apply immediately
FiveM / ox_lib keybindkeybindKeyboard icon via the live RegisterKeyMapping bind. Remaps under Settings > Key Bindings > FiveM apply immediately

auto mode also swaps keyboard vs gamepad icons when the last input device changes. key / keyboard / gamepad override the live glyph when you set them.

{ id = 'enter', label = 'Enter', control = 38 }
{ id = 'use', label = 'Use', keybind = 'my_use' }

Positions

Named slots:

top-left, top-center, top-right, middle-left, center, middle-right, bottom-left, bottom-center, bottom-right.

Aliases: top, bottom, left, right, center-left, center-right, center-top, center-bottom.

Custom:

prompts.setPosition('vehicle', { x = 82, y = 18, origin = 'top-right' })

x and y are percents of the screen. origin is the transform origin (defaults to center).

Gamepad names

Names follow Xbox layout. PlayStation icons remap automatically.

NameXboxPlayStation
a / crossACross
b / circleBCircle
x / squareXSquare
y / triangleYTriangle
lt / l2LTL2
rt / r2RTR2
lb / l1LBL1
rb / r1RBR1
ls / rsLeft / right stickLeft / right stick
lsclick / l3LS clickL3
dpadup dpaddown dpadleft dpadrightD-padD-pad
start / optionsMenuOptions
back / shareViewShare

Keyboard names include letters, F1 to F12, Shift, Ctrl, Alt, Enter, Space, LMB, RMB, and similar aliases.

Arrays draw combo keys:

{ keyboard = { 'Ctrl', 'E' }, gamepad = 'A', label = 'Interact' }

On this page