NoneM
Tebex
  • Resources
    • no-base
      • Supported Resources
      • Configuration
        • Player
          • Controls
          • Actions
        • Inventory
        • Interact (Target)
        • Alerts
          • Notification
          • Indicators
    • no-alerts
      • Exports & Events
      • Notification Usage
      • Indicator Usage
    • no-chains
      • Configuration
      • Exports & Events
    • no-contextmenu
      • Exports
      • Contextmenu Usage
      • Input Menu Usage
    • no-elevators
      • Configuration
        • Elevator Creator
        • Scene Creator
        • Floor Creator
        • Door Selector
        • Icons
      • Restrictions
        • Elevator Restriction
        • Floor Restriction
    • no-gameplaycam
      • Configuration
      • Exports & Events
    • no-housing
      • Configuration
        • Buildings
          • Adding IPL Building
          • Adding Shell Building
          • Adding Building Interaction
        • Real Estate
        • Commands
        • Furniture Interactions
        • Garage
      • House Editor
        • Creating Houses
        • Editing & Removing Existing Houses
      • Furniture Editor
        • Editing Furnitures
        • Editing Furniture Categories
      • Access Sharing
      • Exports & Events
    • no-mop
      • Configuration
        • Client
        • How to disable pollution for interiors?
        • Use with commands
      • Exports & Events
    • no-newspaper
      • Configuration
        • Registering Papers
      • Exports & Events
    • no-payphone
      • Configuration
      • Integration
        • VOIP Integration
        • Phone Integration
    • no-polaroid
      • Configuration
      • Exports & Events
    • no-rappel
      • Configuration
      • Exports & Events
    • no-spy
      • Configuration
        • Client
        • Commands
      • Exports & Events
    • no-torture
      • Configuration
      • Exports & Events
    • no-trains
      • Configuration
      • Exports & Events
    • no-vehicles
      • Configuration
        • Anchor
        • Cruise
        • Indicator
        • Roll
        • Seat Belt
        • Siren Lights
        • Siren Sounds
      • Exports & Events
Powered by GitBook
On this page
  • Types
  • Entry
  • Distance
  • Options
  • Examples
  1. Resources
  2. no-base
  3. Configuration

Interact (Target)

PreviousInventoryNextAlerts

Last updated 1 year ago

If you're using you dont have to make any changes in this section.

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
}
AddEntryByModel

Adds interaction to passed models.

Parameters

  • models: number[]

AddEntryBySphereZone

Adds interaction for sphere zone.

Parameters

  • coords: vector3

  • radius: number

?

entries: []

options:

entries: []

options:

Entry
Options
Entry
Options
Distance
supported interact resource