added library for polygons

This commit is contained in:
Fabian
2021-04-22 17:12:52 +02:00
parent 44609e0ee6
commit 093563ea87
5 changed files with 110 additions and 0 deletions

View File

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