diff --git a/ReallifeGamemode.Client/Gui/infobox.ts b/ReallifeGamemode.Client/Gui/infobox.ts index 74f48eeb..eb8a65fa 100644 --- a/ReallifeGamemode.Client/Gui/infobox.ts +++ b/ReallifeGamemode.Client/Gui/infobox.ts @@ -86,8 +86,8 @@ export default function (globalData: IGlobalData): void { gangwarTimer = gwTimer; }); - mp.events.add("countdown", (timer, text) => { - countdown = timer; + mp.events.add("countdown", (timer: number, text) => { + countdown = Math.round(timer); cdTimestamp = Date.now(); countdownText = text; }); diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index d887447b..17eb64a8 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -544,6 +544,9 @@ namespace ReallifeGamemode.Server.Commands return; } + GlobalHelper.CountdownUntil = DateTime.Now + TimeSpan.FromSeconds(timer); + GlobalHelper.CountdownText = text; + NAPI.ClientEvent.TriggerClientEventForAll("countdown", timer, text); } diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index 284a87d5..0d46c49c 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -10,7 +10,7 @@ using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Database.Entities; - +using System; /** * @overview Life of German Reallife - Event Login (Login.cs) @@ -167,6 +167,11 @@ namespace ReallifeGamemode.Server.Events player.SetData("isDead", false); } }, delayTime: 1000); + + if(GlobalHelper.CountdownUntil > DateTime.Now) + { + player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText); + } } } } diff --git a/ReallifeGamemode.Server/Events/Register.cs b/ReallifeGamemode.Server/Events/Register.cs index be48a443..1ec96ced 100644 --- a/ReallifeGamemode.Server/Events/Register.cs +++ b/ReallifeGamemode.Server/Events/Register.cs @@ -4,6 +4,8 @@ using ReallifeGamemode.Database.Entities; using Newtonsoft.Json; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Util; +using System; /** * @overview Life of German Reallife - Event Register (Register.cs) @@ -66,6 +68,11 @@ namespace ReallifeGamemode.Server.Events player.TriggerEvent("toggleCreator"); player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027)); //player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ); + + if (GlobalHelper.CountdownUntil > DateTime.Now) + { + player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText); + } } else { diff --git a/ReallifeGamemode.Server/Util/GlobalHelper.cs b/ReallifeGamemode.Server/Util/GlobalHelper.cs index ca03c41f..8fcd8b3a 100644 --- a/ReallifeGamemode.Server/Util/GlobalHelper.cs +++ b/ReallifeGamemode.Server/Util/GlobalHelper.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using GTANetworkAPI; namespace ReallifeGamemode.Server.Util @@ -14,5 +15,8 @@ namespace ReallifeGamemode.Server.Util { "iCroniX", "Life of Malle - Eimer für Alle - Alle für Malle - Böllern! (CroniX)" }, { "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" }, }; + + public static DateTime CountdownUntil { get; internal set; } + public static string CountdownText { get; internal set; } } }