You can override interact actions from no-base/configure/client/interact.lua
Types
Entry
Field
Type
Description
id
string
Unique id for entry
label
string
Label for entry
icon
string?
Font awesome icon name
event
string
Client event to trigger
parameters
any?
Parameters to pass with event
Distance
Field
Type
Description
radius
number?
Distance between entity and player
Options
Field
Type
Description
distance
Distance data
isEnabled
function(entity: number)?
Function to check is entity interactable
Examples
This is an example of how we handle qb-target. Since we support qb-target internally you don't need to make any changes if you use qb-target.
Make sure to trigger the given event as in the example.
AddEventHandler("no-base:interact:qb", function(response)
TriggerEvent(response.data.event, response.data.parameters, response.entity)
end)
Config.Interact = {
AddEntryByModel = function(models, entries, options)
local function canInteract(entity)
return not options.isEnabled or options.isEnabled(entity)
end
local _entries = {}
for _, entry in pairs(entries) do
_entries[#_entries + 1] = {
icon = "fas fa-" .. entry.icon,
label = entry.label,
event = "no-base:interact:qb",
data = {event = entry.event, parameters = entry.parameters},
distance = options.distance?.radius,
bones = options.bone and {options.bone} or options.bones,
canInteract = canInteract
}
end
local resource = GetInvokingResource()
local handler
handler = AddEventHandler("onResourceStop", function(resName)
if resName ~= resource then return end
RemoveEventHandler(handler)
local labels = {}
for _, entry in pairs(_entries) do
labels[#labels + 1] = entry.label
end
exports["qb-target"]:RemoveTargetModel(models, labels)
end)
return exports["qb-target"]:AddTargetModel(models, {
options = _entries,
distance = options.distance?.radius
})
end,
AddEntryBySphereZone = function(coords, radius, entries, options)
local zoneId = entries[1] and entries[1].id
if not zoneId then return end
local function canInteract(entity)
return not options.isEnabled or options.isEnabled(entity)
end
local _entries = {}
for _, entry in pairs(entries) do
_entries[#_entries + 1] = {
icon = "fas fa-" .. entry.icon,
label = entry.label,
event = "no-base:interact:qb",
data = {event = entry.event, parameters = entry.parameters},
distance = options.distance?.radius,
bones = options.bone and {options.bone} or options.bones,
canInteract = canInteract
}
end
exports["qb-target"]:AddCircleZone(zoneId, coords, radius, {
name = zoneId,
useZ = true
}, {
options = _entries,
distance = options.distance?.radius
})
local resource = GetInvokingResource()
local handler
handler = AddEventHandler("onResourceStop", function(resName)
if resName ~= resource then return end
RemoveEventHandler(handler)
exports["qb-target"]:RemoveZone(zoneId)
end)
end
}