Rework client-side medic task
This commit is contained in:
@@ -27,6 +27,9 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
var sortText;
|
||||
var deadRespawned = false;
|
||||
var isRevived = false;
|
||||
var timeLeft = 0;
|
||||
var deathTime;
|
||||
var taskTimeout = false;
|
||||
|
||||
var ticketName: string;
|
||||
var pointsName: string;
|
||||
@@ -374,6 +377,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
if (tasks[index].MedicName === "none") {
|
||||
mp.game.graphics.requestStreamedTextureDict("medicimages", true);
|
||||
mp.events.callRemote("updateMedicTask", 1, index);
|
||||
deathTime = tasks[index].Time;
|
||||
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
||||
activeCheckpoint = mp.checkpoints.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0,
|
||||
{
|
||||
@@ -468,26 +472,27 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
function getDistance2(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
mp.events.add("checkPointTimeout", () => {
|
||||
activeTask = false;
|
||||
activeCheckpoint.destroy();
|
||||
});
|
||||
|
||||
mp.events.add("cutMedicEarnings", () => {
|
||||
mp.gui.chat.push("DEBUG: Nur noch hälfte Verdienst!")
|
||||
deadRespawned = true;
|
||||
});
|
||||
|
||||
mp.events.add("destroyMedicTaskCheckpoint", () => {
|
||||
activeCheckpoint.destroy();
|
||||
activeTask = false;
|
||||
mp.events.callRemote("MedicTaskTimeout");
|
||||
});
|
||||
|
||||
mp.events.add('playerEnterCheckpoint', (activeCheckpoint) => {
|
||||
mp.gui.chat.push("DEBUG: Checkpoint NACH wiederbelebung des Spielers betreten")
|
||||
if (deadRespawned == true) {
|
||||
activeTask = false;
|
||||
activeCheckpoint.destroy();
|
||||
mp.events.callRemote("delReviveTaskMedic");
|
||||
mp.events.callRemote("PayCutMedicEarnings");
|
||||
mp.gui.chat.push("DEBUG: Checkpoint NACH wiederbelebung des Spielers betreten")
|
||||
mp.gui.chat.push("DEBUG: Hälfte ausgezahlt")
|
||||
activeCheckpoint.destroy();
|
||||
mp.events.callRemote("PayCutMedicEarnings");
|
||||
activeTask = false;
|
||||
deadRespawned = false;
|
||||
} else {
|
||||
activeTask = false;
|
||||
activeCheckpoint.destroy();
|
||||
mp.gui.chat.push("DEBUG: Checkpoint VOR wiederbelebung des Spielers betreten")
|
||||
}
|
||||
});
|
||||
@@ -511,8 +516,37 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
mp.game.graphics.drawSprite("medicimages", "ambulance", ambulanceImagePos + 0.01, 0.915, 0.04, 0.07, 0, 255, 255, 255, 255);
|
||||
} else {
|
||||
mp.game.graphics.drawSprite("medicimages", "running", ambulanceImagePos + 0.02, 0.915, 0.02, 0.035, 0, 255, 0, 0, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var currentDate = new Date();
|
||||
|
||||
if (deadRespawned == false) {
|
||||
timeLeft = Math.abs(deathTime - 30 - Math.floor(currentDate.getTime() / 1000));
|
||||
} else {
|
||||
timeLeft = Math.abs(deathTime - 60 - Math.floor(currentDate.getTime() / 1000));
|
||||
if (timeLeft < 0) mp.events.call("destroyMedicTaskCheckpoint");
|
||||
}
|
||||
|
||||
if (deadRespawned == false) {
|
||||
mp.game.graphics.drawText(timeLeft.toString() + "s", [0.5, 0.85], {
|
||||
font: 7,
|
||||
color: [60, 179, 113, 255],
|
||||
scale: [0.2, 0.2],
|
||||
outline: true,
|
||||
centre: true
|
||||
});
|
||||
} else {
|
||||
{
|
||||
mp.game.graphics.drawText(timeLeft.toString() + "s", [0.5, 0.85], {
|
||||
font: 7,
|
||||
color: [255, 203, 145, 255],
|
||||
scale: [0.2, 0.2],
|
||||
outline: true,
|
||||
centre: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user