Fix polygon api

This commit is contained in:
hydrant
2021-04-22 17:52:39 +02:00
parent 17c2392a64
commit c276b87977
6 changed files with 114 additions and 85 deletions

View File

@@ -0,0 +1,22 @@
import polygons from ".";
setInterval(() => {
const { position, dimension } = mp.players.local;
polygons.pool.map((polygon) => {
if (polygon.colliding) {
if (!polygons.isPositionWithinPolygon(position, polygon, dimension)) {
polygon.colliding = false;
mp.events.call('playerLeavePolygon', polygon);
}
}
else {
if (polygons.isPositionWithinPolygon(position, polygon, dimension)) {
polygon.colliding = true;
mp.events.call('playerEnterPolygon', polygon);
}
}
});
}, 100);