Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 1690aa4

Browse files
committed
Release v2.0.1
1 parent 355aae3 commit 1690aa4

File tree

7 files changed

+41
-20
lines changed

7 files changed

+41
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
-- 2025.02.06 - 2.0.1
2+
3+
- feat: Introduced configurable default round type for scenarios where players have no matching round preferences
4+
- fix: Resolved queue assignment issues when warmup_enabled convars was disabled
5+
16
-- 2025.02.04 - 2.0.0
27

38
- feat: Added automated challenge systems for bots

src-plugin/Plugin/Models/ArenaRoundTypeModel.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ public struct RoundType(string name, int teamSize, CsItem? primary, CsItem? seco
2222
public readonly bool EnabledByDefault = enabledByDefaultAction;
2323
public readonly Action<List<CCSPlayerController>?, List<CCSPlayerController>?>? StartFunction = startFunction;
2424
public readonly Action<List<CCSPlayerController>?, List<CCSPlayerController>?>? EndFunction = endFunction;
25-
public static readonly RoundType Rifle = new RoundType("k4.rounds.rifle", 1, null, null, true, WeaponType.Rifle, true);
26-
public static readonly RoundType Sniper = new RoundType("k4.rounds.sniper", 1, null, null, true, WeaponType.Sniper, true);
27-
public static readonly RoundType Shotgun = new RoundType("k4.rounds.shotgun", 1, null, null, true, WeaponType.Shotgun, true);
28-
public static readonly RoundType Pistol = new RoundType("k4.rounds.pistol", 1, null, null, false, null, true);
29-
public static readonly RoundType Scout = new RoundType("k4.rounds.scout", 1, CsItem.Scout, null, false, null, true);
30-
public static readonly RoundType AWP = new RoundType("k4.rounds.awp", 1, CsItem.AWP, null, false, null, true);
31-
public static readonly RoundType Deagle = new RoundType("k4.rounds.deagle", 1, null, CsItem.Deagle, false, null, false);
32-
public static readonly RoundType SMG = new RoundType("k4.rounds.smg", 1, null, null, true, WeaponType.SMG, true);
33-
public static readonly RoundType LMG = new RoundType("k4.rounds.lmg", 1, null, null, true, WeaponType.LMG, true);
34-
public static readonly RoundType TwoVSTwo = new RoundType("k4.rounds.2vs2", 2, null, null, true, WeaponType.Unknown, true);
35-
public static readonly RoundType ThreeVSThree = new RoundType("k4.rounds.3vs3", 3, null, null, true, WeaponType.Unknown, true);
36-
public static readonly RoundType Knife = new RoundType("k4.rounds.knife", 1, null, null, false, null, false, false, false);
25+
public static readonly RoundType Rifle = new("k4.rounds.rifle", 1, null, null, true, WeaponType.Rifle, true);
26+
public static readonly RoundType Sniper = new("k4.rounds.sniper", 1, null, null, true, WeaponType.Sniper, true);
27+
public static readonly RoundType Shotgun = new("k4.rounds.shotgun", 1, null, null, true, WeaponType.Shotgun, true);
28+
public static readonly RoundType Pistol = new("k4.rounds.pistol", 1, null, null, false, null, true);
29+
public static readonly RoundType Scout = new("k4.rounds.scout", 1, CsItem.Scout, null, false, null, true);
30+
public static readonly RoundType AWP = new("k4.rounds.awp", 1, CsItem.AWP, null, false, null, true);
31+
public static readonly RoundType Deagle = new("k4.rounds.deagle", 1, null, CsItem.Deagle, false, null, false);
32+
public static readonly RoundType SMG = new("k4.rounds.smg", 1, null, null, true, WeaponType.SMG, true);
33+
public static readonly RoundType LMG = new("k4.rounds.lmg", 1, null, null, true, WeaponType.LMG, true);
34+
public static readonly RoundType TwoVSTwo = new("k4.rounds.2vs2", 2, null, null, true, WeaponType.Unknown, true);
35+
public static readonly RoundType ThreeVSThree = new("k4.rounds.3vs3", 3, null, null, true, WeaponType.Unknown, true);
36+
public static readonly RoundType Knife = new("k4.rounds.knife", 1, null, null, false, null, false, false, false);
3737

3838
public static List<RoundType> RoundTypes { get; } = [];
3939

@@ -47,7 +47,7 @@ public static void AddRoundType(RoundTypeReader roundType)
4747

4848
public static int AddSpecialRoundType(string name, int teamSize, bool enabledByDefault, Action<List<CCSPlayerController>?, List<CCSPlayerController>?> startFunction, Action<List<CCSPlayerController>?, List<CCSPlayerController>?> endFunction)
4949
{
50-
RoundType specialRound = new RoundType(name, teamSize, null, null, false, null, false, false, false, enabledByDefault, startFunction, endFunction);
50+
RoundType specialRound = new(name, teamSize, null, null, false, null, false, false, false, enabledByDefault, startFunction, endFunction);
5151
RoundTypes.Add(specialRound);
5252
return specialRound.ID;
5353
}

src-plugin/Plugin/PluginConfig.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public sealed class PluginConfig : BasePluginConfig
128128
public DefaultWeaponSettings DefaultWeaponSettings { get; set; } = new DefaultWeaponSettings();
129129

130130
[JsonPropertyName("ConfigVersion")]
131-
public override int Version { get; set; } = 7;
131+
public override int Version { get; set; } = 8;
132132
}
133133

134134
public sealed class CompatibilitySettings
@@ -231,6 +231,9 @@ public sealed class DefaultWeaponSettings
231231

232232
[JsonPropertyName("default-pistol")]
233233
public string? DefaultPistol { get; set; } = null;
234+
235+
[JsonPropertyName("default-round")]
236+
public string? DefaultRound { get; set; } = "k4.rounds.rifle";
234237
}
235238

236239
public sealed class DatabaseSettings

src-plugin/Plugin/PluginEvents.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace K4Arenas
77
using CounterStrikeSharp.API.Modules.Timers;
88
using CounterStrikeSharp.API.Modules.Utils;
99
using K4Arenas.Models;
10-
using Microsoft.Extensions.Logging;
1110

1211
public sealed partial class Plugin : BasePlugin
1312
{
@@ -28,6 +27,12 @@ public void Initialize_Events()
2827

2928
gameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First().GameRules;
3029

30+
foreach (CCSPlayerController player in Utilities.GetPlayers().Where(x => x?.IsValid == true && !x.IsHLTV && x.Connected == PlayerConnectedState.PlayerConnected && !x.IsBot))
31+
{
32+
if (Arenas.FindPlayer(player) == null)
33+
SetupPlayer(player);
34+
}
35+
3136
AddTimer(3, () => // ! Fixes issues with the 3 sec warmup countdown when warmuptime is 0
3237
{
3338
if (gameRules?.WarmupPeriod == true && ConVar.Find("mp_warmuptime")?.GetPrimitiveValue<float>() > 0.0f)
@@ -151,7 +156,6 @@ public void Initialize_Events()
151156
if (!Config.CompatibilitySettings.BlockDamageOfNotOpponent)
152157
return HookResult.Continue;
153158

154-
155159
ArenaPlayer? attacker = Arenas?.FindPlayer(@event.Attacker);
156160
ArenaPlayer? target = Arenas?.FindPlayer(@event.Userid);
157161

@@ -178,7 +182,7 @@ public void Initialize_Events()
178182

179183
RegisterEventHandler((EventRoundPrestart @event, GameEventInfo info) =>
180184
{
181-
if (gameRules == null || gameRules.WarmupPeriod || lastRealPlayers == 0 || Arenas == null)
185+
if (gameRules == null || gameRules.WarmupPeriod || Arenas == null)
182186
return HookResult.Continue;
183187

184188
Queue<ArenaPlayer> arenaWinners = new();

src-plugin/Plugin/PluginManifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public sealed partial class Plugin : BasePlugin
1010

1111
public override string ModuleAuthor => "K4ryuu";
1212

13-
public override string ModuleVersion => "2.0.0 " +
13+
public override string ModuleVersion => "2.0.1 " +
1414
#if RELEASE
1515
"(release)";
1616
#else

src-plugin/Plugin/PluginStock.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void TerminateRoundIfPossible()
3131
if (gameRules.WarmupPeriod == true || Arenas == null)
3232
return;
3333

34-
List<CCSPlayerController> players = [.. Utilities.GetPlayers().Where(x => x?.IsValid == true && x.PlayerPawn?.IsValid == true && !x.IsHLTV && x.Connected == PlayerConnectedState.PlayerConnected)];
34+
List<CCSPlayerController> players = [.. Utilities.GetPlayers().Where(x => x?.IsValid == true && x.PlayerPawn?.IsValid == true && x.Team > CsTeam.Spectator && !x.IsHLTV && x.Connected == PlayerConnectedState.PlayerConnected)];
3535

3636
if (!players.Any(p => !p.IsBot))
3737
return;
@@ -182,7 +182,7 @@ public static void CheckCommonProblems()
182182
Server.ExecuteCommand("mp_free_armor 0");
183183
}
184184

185-
public static RoundType GetCommonRoundType(List<RoundType>? roundPreferences1, List<RoundType>? roundPreferences2, bool multi)
185+
public RoundType GetCommonRoundType(List<RoundType>? roundPreferences1, List<RoundType>? roundPreferences2, bool multi)
186186
{
187187
List<RoundType> commonRounds = roundPreferences1?.Intersect(roundPreferences2 ?? roundPreferences1)?.ToList() ?? [];
188188
List<RoundType> commonUsableRounds = multi ? commonRounds : [.. commonRounds.Where(rt => rt.TeamSize < 2)];
@@ -192,6 +192,15 @@ public static RoundType GetCommonRoundType(List<RoundType>? roundPreferences1, L
192192
return commonUsableRounds[Random.Shared.Next(0, commonUsableRounds.Count)];
193193
}
194194

195+
if (!string.IsNullOrEmpty(Config.DefaultWeaponSettings.DefaultRound))
196+
{
197+
RoundType? defaultRound = RoundType.RoundTypes.FirstOrDefault(rt => rt.Name == Config.DefaultWeaponSettings.DefaultRound);
198+
if (defaultRound != null)
199+
{
200+
return (RoundType)defaultRound;
201+
}
202+
}
203+
195204
List<RoundType> availableRoundTypes = [.. RoundType.RoundTypes.Where(rt => rt.TeamSize < 2)];
196205
return availableRoundTypes[Random.Shared.Next(0, availableRoundTypes.Count)];
197206
}

src-shared/K4-ArenaSharedApi.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)