laufenden countdown auch nach login/register anzeigen

This commit is contained in:
hydrant
2021-04-11 05:36:23 +02:00
parent cf62e11656
commit 5d4d1165de
5 changed files with 23 additions and 4 deletions

View File

@@ -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;
});

View File

@@ -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);
}

View File

@@ -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);
}
}
}
}

View File

@@ -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
{

View File

@@ -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; }
}
}