brentN5 / bt-target

GNU General Public License v3.0
36 stars 52 forks source link

[Bug] Polyzone not working throws an error #13

Open benzon opened 3 years ago

benzon commented 3 years ago

Got some issues with Polyzones it throws an error, since it can't work with the vector2 values, if i do vector3's or even add a min and max height, it dos not react either.

161775716154a868a8e7b7d40e8fa55c2bcb75b1c8

exports['bt-target']:AddPolyzone("Test", {vector2(733.60607910156, 658.37176513672), vector2(726.609375, 638.64202880859), vector2(646.35656738281, 668.22436523438), vector2(653.34967041016, 687.67864990234)}, {
        name="Test",
        debugPoly=true,
        }, {
            options = {
                {
                    event = "signon",
                    icon = "far fa-clipboard",
                    label = "Sign On",
                },
            },
            job = {"all"},
            distance = 2.5
        })
xDope7137 commented 3 years ago

Same issue with creating "AddPolyzone". Still finding a way to fix it.

The issue is, bt-target cant find Zones[_].center with vector2 math

LiamDormon commented 3 years ago

The issue is, bt-target cant find Zones[_].center with vector2 math

Polyzones don't have a center param so there is no vector for it to work with, the vector2 has nothing to do with this. This is going to either need an exception specific to polyzones or add an addition center param to them

benzon commented 3 years ago

Hmm and how would you do that @Mojito-Fivem

LiamDormon commented 3 years ago

I think the easiest way to ammend this would be to add a center param to the AddPolyZone function like so

function AddPolyzone(name, center, points, options, targetoptions)
    Zones[name] = PolyZone:Create(points, options)
    Zones[name].targetoptions = targetoptions
    Zones[name].center = center
end

And then you can add an extra vector3 for the center of your PolyZone

exports["bt-target"]:AddPolyZone("ZoneName", vector3(0, 0, 0), points, options, {
    options = {
         {
              event = "some_event",
              icon = "fas fa-icon",
              label = "A Label"     
         }
    },
    jobs = {"all"},
    distance = 2.0,
}

If this works submit a PR to this repository or my maintained one.