35 lines
1004 B
TypeScript
35 lines
1004 B
TypeScript
import * as NativeUI from 'NativeUI';
|
|
import InputHelper from '../inputhelper';
|
|
|
|
export default function checkpointHandle(globalData: GlobalData) {
|
|
var count = 0;
|
|
var myVar;
|
|
var posCp;
|
|
var Player;
|
|
var activeCheckpoint;
|
|
var inCheckpoint = false;
|
|
|
|
mp.events.add('setCheckPoint', (position, player) => {
|
|
mp.gui.chat.push("exec");
|
|
posCp = position;
|
|
Player = player;
|
|
activeCheckpoint = mp.markers.new(1, posCp, 3.0, {
|
|
color: [255, 0, 0, 150],
|
|
visible: true,
|
|
dimension: 0
|
|
});
|
|
|
|
myVar = setInterval(myTimer, 100);
|
|
});
|
|
|
|
function myTimer() {
|
|
let dist = mp.game.gameplay.getDistanceBetweenCoords(Player.position.x, Player.position.y, 0, posCp.x, posCp.y, 0, false);
|
|
|
|
if (dist <= 2 && !inCheckpoint) {
|
|
inCheckpoint = true;
|
|
mp.events.callRemote("playerInCheckpoint");
|
|
} else if (dist > 2) {
|
|
inCheckpoint = false;
|
|
}
|
|
}
|
|
} |