Skip to content

Commit

Permalink
bug fix for warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
LordFetznschaedl committed May 9, 2024
1 parent ac12877 commit 8d5501d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions CS2Retake/Managers/TeamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 8d5501d

Please sign in to comment.