Skip to content

Commit 07ff716

Browse files
authored
Merge pull request #14 from oscar-wos/maxplayers
feat: Config.MaxPlayers
2 parents 5447959 + 4f16a47 commit 07ff716

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/Config.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace AntiRush;
55

66
public class AntiRushConfig : BasePluginConfig
77
{
8-
public override int Version { get; set; } = 7;
8+
public override int Version { get; set; } = 8;
99
[JsonPropertyName("Messages")] public string Messages { get; set; } = "simple";
1010
[JsonPropertyName("DrawZones")] public bool DrawZones { get; set; } = false;
1111
[JsonPropertyName("Warmup")] public bool Warmup { get; set; } = false;
@@ -17,4 +17,5 @@ public class AntiRushConfig : BasePluginConfig
1717
[JsonPropertyName("CampZones")] public int[] CampZones { get; set; } = [1];
1818
[JsonPropertyName("Countdown")] public int[] Countdown { get; set; } = [60, 30, 15, 10, 5, 3, 2, 1];
1919
[JsonPropertyName("MinPlayers")] public int MinPlayers { get; set; } = 1;
20+
[JsonPropertyName("MaxPlayers")] public int MaxPlayers { get; set; } = 64;
2021
}

src/Events.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ public partial class AntiRush
99
{
1010
private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
1111
{
12-
_roundStart = Server.CurrentTime;
1312
_bombPlanted = false;
14-
1513
_gameRules = GameUtils.GetGameRules();
16-
_minPlayers = Utilities.GetPlayers().Where(p => p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist).ToList().Count >= Config.MinPlayers;
14+
_roundStart = Server.CurrentTime;
15+
16+
var count = Utilities.GetPlayers().Where(p => p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist).ToList().Count;
17+
_minPlayers = count >= Config.MinPlayers;
18+
_maxPlayers = count < Config.MaxPlayers;
1719

1820
foreach (var zone in _zones)
1921
{

src/Globals.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace AntiRush;
88
public partial class AntiRush
99
{
1010
public override string ModuleName => "AntiRush";
11-
public override string ModuleVersion => "1.0.11";
11+
public override string ModuleVersion => "1.0.12";
1212
public override string ModuleAuthor => "https://github.com/oscar-wos/AntiRush";
1313
public AntiRushConfig Config { get; set; } = new();
1414
public Menu.Menu Menu { get; } = new();
@@ -21,4 +21,5 @@ public partial class AntiRush
2121
private float[] _countdown = [];
2222
private CCSGameRules? _gameRules;
2323
private bool _minPlayers;
24+
private bool _maxPlayers;
2425
}

src/Listeners.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private void OnTick()
99
if (_gameRules is { WarmupPeriod: true } && !Config.Warmup)
1010
return;
1111

12-
if (!_minPlayers)
12+
if (!_minPlayers || !_maxPlayers)
1313
return;
1414

1515
if (Config.NoRushTime != 0 && !_bombPlanted)

0 commit comments

Comments
 (0)