mkafrin / PolyZone

PolyZone is a FiveM mod to define zones of different shapes and test whether a point is inside or outside of the zone
MIT License
204 stars 191 forks source link

Combo onPlayerInOut method not getting triggered #80

Closed ali-exacute closed 1 year ago

ali-exacute commented 1 year ago

Only on resource startup it works, and will not print anymore (debug markers showing up correct)

inside a loop

zones[#zones+1] = CircleZone:Create(blipData.radiusCoord, blipData.radiusRange, {
        name= name..tostring(i),
       useZ=true,
       })
end

After loop is done :

local combo = ComboZone:Create(zones, {name="safezones", debugPoly=true})
combo:onPlayerInOut(function(isPointInside, point, zone)
  print("combo: isPointInside>>", isPointInside)
  print("combo: point>>", point)
  print("combo: zone>>", zone)
end)
mkafrin commented 1 year ago

Are you entering and exiting the zone with the player? The onPlayerInOut callback doesn't trigger continuously, it only triggers if you go from outside the zone to in it, or vice versa. If you are and it's still not working, do you have overlapping zones? Aka multiple zones in the same place, or one large zone with smaller ones inside of it? If so, you may need to use the exhaustive helpers since onPlayerInOut stops after it finds the first zone you are inside of (see https://github.com/mkafrin/PolyZone/wiki/ComboZone#exhaustive-helpers).

Also, are you getting any errors (from your script or PolyZone) in the console?

ali-exacute commented 1 year ago

hey

  1. yes i am entering and exiting the zone
  2. no there are no overlapping zones at all
  3. sadly there are no errors
mkafrin commented 1 year ago

Hmm given that, it'd be hard for me to determine what's going wrong without a reproduction of the issue. Can you take your current code and shorten it to a simple and repeatable reproduction of the issue and post that here? Then I can look into why it's happening.

PolEpie commented 1 year ago

Hi, i have the same thing while drawing a 3d on a separate thread on function ComboZone:new(zones, options) idk why it happend but all ComboZone stop working and my text work pretty fine ! To fix it i need to reinstall my server cause even on removing my function call on the new function it still not working then even after reboot. Like ali said there is no errors

PolEpie commented 1 year ago

Code here to reproduce https://gist.github.com/PolEpie/ef4cefd55dcaa3888d91ee715da5e79f

mkafrin commented 1 year ago

This doesn't seem to be a PolyZone issue. Adding a call to your own code to PolyZone's files then it breaking seems to point to your own code having a bug. Closing this for now.

PolEpie commented 1 year ago

The fact is that is permanently broke poly zone with just one line of code and then it still broke even If i delete the code so there might be an issue somewhere. I’m new in five m coding so if you can help me to understand why ? Is there a thread limit ?

mkafrin commented 1 year ago

I have no idea why it might be breaking and I'm sorry but I frankly don't have the time to debug other resources code. You can try asking in help channels in the fivem discord or forums. If I were you, I'd test your code (and attempt to fix it) outside the context of PolyZone, since PolyZone breaking is just a symptom of your code that you inserted into it breaking.