From c51fbd3246775bb03a6ae2b278253185d4efbe82 Mon Sep 17 00:00:00 2001 From: VegaZ Date: Sun, 4 Apr 2021 15:57:14 +0200 Subject: [PATCH] Fix Medic 3 --- .../Interaction/factioninteraction.ts | 18 ++++++-------- .../Factions/Medic/Medic.cs | 24 ++++++++++--------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/ReallifeGamemode.Client/Interaction/factioninteraction.ts b/ReallifeGamemode.Client/Interaction/factioninteraction.ts index bb670c6f..43edb4d4 100644 --- a/ReallifeGamemode.Client/Interaction/factioninteraction.ts +++ b/ReallifeGamemode.Client/Interaction/factioninteraction.ts @@ -13,8 +13,6 @@ export default function factionInteraction(globalData: IGlobalData) { var screenRes = mp.game.graphics.getScreenResolution(0, 0); var player = mp.players.local; var tasks; - var deathSeconds; - var initTasks; var newTasks; var sorting = 0; var firstSorting = true; @@ -40,6 +38,7 @@ export default function factionInteraction(globalData: IGlobalData) { /*mp.events.add("updateFactionBlips", (type, taskList) => { }); + });*/ mp.events.add("showFactionInteractionLSPD", (userFactionId, isDuty, userFactionName, isFactionLeader) => { //LSPD @@ -280,13 +279,9 @@ export default function factionInteraction(globalData: IGlobalData) { }); - mp.events.add("showMedicTasks", (type, taskList, deathTimes) => { + mp.events.add("showMedicTasks", (type, taskList) => { tasks = JSON.parse(taskList); - deathSeconds = JSON.parse(deathTimes); - if (sorting === 0) { - initTasks = tasks; - } //mp.events.call("sortFactionTasks", false); @@ -407,6 +402,7 @@ export default function factionInteraction(globalData: IGlobalData) { } }); + /* mp.events.add("sortFactionTasks", (sortByKey) => { if (firstSorting) { sortText = "Nach Uhrzeit"; @@ -462,7 +458,7 @@ export default function factionInteraction(globalData: IGlobalData) { } } } - }); + });*/ function getDistance1(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); @@ -530,11 +526,11 @@ export default function factionInteraction(globalData: IGlobalData) { var currentDate = new Date(); if (deadRespawned == false) { - timeLeft = Math.round(Math.abs(Math.floor(currentDate.getTime() / 1000) - activeTask.TimeLeft - 60)); - if (timeLeft < 1) mp.events.call("cutMedicEarnings"); + //timeLeft = Math.round(Math.abs(Math.floor(currentDate.getTime() / 1000) - activeTask.TimeLeft - 60)); + if (activeTask.TimeLeft < 60) mp.events.call("cutMedicEarnings"); } else { timeLeft = Math.round(Math.abs(Math.floor(currentDate.getTime() / 1000) - activeTask.TimeLeft - 120)); - if (timeLeft < 1) mp.events.call("destroyMedicTaskCheckpoint"); + if (activeTask.TimeLeft < 1) mp.events.call("destroyMedicTaskCheckpoint"); } if (deadRespawned == false) { diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 3a223c12..39bb0852 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -75,9 +75,17 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void UpdateTaskTimeLeft() { DateTime actualTime = DateTime.Now; - foreach(var task in ReviveTasks) + if (ReviveTasks.Count != 0) { - task.TimeLeft = (Int32)(((DateTimeOffset)task.Time).ToUnixTimeSeconds() - ((DateTimeOffset)actualTime).ToUnixTimeSeconds() - reviveTaskTime); + foreach (var task in ReviveTasks) + { + if (task.MedicName != null) + { + var taskTimeLeft = (Int32)(((DateTimeOffset)task.Time).ToUnixTimeSeconds() - ((DateTimeOffset)actualTime).ToUnixTimeSeconds() - reviveTaskTime); + task.TimeLeft = taskTimeLeft; + PlayerService.GetPlayerByNameOrId(task.MedicName).TriggerEvent("setTaskTimeLeft", taskTimeLeft); + } + } } } @@ -87,21 +95,15 @@ namespace ReallifeGamemode.Server.Factions.Medic switch (type) { case 0: - List deathTimes = new List(); - foreach(var task in ReviveTasks) - { - deathTimes.Add(((DateTimeOffset)task.Time).ToUnixTimeSeconds()); - } - - player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks), JsonConvert.SerializeObject(deathTimes)); + player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks)); break; case 1: - player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks), null); + player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks)); break; case 2: - player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks), null); + player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks)); break; } }