AddPed

AddPed

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

peds

A single, or table of, pedsthat the target should be for

options

The options for the target (see Options Formatting)

Usage

exports['nyx2_target']:AddPed(identifier, peds, options)

Example

local pedCoords = vector4(-71.38, -821.39, 326.18 - 1.0, 52.81)
local pedModel = GetHashKey('mp_m_freemode_01')

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

local ped = CreatePed(4, pedModel, pedCoords.x, pedCoords.y, pedCoords.z, pedCoords.w, false, false)
SetEntityAsMissionEntity(ped, true, true)
SetBlockingOfNonTemporaryEvents(ped, true)
FreezeEntityPosition(ped, true)
SetEntityInvincible(ped, true)
SetEntityVisible(ped, true)
SetEntityAlpha(ped, 255, false)
SetModelAsNoLongerNeeded(pedModel)

exports['nyx2_target']:AddPed('debug_ped', ped, {{
    title = 'Debug Ped',
    icon = 'fas fa-user',
    action = function(zone)
        local QBCore = exports['qb-core']:GetCoreObject()
        QBCore.Functions.Notify('This is a ped!', '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
}})

RemovePed

This export removes a pedtarget that you have created.

Arguments

Argument
Description

identifier

The unique string identifier of the zone you want to remove

Example

exports['nyx2_target']:RemovePed('debug_ped')

Last updated