Skip to main content
If you’re using supported interact resource you dont have to make any changes in this section.
You can override interact actions from no-base/configure/client/interact.lua

Types


Entry

FieldTypeDescription
idstringUnique id for entry
labelstringLabel for entry
iconstring?Font awesome icon name
eventstringClient event to trigger
parametersany?Parameters to pass with event

Distance

FieldTypeDescription
radiusnumber?Distance between entity and player

Options

FieldTypeDescription
distanceDistance?Distance data
isEnabledfunction(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
}
Adds interaction to passed models.

Parameters

Adds interaction for sphere zone.

Parameters

  • coords: vector3
  • radius: number
  • entries: Entry[]
  • options: Options