Rework client-side medic task
This commit is contained in:
@@ -54,20 +54,12 @@ export default function deathScreen() {
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
mp.events.callRemote('RespawnPlayerAtHospital');
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("Mptattoos");
|
||||
mp.events.callRemote("CutMedicEarnings");
|
||||
});
|
||||
|
||||
mp.events.add("updateDutyMedics", (count) => {
|
||||
dutyMedics = count;
|
||||
});
|
||||
|
||||
mp.events.add("medicTaskTimeout", (count) => {
|
||||
taskTimeout = true;
|
||||
mp.events.callRemote("MedicTaskTimeout");
|
||||
mp.events.callRemote("RemoveMedicCheckpoint");
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("render", () => {
|
||||
var currentDate = new Date();
|
||||
|
||||
@@ -113,10 +105,6 @@ export default function deathScreen() {
|
||||
} else {
|
||||
mp.events.call("respawnDeathPlayer");
|
||||
}
|
||||
} else {
|
||||
if (deathSeconds < medicJobTime && taskTimeout == false) {
|
||||
mp.events.callRemote("medicTaskTimeout");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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('playerEnterCheckpoint', (activeCheckpoint) => {
|
||||
mp.gui.chat.push("DEBUG: Checkpoint NACH wiederbelebung des Spielers betreten")
|
||||
if (deadRespawned == true) {
|
||||
activeTask = false;
|
||||
mp.events.add("destroyMedicTaskCheckpoint", () => {
|
||||
activeCheckpoint.destroy();
|
||||
mp.events.callRemote("delReviveTaskMedic");
|
||||
mp.events.callRemote("PayCutMedicEarnings");
|
||||
activeTask = false;
|
||||
mp.events.callRemote("MedicTaskTimeout");
|
||||
});
|
||||
|
||||
mp.events.add('playerEnterCheckpoint', (activeCheckpoint) => {
|
||||
if (deadRespawned == true) {
|
||||
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")
|
||||
}
|
||||
});
|
||||
@@ -513,6 +518,35 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -291,6 +291,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0);
|
||||
|
||||
deadPlayer.TriggerEvent("onPlayerRevived");
|
||||
player.TriggerEvent("destroyMedicTaskCheckpoint");
|
||||
deadPlayer.SendNotification($"Du wurdest von ~y~{player.Name}~s~ für ~g~{100.ToMoneyString()} ~s~wiederbelebt.");
|
||||
player.SendNotification($"Du hast ~y~{deadPlayer.Name}~s~ wiederbelebt und ~g~{Medic.ReviveIncome}$ ~s~für die Fraktion verdient.");
|
||||
deadPlayer.SetData("isDead", false);
|
||||
|
||||
@@ -136,14 +136,6 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
RemoveTaskFromList(task);
|
||||
}
|
||||
|
||||
[RemoteEvent("RemoveMedicCheckpoint")]
|
||||
public void RemoveMedicCheckpoint(Player player)
|
||||
{
|
||||
MedicTask task = ReviveTasks.FirstOrDefault(t => t.Victim == player.Name);
|
||||
var medic = PlayerService.GetPlayerByNameOrId(task.MedicName);
|
||||
medic.TriggerEvent("checkPointTimeout");
|
||||
medic.SendNotification("Der Auftrag wurde abgebrochen da du nicht innerhalb der Zeit am Einsatzort warst!");
|
||||
}
|
||||
[RemoteEvent("CutMedicEarnings")]
|
||||
public void CutMedicEarnings(Player player)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user