index.js vom polygon hinzugefügt
This commit is contained in:
@@ -7,14 +7,14 @@ export function isPlayerInNoDMZone(pos) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function positionHandler() {
|
export default function nodmHandler() {
|
||||||
|
|
||||||
mp.events.add('playerEnterPolygon', (polygon) => {
|
mp.events.add('playerEnterPolygon', (polygon) => {
|
||||||
mp.gui.chat.push("entered");
|
mp.gui.chat.push("entered");
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add('playerLeavePolygon', (polygon) => {
|
mp.events.add('playerLeavePolygon', (polygon) => {
|
||||||
mp.gui.chat.push("entered");
|
mp.gui.chat.push("leaved");
|
||||||
});
|
});
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
@@ -186,8 +186,8 @@ ped();
|
|||||||
import reportList from './Player/reportmenu';
|
import reportList from './Player/reportmenu';
|
||||||
reportList(globalData);
|
reportList(globalData);
|
||||||
|
|
||||||
import positionHandler from './Player/position';
|
import nodmHandler from './Player/nodm';
|
||||||
positionHandler();
|
nodmHandler();
|
||||||
|
|
||||||
import checkpointHandle from './util/checkpoint';
|
import checkpointHandle from './util/checkpoint';
|
||||||
checkpointHandle(globalData);
|
checkpointHandle(globalData);
|
||||||
|
|||||||
48
ReallifeGamemode.Client/polygons/index.js
Normal file
48
ReallifeGamemode.Client/polygons/index.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
const { generateUniquePolygonId, getAngleSumBetweenPositionAndVertices, isPointInArea2D } = require('polygons/helpers');
|
||||||
|
require('polygons/render');
|
||||||
|
require('polygons/events');
|
||||||
|
|
||||||
|
mp.polygons = {
|
||||||
|
pool: [],
|
||||||
|
add: (vertices, height, options = { visible: false, lineColorRGBA: [255,255,255,255], dimension: 0 }) => {
|
||||||
|
|
||||||
|
const polygon = {
|
||||||
|
id: generateUniquePolygonId(),
|
||||||
|
vertices,
|
||||||
|
height,
|
||||||
|
...options,
|
||||||
|
colliding: false
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.polygons.pool.push(polygon);
|
||||||
|
|
||||||
|
return polygon;
|
||||||
|
},
|
||||||
|
remove: (polygon) => {
|
||||||
|
const index = mp.polygons.pool.findIndex(p => p.id === polygon.id);
|
||||||
|
|
||||||
|
if (index !== -1)
|
||||||
|
mp.polygons.pool.splice(index, 1);
|
||||||
|
},
|
||||||
|
exists: (polygon) => {
|
||||||
|
return mp.polygons.pool.some(p => p.id === polygon.id)
|
||||||
|
},
|
||||||
|
isPositionWithinPolygon: (position, polygon, dimension) => {
|
||||||
|
if (dimension && polygon.dimension !== dimension && polygon.dimension !== -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const { vertices } = polygon;
|
||||||
|
|
||||||
|
const polygonPoints2D = [];
|
||||||
|
|
||||||
|
for (let i in vertices) {
|
||||||
|
if (position.z >= vertices[i].z && position.z <= (vertices[i].z + polygon.height) || getAngleSumBetweenPositionAndVertices(position, vertices) >= 5.8)
|
||||||
|
polygonPoints2D.push([vertices[i].x, vertices[i].y]);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isPointInArea2D([position.x, position.y], polygonPoints2D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isPlayerInNoDMZone } from "../Player/position";
|
import { isPlayerInNoDMZone } from "../Player/nodm";
|
||||||
|
|
||||||
export default function weapondamageUtil() {
|
export default function weapondamageUtil() {
|
||||||
let blockInput = false;
|
let blockInput = false;
|
||||||
@@ -11,7 +11,6 @@ export default function weapondamageUtil() {
|
|||||||
|
|
||||||
mp.events.add('outgoingDamage', (sourceEntity, targetEntity, sourcePlayer, weapon, boneIndex, damage) => {
|
mp.events.add('outgoingDamage', (sourceEntity, targetEntity, sourcePlayer, weapon, boneIndex, damage) => {
|
||||||
if (isPlayerInNoDMZone(targetEntity.position) || isPlayerInNoDMZone(sourceEntity.position)) {
|
if (isPlayerInNoDMZone(targetEntity.position) || isPlayerInNoDMZone(sourceEntity.position)) {
|
||||||
mp.gui.chat.push("Kein DM in NODM!");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user