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