Closed enc0ded closed 2 years ago
I got around this by passing the netID instead but still not sure why it doesn't return the correct entity.
You don't pass the entity yourself in the options, qb-target makes that variable for you
I've updated my post to reflect that. It still returns the same entity for each seperate object.
@enc0ded you might be hitting into variable shadowing issue due to the scope. Try changing the action function to
action = function(entity2)
print("Entity from action", entity2)
end
CreateThread(function()
local coords = GetEntityCoords(PlayerPedId())
RequestModel(`a_m_m_indian_01`)
local entity = CreatePed(0, `a_m_m_indian_01`, coords.x, coords.y, coords.z, 0, true, true)
print('Passed Entity', entity)
exports['qb-target']:AddEntityZone("test-"..entity, entity, {
name = "test-"..entity,
heading = GetEntityHeading(entity),
debugPoly = true,
}, {
options = {
{
label = "Pick Up",
icon = "fas fa-circle",
action = function(ent)
print('Entity from action', ent)
end
},
},
distance = 2.5
})
end)
I put this code in a client.lua of my testing resource and this works fine, the entity handle is correct each time
So I think your issue was what TheiLLeniumStudios mentioned
Describe the bug AddEntityZone always returns same entity.
To Reproduce Steps to reproduce the behavior:
Expected behavior To return relative entity to client