I currently have this code
for _, obj in ipairs(GetGamePool('CObject')) do
if DoesEntityExist(obj) and GetEntityModel(obj) == GetHashKey('prop_vend_soda_01') then
...
end
This code seems to only get all object rendered around the player on the moment the script is started.
When I move to a place further away from the location where I started the script, then it doesn’t work.
I use ox_target inside the if statement and the third eye option don’t show on the vending machines far away from the place where I was when the script started
for _, obj in ipairs(GetGamePool('CObject')) do
if DoesEntityExist(obj) and GetEntityModel(obj) == GetHashKey(Config.Models.Cola) then
exports.ox_target:addBoxZone({
coords = GetEntityCoords(obj),
size = vec3(2,2,2),
rotation = 45,
debug = drawZones,
options = {
{
distance = 1,
name = "buy-cola",
event = 'ss-script:buycola',
icon = 'fa-solid fa-cube',
label = "Buy Cola ($" .. Config.Prices.Cola .. ")",
}
}
})
end
end