RX Interact Exports (RedM)

Scripts written for ox_target, rsg-target, murphy_interact, rsg-core DrawText and Notify, and ox_lib work through RX Interact without changes. The exports below are for writing new scripts against it directly. They are the same as on FiveM.

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({ 'p_waterpump01x' }, { use = 1.5, options = { ... } })

Turning prompts off

Lua
exports.rx_interact:setDisabled(true)   -- hide all prompts, e.g. while a UI is open

ox_target and rsg-target names

The ox_target and rsg-target exports work with the same names and arguments:

Lua
exports.ox_target:addModel(...)
exports['rsg-target']:AddBoxZone(...)

Key hints

Lua
local id = exports.rx_interact:showHint({
    { key = 'E', label = 'Open' },
    { key = 'LMB', label = 'Hold to drink', hold = 1.2, onSelect = function(id, row) end },
    { control = 0x760A9C6F, label = 'Equip' },     -- an RDR control hash, or a key's name: control = 'G'
    { icon = 'fa-solid fa-droplet', label = 'Canteen: 3/5' },
}, { 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 = 'store', title = 'General Store', subtitle = 'Valentine',
    options = {
        { title = 'Coffee', description = 'Hot and black', icon = 'fa-solid fa-mug-hot', badge = '$0.40',
          onSelect = function(args) end },
        { title = 'Provisions', menu = 'store_food' },   -- opens a sub menu
        { title = 'Staff', section = true },             -- a heading
    },
})

exports.rx_interact:registerMenu({ id = 'store_food', title = 'Provisions', menu = 'store', options = { ... } })
exports.rx_interact:showMenu('store_food')
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**?', 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 (the law), and ambulance (the doctor); their icons and colours are set in Config.Notify.Types. Keys written as [E] are drawn as key caps.

Skill check

Lua
if exports.rx_interact:skill({ rounds = 3, coords = vector3(x, y, z) }) then
    -- all hit
end

exports.rx_interact:skill({ rounds = 4, misses = 0, speed = 1.3, zone = 0.8 })   -- harder
exports.rx_interact:closeSkill()
exports.rx_interact:isSkillOpen()

rounds, misses, speed, and zone default to Config.Skill. The player presses with the interact key, Enter, or Space, and gives up with Esc or Backspace. skill returns true when every round hit, false on too many misses or giving up, and nil when another minigame was already open.

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 skill check and the safe run on the client. If there is a real reward, give it from the server after your own checks.

Pump

A water pump, a well, or a bellows, worked a few strokes until it gives.

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

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

pulls defaults to Config.Pull.Pulls. The player’s animation is Config.Pull.Anim.