Client Exports
Last updated on
All client-side exports for showing and updating prompt groups. You can also import the global:
client_script '@sleepless_prompts/init.lua'Then call prompts.show(...) instead of exports.sleepless_prompts:show(...).
Prompt table shapes are documented on Prompt Options.
World targets (addCoords, addEntity, addModel, and the global adds) register prompts that show and hide by distance. show / hide still own prompts you turn on yourself.
show
Show or replace a prompt group. Returns the group id.
local id = exports.sleepless_prompts:show(id, data)
local id = exports.sleepless_prompts:show(data)Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | PromptGroupData | Group id, or a full group table that includes id |
data | PromptGroupData? | Group table when id is a string |
Returns
| Type | Description |
|---|---|
string | The group id |
Example
exports.sleepless_prompts:show('vehicle', {
position = 'bottom-center',
prompts = {
{ id = 'enter', label = 'Enter', control = 38 },
{ id = 'lock', label = 'Lock', control = 182 },
{ id = 'horn', label = 'Horn', control = 86 },
{ id = 'engine', label = 'Engine', control = 23, holdTime = 1500 },
},
})update
Patch an existing group. Omitted fields stay as they are. Passing prompts replaces the whole list.
exports.sleepless_prompts:update(id, data)Example
exports.sleepless_prompts:update('vehicle', {
position = 'middle-left',
layout = 'column',
})updatePrompt
Patch a single prompt inside a group.
exports.sleepless_prompts:updatePrompt(groupId, promptId, patch)Example
exports.sleepless_prompts:updatePrompt('vehicle', 'lock', {
label = 'Unlock',
disabled = false,
})addPrompt
Append a prompt to an open group. Returns the prompt id.
local promptId = exports.sleepless_prompts:addPrompt(groupId, entry)Example
exports.sleepless_prompts:addPrompt('vehicle', {
label = 'Horn',
control = 86,
})removePrompt
Remove a prompt from an open group.
exports.sleepless_prompts:removePrompt(groupId, promptId)setPosition
Move an open group.
exports.sleepless_prompts:setPosition(id, position, offset?)Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Group id |
position | string | table | Named slot or { x, y, origin? } |
offset | { x, y }? | Extra offset in rem |
Example
exports.sleepless_prompts:setPosition('vehicle', 'top-right')
exports.sleepless_prompts:setPosition('vehicle', { x = 82, y = 18, origin = 'top-right' })hide
Hide a group. Omit id to hide every group owned by the calling resource.
exports.sleepless_prompts:hide(id?)hideAll
Hide every group.
exports.sleepless_prompts:hideAll()isActive
true if the named group is open, or if any group is open when id is omitted.
local open = exports.sleepless_prompts:isActive(id?)get / getAll
local group = exports.sleepless_prompts:get(id)
local groups = exports.sleepless_prompts:getAll()setMode / getMode
Lock or auto-detect which icons to show. Player picks from /promptmode are saved in KVP and override this on the next start.
exports.sleepless_prompts:setMode('auto')
exports.sleepless_prompts:setMode('keyboard')
exports.sleepless_prompts:setMode('xbox')
exports.sleepless_prompts:setMode('playstation')
local mode = exports.sleepless_prompts:getMode()| Mode | Behavior |
|---|---|
auto | Follows last input device. Detects Xbox vs DualSense / DualShock |
keyboard | Always show keyboard / mouse icons |
xbox | Always show Xbox icons |
playstation | Always show DualSense icons |
setGamepad('auto' | 'xbox' | 'playstation') is an alias for setMode.
openModeMenu
Opens the ox_lib select dialog (same as /promptmode).
exports.sleepless_prompts:openModeMenu()getGamepad / getDevice
local family = exports.sleepless_prompts:getGamepad() -- 'xbox' | 'playstation'
local device = exports.sleepless_prompts:getDevice() -- 'keyboard' | 'gamepad'getGamepad never returns 'auto'. It is the resolved family after detection.
setStyle / getStyle
Change keyboard and gamepad art styles at runtime.
exports.sleepless_prompts:setStyle('dark')
exports.sleepless_prompts:setStyle('light')
exports.sleepless_prompts:setStyle('retro')
exports.sleepless_prompts:setStyle('white', 'alt2')
exports.sleepless_prompts:setStyle({ keyboard = 'vintage', gamepad = 'default' })
local keyboardStyle, gamepadStyle = exports.sleepless_prompts:getStyle()Keyboard: white, dark, alt, retro, vintage.
Gamepad: default, light, alt, alt2, retro.
One string applies to the device that owns that style. alt and retro apply to both.
getKeybindKey
Current keyboard key for an ox_lib / FiveM keybind name or the table from lib.addKeybind. Follows remaps under Settings > Key Bindings > FiveM.
local key = exports.sleepless_prompts:getKeybindKey('vehicle_enter')setScale / setTheme / setColor
exports.sleepless_prompts:setScale(1.1)
exports.sleepless_prompts:setTheme('cyber')
exports.sleepless_prompts:setTheme('modern', { 255, 64, 180, 255 })
exports.sleepless_prompts:setColor({ 232, 96, 48, 255 })
exports.sleepless_prompts:setColor(nil)setTheme takes a look id that matches web/themes/<id>.css. Built-in: modern, minimal, light, retro, cyber, vice, noir, industrial, fantasy.
The optional second argument, and setColor, set the HUD accent as { r, g, b, a } (0–255). setColor(nil) restores the current theme's color from config.themeColors.
See Custom Themes.
on
Subscribe to a prompt hook. Returns an unsubscribe function.
local remove = exports.sleepless_prompts:on('pressed', function(groupId, promptId, entry)
if groupId == 'vehicle' and promptId == 'enter' then
-- handle enter
end
end)| Event | Arguments |
|---|---|
shown | id, group |
hidden | id? |
updated | id, group |
deviceChanged | device, gamepad |
pressed | groupId, promptId, entry |
released | groupId, promptId, entry |
held | groupId, promptId, entry |
The same names are also fired as net-local events: sleepless_prompts:shown, sleepless_prompts:pressed, and so on.
Hold prompts fill while the control is held, then fire held / onHold.
World targets
Register a prompt on a point or an entity. It appears while the player is within distance and disappears when they leave. Distance is measured to the entity origin or the coord.
Each option is a prompt entry: label, plus control or keybind (or key / keyboard / gamepad / icon). name is how you remove or replace that prompt later. groups, items, anyItem, canInteract, and allowInVehicle use the same rules as a manual prompt.
distance defaults to config.defaultPromptDistance (2). An optional third argument sets the HUD slot and a default distance for that call:
{
position = 'bottom-center',
layout = 'row',
separator = 'slash',
offset = { x = 0, y = 0 },
order = 0,
distance = 2.5,
}Several targets can be on screen at once. Each one is its own group.
| Target | What shows |
|---|---|
| Coord | One group per point, while the player is in range of that point |
| Local entity or network id | That entity's prompts, plus model and global prompts when it is the closest match |
| Model | The closest entity of that model |
| Global ped, vehicle, object, or player | The closest entity of that type |
Model prompts and global prompts attach to that closest entity. Prompts registered on the entity itself are merged into the same group, specific ones first, then model, then global. A second car nearby does not get a second copy of a global vehicle prompt.
canInteract receives (entity, distance, coords, name). Coord targets pass entity as 0. The action payload adds entity, coords, distance, and coordId when the prompt is tied to a target. serverEvent sends a network id instead of the client handle, or 0 when the entity is local.
hide and hideAll clear the HUD. They do not unregister a world target, so a prompt in range comes back on the next check. remove* drops it. Stopping the resource that registered it drops it too.
addCoords
local id = exports.sleepless_prompts:addCoords(coords, options, settings?)Parameters
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | vector3[] | One point, an array of points, or { x, y, z } |
options | PromptEntry | PromptEntry[] | One prompt or an array |
settings | table? | Optional slot, layout, and default distance |
Returns
| Type | Description |
|---|---|
string | string[] | One coord id, or an array of ids when you passed several points |
The id is stable for the same point. A later addCoords on that point merges prompts. The same name from the same resource replaces the previous prompt.
Example
local id = exports.sleepless_prompts:addCoords(vec3(100.0, 200.0, 30.0), {
{
name = 'open_stash',
label = 'Open',
control = 38,
distance = 2.0,
onSelect = function(data)
print(data.coordId, data.distance)
end,
},
})
exports.sleepless_prompts:removeCoords(id, 'open_stash')
exports.sleepless_prompts:removeCoords(id)removeCoords
exports.sleepless_prompts:removeCoords(id, names?)Omit names to remove every prompt the calling resource added to that id. id can be the array returned by addCoords.
addLocalEntity
Prompts for one local entity, or a list of them. The handle must already exist.
exports.sleepless_prompts:addLocalEntity(entityId, {
{
name = 'talk',
label = 'Talk',
control = 38,
distance = 2.5,
onSelect = function(data)
print(data.entity)
end,
},
})exports.sleepless_prompts:removeLocalEntity(entityId, 'talk')
exports.sleepless_prompts:removeLocalEntity(entityId)addEntity
Prompts for a network id. The entity can stream in after the call.
local netId = NetworkGetNetworkIdFromEntity(entity)
exports.sleepless_prompts:addEntity(netId, {
name = 'trunk',
label = 'Trunk',
control = 47,
distance = 2.5,
})exports.sleepless_prompts:removeEntity(netId, 'trunk')
exports.sleepless_prompts:removeEntity(netId)addModel
Prompts for every entity of a model. While several are in range, the closest one shows the group.
exports.sleepless_prompts:addModel(`prop_atm_01`, {
name = 'atm',
label = 'Use ATM',
control = 38,
distance = 1.5,
})
exports.sleepless_prompts:addModel({ `prop_atm_01`, 'prop_atm_02' }, options)exports.sleepless_prompts:removeModel(`prop_atm_01`, 'atm')
exports.sleepless_prompts:removeModel(`prop_atm_01`)Model names and hashes both work.
addGlobalPed
Prompts for the closest ped. Player peds are skipped.
exports.sleepless_prompts:addGlobalPed({
name = 'talk',
label = 'Talk',
control = 38,
distance = 2.0,
})exports.sleepless_prompts:removeGlobalPed('talk')
exports.sleepless_prompts:removeGlobalPed()removeGlobalPed() with no names removes every global ped prompt the calling resource added. The vehicle, object, and player removes work the same way.
addGlobalVehicle
Prompts for the closest vehicle, including the one the player is in. Set allowInVehicle when the prompt should stay up while seated.
exports.sleepless_prompts:addGlobalVehicle({
{
name = 'lock',
label = 'Lock',
control = 182,
distance = 4.0,
allowInVehicle = true,
},
{
name = 'trunk',
label = 'Trunk',
control = 47,
distance = 2.5,
},
})exports.sleepless_prompts:removeGlobalVehicle('lock')
exports.sleepless_prompts:removeGlobalVehicle()addGlobalObject
Prompts for the closest object.
exports.sleepless_prompts:addGlobalObject({
name = 'pickup',
label = 'Pick up',
control = 38,
distance = 2.0,
})exports.sleepless_prompts:removeGlobalObject('pickup')addGlobalPlayer
Prompts for the closest other player.
exports.sleepless_prompts:addGlobalPlayer({
name = 'trade',
label = 'Trade',
control = 38,
distance = 2.0,
})exports.sleepless_prompts:removeGlobalPlayer('trade')