AddEntity

AddEntity

This export does the equivalent of AddTargetEntity

Arguments

Argument
Description

identifier

The unique string identifier of this target, in-case you want to remove it later

entities

A single, or table of, entities that the target should be for

options

The options for the target (see Options Formatting)

Usage

exports['nyx2_target']:AddEntity(identifier, entities, options)

Example

local boxCoords = vector3(-74.41, -823.88, 326.18)
local boxModel = GetHashKey('prop_boxpile_07d')

RequestModel(boxModel)
while not HasModelLoaded(boxModel) do
    Wait(0)
end

local box = CreateObject(boxModel, boxCoords.x, boxCoords.y, boxCoords.z - 1.0, false, false, false)
SetEntityAsMissionEntity(box, true, true)
SetEntityAlpha(box, 255, false)
SetModelAsNoLongerNeeded(boxModel)

exports['nyx2_target']:AddEntity('debug_box_entity', box, {
    {
        title = 'Debug Box Entity',
        icon = 'fas fa-box',
        action = function(zone)
            local QBCore = exports['qb-core']:GetCoreObject()
            QBCore.Functions.Notify('This is a box!', 'success')
        end,
        canInteract = function(zone)
            return true
        end,
        job = nil, -- if nil, all jobs can interact
        gang = nil, -- if nil, all gangs can interact
        citizenid = nil, -- if nil, all players can interact
        item = nil, -- if nil, don't require an item to interact
    }
})

RemoveEntity

This export removes a entity target that you have created.

Argument
Description

identifier

The unique string identifier of the target you want to remove

Example

exports['nyx2_target']:RemoveEntity('debug_box_entity')

Last updated