From f139dfdab7266da1499853ecc8002e4dace560d9 Mon Sep 17 00:00:00 2001 From: VegaZ Date: Thu, 8 Apr 2021 23:33:19 +0200 Subject: [PATCH] add Checkpoint Update Sani --- .../Interaction/factioninteraction.ts | 9 +++++++- .../Commands/FactionCommands.cs | 1 + .../Factions/Medic/Medic.cs | 21 +++++++++++++++++-- ReallifeGamemode.Server/Util/ThreadTimers.cs | 13 ++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/Interaction/factioninteraction.ts b/ReallifeGamemode.Client/Interaction/factioninteraction.ts index c2489d92..54642ae2 100644 --- a/ReallifeGamemode.Client/Interaction/factioninteraction.ts +++ b/ReallifeGamemode.Client/Interaction/factioninteraction.ts @@ -17,7 +17,7 @@ export default function factionInteraction(globalData: IGlobalData) { var sorting = 0; var firstSorting = true; var activeTask = null; - var activeCheckpoint; + var activeCheckpoint: CheckpointMp; var taskStart; var taskFinish; var taskRange; @@ -427,6 +427,13 @@ export default function factionInteraction(globalData: IGlobalData) { } }); + mp.events.add('updateHealCheckpoint', (xPos, yPos, zPos) => { + if (activeTask && activeTask.Type == 1) { + activeCheckpoint.setCoords(xPos, yPos, zPos, false, false, false, false); + mp.game.ui.setNewWaypoint(xPos, yPos); + } + }); + function renderMedicGui() { if (activeTask) { rangeLeft = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, taskFinish.x, taskFinish.y, taskFinish.z, true).toFixed(2); diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index 358cb273..eec24506 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -398,6 +398,7 @@ namespace ReallifeGamemode.Server.Commands ChatService.SendMessage(target, "~g~" + player.Name + " ~s~möchte dich für ~g~$" + price + " ~s~heilen. Drücke ~g~J~s~ zum Erlauben oder ~r~N ~s~zum Verbieten"); player.SendNotification("Du hast " + target.Name + " einen Heal angeboten", false); target.SetData("healDecision", true); + Medic.delHealTask(target); Medic.HealDecisions.Add(new Medic.HealDecision { dMedic = player, dTarget = target, dPrice = price }); } diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 679bec9a..4b5e634f 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -149,7 +149,7 @@ namespace ReallifeGamemode.Server.Factions.Medic activeDecision.dTarget.Health = 100; activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false); activeDecision.dMedic.SendNotification($"Du hast ~g~{activeDecision.dTarget.Name} ~s~ für {activeDecision.dPrice.ToMoneyString()} geheilt", false); - delHealTask(activeDecision.dTarget); + delHealTask(activeDecision.dTarget); } HealDecisions.Remove(activeDecision); } @@ -161,7 +161,7 @@ namespace ReallifeGamemode.Server.Factions.Medic DateTime actualTime = DateTime.Now; foreach (var task in ReviveTasks) { - if (task.MedicName != null) + if (task.MedicName != "none") { var taskTimeLeft = Math.Abs((int)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime)); task.TimeLeft = taskTimeLeft; @@ -172,6 +172,23 @@ namespace ReallifeGamemode.Server.Factions.Medic } } + public static void UpdateHealTaskCheckpoint() + { + if (HealTasks.Count != 0) + { + foreach(var task in HealTasks) + { + if(task.MedicName != "none") + { + var medic = PlayerService.GetPlayerByNameOrId(task.MedicName); + var victim = PlayerService.GetPlayerByNameOrId(task.Victim); + task.Position = victim.Position; + medic.TriggerEvent("updateHealCheckpoint", victim.Position.X, victim.Position.Y, victim.Position.Z); + } + } + } + } + [RemoteEvent("loadMedicTasks")] public void LoadMedicTasks(Player player, int type) { diff --git a/ReallifeGamemode.Server/Util/ThreadTimers.cs b/ReallifeGamemode.Server/Util/ThreadTimers.cs index 1d79d970..f0b2a057 100644 --- a/ReallifeGamemode.Server/Util/ThreadTimers.cs +++ b/ReallifeGamemode.Server/Util/ThreadTimers.cs @@ -14,6 +14,7 @@ namespace ReallifeGamemode.Server.Util private static Timer timer500 = new Timer(500); //0.5 seconds timer private static Timer timer1000 = new Timer(1000); //1 seconds timer private static Timer timer2500 = new Timer(2500); //2.5 seconds timer + private static Timer timer5000 = new Timer(5000); //5 seconds timer private static Timer timer10000 = new Timer(10000); // 10 second timer private static Timer timer60000 = new Timer(60000); //60 seconds timer @@ -28,6 +29,9 @@ namespace ReallifeGamemode.Server.Util timer2500.Start(); timer2500.Elapsed += Timer2500_Elapsed; + timer5000.Start(); + timer5000.Elapsed += Timer5000_Elapsed; + timer10000.Start(); timer10000.Elapsed += Timer10000_Elapsed; @@ -53,6 +57,15 @@ namespace ReallifeGamemode.Server.Util }); } + private static void Timer5000_Elapsed(object sender, ElapsedEventArgs e) + { + NAPI.Task.Run(() => + { + Medic.UpdateHealTaskCheckpoint(); + }); + } + + private static void Timer60000_Elapsed(object sender, ElapsedEventArgs e) { NAPI.Task.Run(() =>