From 8d5501d56d5a503c0435ee0b4101b2355f3357c6 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 9 May 2024 22:03:24 +0200 Subject: [PATCH] bug fix for warmup --- CS2Retake/Managers/TeamManager.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CS2Retake/Managers/TeamManager.cs b/CS2Retake/Managers/TeamManager.cs index c35485f..90d7f9a 100644 --- a/CS2Retake/Managers/TeamManager.cs +++ b/CS2Retake/Managers/TeamManager.cs @@ -210,14 +210,14 @@ public void FixTeams() public void OnTick() { - if(GameRuleManager.Instance.IsWarmup) + if (GameRuleManager.Instance.IsWarmup) { return; } var playerIds = this._playerStateDict.Where(x => x.Value == PlayerStateEnum.Connected || x.Value == PlayerStateEnum.Spectating || x.Value == PlayerStateEnum.Queue).ToList(); - - foreach(var playerId in playerIds) + + foreach (var playerId in playerIds) { var player = Utilities.GetPlayerFromUserid(playerId.Key); var state = playerId.Value; @@ -341,6 +341,17 @@ public void PlayerSwitchTeam(CCSPlayerController player, CsTeam previousTeam, Cs return; } + if (GameRuleManager.Instance.IsWarmup && (newTeam == CsTeam.Terrorist || newTeam == CsTeam.CounterTerrorist)) + { + MessageUtils.LogDebug($"Switch to playing while warmup {userId}"); + this.UpdatePlayerStateDict(userId, PlayerStateEnum.Playing); + this.RemoveFromQueue(userId); + + player.ChangeTeam(newTeam); + + return; + } + //Allow switch to spectator if ((currentState == PlayerStateEnum.Connected || currentState == PlayerStateEnum.Playing) && newTeam == CsTeam.Spectator) {