Skip to content

Commit

Permalink
Fix events with the spawn event
Browse files Browse the repository at this point in the history
  • Loading branch information
PintTheDragon committed Oct 29, 2020
1 parent 0a26661 commit 9755413
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions SCPStats/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> Queue = new List<string>();

Expand Down Expand Up @@ -212,25 +213,33 @@ private static IEnumerator<float> 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()
Expand All @@ -239,6 +248,7 @@ internal static void Waiting()

Restarting = false;
DidRoundEnd = false;
StartGrace = false;
}

internal static void OnKill(DyingEventArgs ev)
Expand All @@ -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()+"\"}");
}
Expand Down

0 comments on commit 9755413

Please sign in to comment.