Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: B3none/cs2-retakes
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.4
Choose a base ref
...
head repository: B3none/cs2-retakes
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.0.5
Choose a head ref
  • 7 commits
  • 4 files changed
  • 3 contributors

Commits on May 19, 2024

  1. Copy the full SHA
    83f43f0 View commit details
  2. Ensure player is active before dequeueing

    dollannn committed May 19, 2024
    Copy the full SHA
    d1f5cd3 View commit details
  3. Add RemoveSpectators config option

    dollannn committed May 19, 2024
    Copy the full SHA
    20cf0df View commit details
  4. Copy the full SHA
    2c12cd5 View commit details
  5. Changes

    dollannn committed May 19, 2024
    Copy the full SHA
    06f1dbc View commit details

Commits on May 20, 2024

  1. Update README.md

    dollannn authored May 20, 2024
    Copy the full SHA
    b33ee87 View commit details
  2. Merge pull request #126 from dollannn/master

    Remove player from game and queue if they are moved to spectator
    B3none authored May 20, 2024
    Copy the full SHA
    87c5ec9 View commit details
Showing with 41 additions and 6 deletions.
  1. +1 −0 README.md
  2. +2 −1 RetakesPlugin/Modules/Configs/RetakesConfigData.cs
  3. +28 −2 RetakesPlugin/Modules/Managers/GameManager.cs
  4. +10 −3 RetakesPlugin/RetakesPlugin.cs
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ When the plugin is first loaded it will create a `retakes_config.json` file in t
| IsDebugMode | Whether to enable debug output to the server console or not. | false | false | true |
| ShouldForceEvenTeamsWhenPlayerCountIsMultipleOf10 | Whether to force even teams when the active players is a multiple of 10 or not. (this means you will get 5v5 @ 10 players / 10v10 @ 20 players) | true | false | true |
| EnableFallbackBombsiteAnnouncement | Whether to enable the fallback bombsite announcement. | true | false | true |
| ShouldRemoveSpectators | When a player is moved to spectators, remove them from all retake queues. Ensures that AFK plugins work as expected. | false | false | true |

## Commands
| Command | Arguments | Description | Permissions |
3 changes: 2 additions & 1 deletion RetakesPlugin/Modules/Configs/RetakesConfigData.cs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

public class RetakesConfigData
{
public static int CurrentVersion = 8;
public static int CurrentVersion = 9;

public int Version { get; set; } = CurrentVersion;
public int MaxPlayers { get; set; } = 9;
@@ -19,4 +19,5 @@ public class RetakesConfigData
public bool IsDebugMode { get; set; } = false;
public bool ShouldForceEvenTeamsWhenPlayerCountIsMultipleOf10 { get; set; } = true;
public bool EnableFallbackBombsiteAnnouncement { get; set; } = true;
public bool ShouldRemoveSpectators { get; set; } = true;
}
30 changes: 28 additions & 2 deletions RetakesPlugin/Modules/Managers/GameManager.cs
Original file line number Diff line number Diff line change
@@ -11,17 +11,18 @@ public class GameManager
public readonly QueueManager QueueManager;
private readonly int _consecutiveRoundWinsToScramble;
private readonly bool _isScrambleEnabled;

private readonly bool _removeSpectatorsEnabled;
public const int ScoreForKill = 50;
public const int ScoreForAssist = 25;
public const int ScoreForDefuse = 50;

public GameManager(Translator translator, QueueManager queueManager, int? roundsToScramble, bool? isScrambleEnabled)
public GameManager(Translator translator, QueueManager queueManager, int? roundsToScramble, bool? isScrambleEnabled, bool? RemoveSpectatorsEnabled)
{
_translator = translator;
QueueManager = queueManager;
_consecutiveRoundWinsToScramble = roundsToScramble ?? 5;
_isScrambleEnabled = isScrambleEnabled ?? true;
_removeSpectatorsEnabled = RemoveSpectatorsEnabled ?? false;
}

private bool _scrambleNextRound;
@@ -245,4 +246,29 @@ private void SetTeams(List<CCSPlayerController>? terrorists, List<CCSPlayerContr
}
}
}

public HookResult RemoveSpectators(EventPlayerTeam @event, HashSet<CCSPlayerController> _hasMutedVoices)
{
if (_removeSpectatorsEnabled)
{
CCSPlayerController? player = @event.Userid;

if (!Helpers.IsValidPlayer(player))
{
return HookResult.Continue;
}
int team = @event.Team;

if (team == (int)CsTeam.Spectator)
{
// Ensure player is active ingame.
if (QueueManager.ActivePlayers.Contains(player))
{
QueueManager.RemovePlayerFromQueues(player);
_hasMutedVoices.Remove(player);
}
}
}
return HookResult.Continue;
}
}
13 changes: 10 additions & 3 deletions RetakesPlugin/RetakesPlugin.cs
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ namespace RetakesPlugin;
[MinimumApiVersion(220)]
public class RetakesPlugin : BasePlugin
{
private const string Version = "2.0.4";
private const string Version = "2.0.5";

#region Plugin info
public override string ModuleName => "Retakes Plugin";
@@ -487,7 +487,8 @@ private void OnMapStart(string mapName)
_retakesConfig?.RetakesConfigData?.ShouldForceEvenTeamsWhenPlayerCountIsMultipleOf10
),
_retakesConfig?.RetakesConfigData?.RoundsToScramble,
_retakesConfig?.RetakesConfigData?.IsScrambleEnabled
_retakesConfig?.RetakesConfigData?.IsScrambleEnabled,
_retakesConfig?.RetakesConfigData?.ShouldRemoveSpectators
);

_breakerManager = new BreakerManager(
@@ -815,7 +816,13 @@ public HookResult OnPlayerTeam(EventPlayerTeam @event, GameEventInfo info)
// Ensure all team join events are silent.
@event.Silent = true;

return HookResult.Continue;
if (_gameManager == null)
{
Helpers.Debug($"Game manager not loaded.");
return HookResult.Continue;
}

return _gameManager.RemoveSpectators(@event, _hasMutedVoices);
}

private HookResult OnCommandJoinTeam(CCSPlayerController? player, CommandInfo commandInfo)