From 9755413b6430397c7656f9f26a83f6a8b56cb536 Mon Sep 17 00:00:00 2001 From: PintTheDragon Date: Wed, 28 Oct 2020 20:40:33 -0700 Subject: [PATCH] Fix events with the spawn event --- SCPStats/EventHandler.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/SCPStats/EventHandler.cs b/SCPStats/EventHandler.cs index 71c1177..685971c 100644 --- a/SCPStats/EventHandler.cs +++ b/SCPStats/EventHandler.cs @@ -23,6 +23,7 @@ internal class EventHandler private static WebSocket ws = null; private static Task Pinger = null; private static bool PingerActive = false; + private static bool StartGrace = false; private static List Queue = new List(); @@ -212,25 +213,33 @@ private static IEnumerator ClearPlayers() internal static void OnRoundStart() { + StartGrace = true; Restarting = false; DidRoundEnd = false; - SendRequest("00",null); + SendRequest("00", ""); + + Timing.CallDelayed(10f, () => + { + StartGrace = false; + }); } internal static void OnRoundEnd(RoundEndedEventArgs ev) { DidRoundEnd = true; + StartGrace = false; - SendRequest("01", null); + SendRequest("01", ""); } internal static void OnRoundRestart() { Restarting = true; + StartGrace = false; if (DidRoundEnd) return; - SendRequest("01", null); + SendRequest("01", ""); } internal static void Waiting() @@ -239,6 +248,7 @@ internal static void Waiting() Restarting = false; DidRoundEnd = false; + StartGrace = false; } internal static void OnKill(DyingEventArgs ev) @@ -254,9 +264,9 @@ internal static void OnKill(DyingEventArgs ev) internal static void OnRoleChanged(ChangingRoleEventArgs ev) { - if (!IsPlayerValid(ev.Player, true, false)) return; + if ((!RoundSummary.RoundInProgress() && !StartGrace) || !IsPlayerValid(ev.Player, true, false)) return; - if (!RoundSummary.RoundInProgress() || ev.IsEscaped && !ev.Player.DoNotTrack) + if (ev.IsEscaped && !ev.Player.DoNotTrack) { SendRequest("07", "{\"playerid\": \""+HandleId(ev.Player.RawUserId)+"\", \"role\": \""+((int) ev.Player.Role).ToString()+"\"}"); }