RoyaleWindRoyaleWind

Client

Client exports for registering interaction targets. They match ox_target's, so exports.rw_interact and exports.ox_target are the same functions.

All exports are client side. Everything a resource registers is removed automatically when that resource stops.

exports.rw_interact:addBoxZone(...) and exports.ox_target:addBoxZone(...) call the same function. Existing ox_target code needs no changes; new code can use either name.

See Options for what goes in options.

Zones

addSphereZone

local id = exports.rw_interact:addSphereZone({
	coords = vec3(441.8, -982.0, 30.7),
	radius = 1.0,
	name = 'mrpd_front_desk', -- optional, lets you remove it by name
	options = {
		{ label = 'Sign In', icon = 'clipboard-check', onSelect = function() TriggerEvent('police:signIn') end },
	},
})

Returns a zone id.

addBoxZone

local id = exports.rw_interact:addBoxZone({
	coords = vec3(441.8, -982.0, 30.7),
	size = vec3(2.0, 1.0, 2.0),
	rotation = 90.0,
	options = { ... },
})

addPolyZone

local id = exports.rw_interact:addPolyZone({
	points = { vec3(10.0, 10.0, 30.0), vec3(20.0, 10.0, 30.0), vec3(15.0, 20.0, 30.0) },
	thickness = 4.0,
	options = { ... },
})

removeZone / zoneExists

exports.rw_interact:removeZone(id)           -- or the zone's name
local exists = exports.rw_interact:zoneExists('mrpd_front_desk')

Entities

addEntity / removeEntity

Networked entities, by network id. They survive the entity leaving and re-entering scope.

exports.rw_interact:addEntity(NetworkGetNetworkIdFromEntity(vehicle), {
	{ name = 'impound', label = 'Impound', icon = 'truck', groups = 'police', onSelect = function(data)
		TriggerServerEvent('police:impound', NetworkGetNetworkIdFromEntity(data.entity))
	end },
})

exports.rw_interact:removeEntity(netId, 'impound') -- option name(s); nil removes all

addLocalEntity / removeLocalEntity

Local (non-networked) entities, by handle, e.g. a ped spawned with CreatePed(..., false).

exports.rw_interact:addLocalEntity(shopPed, {
	{ label = 'Browse', icon = 'shopping-bag', onSelect = openShop },
})

addModel / removeModel

Every entity of a model, by name or hash.

exports.rw_interact:addModel({ 'prop_atm_01', 'prop_atm_02', 'prop_atm_03' }, {
	{ label = 'Use ATM', icon = 'credit-card', iconColor = '#4ade80', onSelect = openAtm },
})

exports.rw_interact:removeModel('prop_atm_01', 'Use ATM')

Globals

Options on every entity of a type.

exports.rw_interact:addGlobalVehicle(options)
exports.rw_interact:addGlobalPed(options)     -- non-player peds
exports.rw_interact:addGlobalPlayer(options)  -- other players
exports.rw_interact:addGlobalObject(options)
exports.rw_interact:addGlobalOption(options)  -- peds, vehicles and objects

exports.rw_interact:removeGlobalVehicle({ 'option_name', ... })
-- removeGlobalPed, removeGlobalPlayer, removeGlobalObject, removeGlobalOption

Vehicle parts use bones; each part becomes its own marker on that part of the car:

exports.rw_interact:addGlobalVehicle({
	{ name = 'fuel', label = 'Refuel', icon = 'gas-station', bones = 'petrolcap', hold = 3000, onSelect = refuel },
})

State

exports.rw_interact:disableTargeting(true)  -- e.g. while handcuffed; false turns it back on
local open = exports.rw_interact:isActive() -- a menu is open

What a callback receives

onSelect, and the event / serverEvent / export targets, get one table: the option as you registered it, plus:

FieldType
entitynumberThe entity, or 0 for zones. For serverEvent it is the network id.
coordsvector3Where the marker was
distancenumberPed to target, in metres
zonenumber | string?Zone name, else its id
namestring?The option's name

On this page