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

[QUESTION] Can we detect if object is inOut zone ? #41

Closed ghost closed 3 years ago

ghost commented 3 years ago

Any to detect a object in zone ?

If we use example with pinckage: https://pastebin.com/Pmz6aM7b

How can I make soccerBall if it's in zone ?

Thanks!

mkafrin commented 3 years ago

onPointInOut allows you to pass any arbitrary function to get the "point" that is being tested. In your code, you are passing in PolyZone.getPlayerPosition, but you could just as easily do the following to instead use the soccerBall position:

pinkcage:onPointInOut(function() return GetEntityCoords(soccerBall) end, function(isPointInside, point)
    if isPointInside then
    DeleteObject(soccerBall)
    else
    print('out')
    end
end)

https://github.com/mkafrin/PolyZone/wiki/ComboZone#ispointinsideonpointinoutonplayerinout

ghost commented 3 years ago

Thanks for info, will take a look at it.