RX Interact Exports

Scripts written for qb-target, ox_target, qb-menu, qb-input, qb-core DrawText, and ox_lib work through RX Interact without changes. The exports below are for writing new scripts against it directly.

All exports are client side. Whatever a resource adds is removed automatically when that resource stops. Icons are Font Awesome classes, such as 'fa-solid fa-hand'.

Interactions

Lua
local id = exports.rx_interact:add({
    coords = vector3(x, y, z),               -- or entity = someEntity
    offset = vector3(0.0, 0.0, 0.2),         -- optional, moves the prompt (world space)
    localOffset = vector3(0.4, -2.0, 0.8),   -- optional, in the entity's own space (turns with it)
    show = 8.0, use = 1.6,                   -- optional distances
    los = true,                              -- optional, hide behind walls
    options = {
        { label = 'Pick up', icon = 'fa-solid fa-hand',
          onSelect = function(entity, coords, id) end,
          canInteract = function(entity, coords) return true end },
        { label = 'Inspect', hold = false, onSelect = function() end },   -- hold = false: a simple press
    },
})

exports.rx_interact:update(id, { options = { ... } })
exports.rx_interact:remove(id)
FieldDescription
coords / entityWhere the prompt sits: a fixed position, or an entity it follows.
offsetMoves the prompt in world space.
localOffsetMoves the prompt in the entity’s own space, so it turns with the entity.
show, useDistances for this prompt. Default to Config.ShowDistance and Config.UseDistance.
losHide the prompt behind walls.
optionsOne or more actions. Each has a label, an optional icon, onSelect, an optional canInteract, and an optional hold (seconds, or false for a simple press).

Models

Adds the options to every object of these models near the player:

Lua
local modelId = exports.rx_interact:addModel({ 'prop_atm_01' }, { use = 1.5, options = { ... } })

Turning prompts off

Lua
exports.rx_interact:setDisabled(true)                   -- hide all prompts, e.g. while a UI is open
exports.rx_interact:ignoreVehicleDoors({ 'mymodel' })   -- no built-in door prompts on these vehicles

qb-target and ox_target names

The qb-target and ox_target exports work with the same names and arguments, either on rx_interact or on the original resource names:

Lua
exports.rx_interact:AddBoxZone(...)
exports['qb-target']:AddTargetModel(...)
exports.ox_target:addModel(...)

Key hints

Lua
local id = exports.rx_interact:showHint({
    { key = 'E', label = 'Open' },
    { key = 'LMB', label = 'Hold to heal', hold = 1.2, onSelect = function(id, row) end },
    { control = 47, label = 'Throw' },             -- shows whatever key the player has on that control
    { icon = 'fa-solid fa-gas-pump', label = 'Fuel: 40L' },
}, { position = 'bottom' })                        -- bottom / left / right / top

exports.rx_interact:updateHint(id, rows)
exports.rx_interact:hideHint(id)
exports.rx_interact:pressHint(id, 1)               -- flash a row's key
exports.rx_interact:hintProgress(id, 2, 0.5)       -- fill a row's key yourself
exports.rx_interact:isHintOpen(id)
Lua
exports.rx_interact:openMenu({
    id = 'shop', title = '24/7', subtitle = 'Grove Street',
    options = {
        { title = 'Water', description = 'Fresh and cold', icon = 'fa-solid fa-bottle-water', badge = '$5',
          onSelect = function(args) end },
        { title = 'Drinks', menu = 'shop_drinks' },      -- opens a sub menu
        { title = 'Staff', section = true },             -- a heading
    },
})

exports.rx_interact:registerMenu({ id = 'shop_drinks', title = 'Drinks', menu = 'shop', options = { ... } })
exports.rx_interact:showMenu('shop_drinks')
exports.rx_interact:closeMenu()
exports.rx_interact:getOpenMenu()

A registered menu with a menu field goes back to that menu.

Forms and confirm boxes

Lua
local values = exports.rx_interact:input('Deposit', {
    { type = 'number', label = 'Amount', name = 'amount', required = true, min = 1 },
    { type = 'select', label = 'Account', options = {
        { value = 'bank', label = 'Bank' },
        { value = 'cash', label = 'Cash' },
    } },
}, { submitText = 'Deposit' })

local ok = exports.rx_interact:confirm({ title = 'Buy house', content = 'Pay **$185,000**?', cancel = true })

exports.rx_interact:closeInput()
exports.rx_interact:isInputOpen()

input returns nil when the player cancels. Values can be read by position (values[1]) or by name (values.amount).

Field type
input, number, textareaText and numbers
sliderA value on a range
select, multi-selectOne or several choices
checkboxA toggle
date, date-range, timeDates and times
colorA colour picker

Notifications

Lua
exports.rx_interact:notify('Not enough money.', 'error')
exports.rx_interact:notify({ id = 'house', title = 'House bought', text = 'Press [E] for the keys', type = 'success' })
exports.rx_interact:hideNotify('house')
exports.rx_interact:clearNotify()

From the server:

Lua
TriggerClientEvent('rx_interact:notify', source, 'Money deposited', 'success')

Types are info, success, error, warning, police, and ambulance; their icons and colours are set in Config.Notify.Types. Keys written as [E] or ~INPUT_PICKUP~ are drawn as key caps.

Safe

Lua
if exports.rx_interact:safe({ code = '86-07-22', coords = vector3(x, y, z) }) then
    -- opened
end

exports.rx_interact:safe({ count = 4, max = 59, tries = 3 })   -- random code, cracked by ear
exports.rx_interact:closeSafe()
exports.rx_interact:isSafeOpen()
OptionDescription
codeThe combination. Without it, a random code of count numbers is used.
countNumbers in a random code. Defaults to Config.Safe.Count.
maxThe highest number on the dial. Defaults to Config.Safe.Max.
triesHow many wrong attempts the player gets. Without it, there is no limit.
coordsThe safe’s position. The player turns to face it, and the dial camera uses it.

safe returns true when opened, false when the player gave up or used up the tries, and nil when another minigame was already open.

The code is checked on the client. If there is a real reward inside, give it from the server after your own checks.

Starter cord

Lua
if exports.rx_interact:pull({ pulls = 3, coords = vector3(x, y, z) }) then
    -- it started
end

exports.rx_interact:closePull()
exports.rx_interact:isPullOpen()

pulls (1 to 12) defaults to Config.Pull.Pulls. pull returns true once the motor starts.