Closed Maxamax1 closed 2 years ago
Well EntityZones already have offset and scale options, since it inherits from BoxZone (BoxZone options), but honestly if you're using qtarget anyways, why not just target the object or model? Feel like creating a polyzone to target is just an extra step and will be less accurate as well compared to targeting the object or model directly.
well qtarget relies on PolyZone
test1 = GetClosestObjectOfType(482.2, -999.4, 30.8, 1.0, 165994623, false, false, false)
iam getting the HashID from the door and with
exports.qtarget:AddEntityZone("test", test1, {
debugPoly=true,
useZ = true
}, {
options = {
{
icon = 'fas fa-shopping-basket',
label = "test",
action = function()
end
},
},distance = 2.5
})
i add a zone to the entity (it moves when i open the door) so iam telling qtarget to add a zone.
local function AddEntityZone(name, entity, options, targetoptions)
Zones[name] = EntityZone:Create(entity, options)
Zones[name].targetoptions = targetoptions
end
exports('AddEntityZone', AddEntityZone)
is from qtarget and tells PolyZone to create a EntityZone
function EntityZone:Create(entity, options)
local zone = EntityZone:new(entity, options)
_initDebug(zone, options)
return zone
end
then
function EntityZone:new(entity, options)
assert(DoesEntityExist(entity), "Entity does not exist")
local min, max = GetModelDimensions(GetEntityModel(entity))
local dimensions = {min, max}
local length = max.y - min.y
local width = max.x - min.x
local pos = GetEntityCoords(entity)
local zone = BoxZone:new(pos, length, width, options)
if options.useZ == true then
options.minZ, options.maxZ = _calculateMinAndMaxZ(entity, dimensions, zone.scaleZ, zone.offsetZ, pos)
else
options.minZ = nil
options.maxZ = nil
end
zone.entity = entity
zone.dimensions = dimensions
zone.useZ = options.useZ
zone.damageEventHandlers = {}
zone.isEntityZone = true
setmetatable(zone, self)
self.__index = self
return zone
end
so in the code above line with "local pos = GetEntityCoords(entity)" i think there should the offset happen
I'm pretty sure qtarget only relies on PolyZone if you are registering BoxZone, CircleZone, or EntityZone targets. You can also use it with entities and models, seen in the docs here:
https://overextended.github.io/qtarget/entity https://overextended.github.io/qtarget/model
These seem like they'd work better for your use case. But regardless of whether you use them, as I already said, EntityZones and BoxZones already support offset and scale options.
i was just confused because here: https://github.com/mkafrin/PolyZone/wiki/EntityZone these not listed as options.
If you read right above EntityZone options, it states that EntityZone inherits all but a couple of BoxZone's options.
thanks
i wanted to use PolyZone in combination with qtarget to make a doorlock script but if i do this: test1 = GetClosestObjectOfType(482.2, -999.4, 30.8, 1.0, 165994623, false, false, false) exports.qtarget:AddEntityZone("test", test1, { debugPoly=true, useZ = true }, { options = { { icon = 'fas fa-shopping-basket', label = "test", action = function() -- some code end }, },distance = 2.5
}) i get this: the issue is now to center the zone on the door. do you have any idea how i can do it? maybe some offset which could be implemented in PolyZone my discord is 𝓜𝓪𝔁𝓪𝓜𝓪𝔁#5405