Skip to content

Commit

Permalink
Added fix to prevent a bug where there were no active players
Browse files Browse the repository at this point in the history
  • Loading branch information
B3none committed Jan 6, 2024
1 parent 3517093 commit 3baca6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Modules/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,9 @@ public static void RemoveHelmetAndHeavyArmour(CCSPlayerController player)
itemServices.HasHelmet = false;
itemServices.HasHeavyArmor = false;
}

public static void RestartGame()
{
Server.ExecuteCommand("mp_restartgame 1");
}
}
9 changes: 8 additions & 1 deletion RetakesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventIn
if (Utilities.GetPlayers().ToList().Count <= 2)
{
Console.WriteLine($"{LogPrefix}First or second player connected, resetting game.");
Server.ExecuteCommand("mp_restartgame 1");
Helpers.RestartGame();
}

return HookResult.Continue;
Expand Down Expand Up @@ -652,6 +652,13 @@ public HookResult OnPlayerTeam(EventPlayerTeam @event, GameEventInfo info)
_gameManager.QueueManager.PlayerTriedToJoinTeam(player, (CsTeam)@event.Oldteam, (CsTeam)@event.Team);
_gameManager.QueueManager.DebugQueues(false);

// If we don't have any active players, setup the active players and restart the game.
if (_gameManager.QueueManager.ActivePlayers.Count == 0)
{
_gameManager.QueueManager.SetupActivePlayers();
Helpers.RestartGame();
}

return HookResult.Continue;
}

Expand Down

0 comments on commit 3baca6b

Please sign in to comment.