Fix polygon api
This commit is contained in:
22
ReallifeGamemode.Client/polygons/events.ts
Normal file
22
ReallifeGamemode.Client/polygons/events.ts
Normal 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);
|
||||
Reference in New Issue
Block a user