diff --git a/CHANGELOG b/CHANGELOG index bf84029..29e11ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,12 @@ +-- 2024.04.26 - 1.3.9 + +- feat: Selecting SPEC/Teams toggles AFK mode automatically +- fix: Auto team select being blocked +- fix: Networking logs +- fix: Using !afk to get out of AFK mode didnt change back the clantag +- fix: Respect round restart delay (toorisrael) +- fix: Duplicated round terminates after round ends + -- 2024.04.21 - 1.3.8 - fix: Challenge not ended properly diff --git a/src-plugin/Plugin/Models/ArenaPlayerModel.cs b/src-plugin/Plugin/Models/ArenaPlayerModel.cs index e3e41f8..9d9427c 100644 --- a/src-plugin/Plugin/Models/ArenaPlayerModel.cs +++ b/src-plugin/Plugin/Models/ArenaPlayerModel.cs @@ -110,7 +110,7 @@ public void SetupWeapons(RoundType roundType) CCSPlayerPawn playerPawn = Controller.PlayerPawn.Value; playerPawn.ArmorValue = roundType.Armor ? 100 : 0; - Utilities.SetStateChanged(playerPawn, "CCSPlayerPawnBase", "m_ArmorValue"); + Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_ArmorValue"); CCSPlayer_ItemServices itemServive = new CCSPlayer_ItemServices(playerPawn.ItemServices!.Handle) diff --git a/src-plugin/Plugin/Plugin.cs b/src-plugin/Plugin/Plugin.cs index 00751cb..b9ce513 100644 --- a/src-plugin/Plugin/Plugin.cs +++ b/src-plugin/Plugin/Plugin.cs @@ -20,6 +20,8 @@ public sealed partial class Plugin : BasePlugin, IPluginConfig public static readonly Random rng = new(); public static MemoryFunctionVoid? GiveNamedItem2; + public bool IsBetweenRounds = false; + public void OnConfigParsed(PluginConfig config) { CheckCommonProblems(); diff --git a/src-plugin/Plugin/PluginCommands.cs b/src-plugin/Plugin/PluginCommands.cs index 111b280..7c3ca92 100644 --- a/src-plugin/Plugin/PluginCommands.cs +++ b/src-plugin/Plugin/PluginCommands.cs @@ -7,6 +7,7 @@ namespace K4Arenas using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Utils; using K4Arenas.Models; + using Microsoft.Extensions.Logging; public sealed partial class Plugin : BasePlugin { @@ -195,6 +196,11 @@ public void Command_AFK(CCSPlayerController? player, CommandInfo info) player.Clan = $"{Localizer["k4.general.afk"]} |"; Utilities.SetStateChanged(player, "CCSPlayerController", "m_szClan"); } + else + { + arenaPlayer.Controller.Clan = $"{Localizer["k4.general.waiting"]} |"; + Utilities.SetStateChanged(arenaPlayer.Controller, "CCSPlayerController", "m_szClan"); + } info.ReplyToCommand($" {Localizer["k4.general.prefix"]} {(arenaPlayer.AFK ? string.Format(Localizer["k4.chat.afk_enabled"], Config.CommandSettings.AFKCommands.FirstOrDefault("Missing")) : Localizer["k4.chat.afk_disabled"])}"); } diff --git a/src-plugin/Plugin/PluginEvents.cs b/src-plugin/Plugin/PluginEvents.cs index c8bf398..e2967c4 100644 --- a/src-plugin/Plugin/PluginEvents.cs +++ b/src-plugin/Plugin/PluginEvents.cs @@ -281,8 +281,16 @@ public void Initialize_Events() return HookResult.Continue; }); + RegisterEventHandler((EventRoundStart @event, GameEventInfo info) => + { + IsBetweenRounds = false; + return HookResult.Continue; + }); + RegisterEventHandler((EventRoundEnd @event, GameEventInfo info) => { + IsBetweenRounds = true; + if (Arenas is null) return HookResult.Continue; diff --git a/src-plugin/Plugin/PluginListeners.cs b/src-plugin/Plugin/PluginListeners.cs index d5674c9..ca1f3c0 100644 --- a/src-plugin/Plugin/PluginListeners.cs +++ b/src-plugin/Plugin/PluginListeners.cs @@ -1,9 +1,11 @@ namespace K4Arenas { + using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Commands; using CounterStrikeSharp.API.Modules.Utils; using K4Arenas.Models; + using Microsoft.Extensions.Logging; public sealed partial class Plugin : BasePlugin { @@ -14,7 +16,7 @@ public void Initialize_Listeners() public HookResult ListenerJoinTeam(CCSPlayerController? player, CommandInfo info) { - if (player?.IsValid == true && player.PlayerPawn?.IsValid == true) + if (player?.IsValid == true && player.PlayerPawn?.IsValid == true && info.ArgByIndex(1) != "0") { ArenaPlayer? arenaPlayer = Arenas?.FindPlayer(player); if (arenaPlayer != null) @@ -22,6 +24,29 @@ public HookResult ListenerJoinTeam(CCSPlayerController? player, CommandInfo info if (player.Team != CsTeam.None) { + if (arenaPlayer?.AFK == false && player.Team != CsTeam.Spectator && info.ArgByIndex(1) == "1") + { + arenaPlayer!.AFK = true; + + player.Clan = $"{Localizer["k4.general.afk"]} |"; + Utilities.SetStateChanged(player, "CCSPlayerController", "m_szClan"); + + player!.ChangeTeam(CsTeam.Spectator); + + player.PrintToChat($" {Localizer["k4.general.prefix"]} {string.Format(Localizer["k4.chat.afk_enabled"], Config.CommandSettings.AFKCommands.FirstOrDefault("Missing"))}"); + return HookResult.Stop; + } + else if (arenaPlayer?.AFK == true && player.Team == CsTeam.Spectator && (info.ArgByIndex(1) == "2" || info.ArgByIndex(1) == "3")) + { + arenaPlayer!.AFK = false; + + arenaPlayer.Controller.Clan = $"{Localizer["k4.general.waiting"]} |"; + Utilities.SetStateChanged(arenaPlayer.Controller, "CCSPlayerController", "m_szClan"); + + player.PrintToChat($" {Localizer["k4.general.prefix"]} {Localizer["k4.chat.afk_disabled"]}"); + return HookResult.Continue; + } + player.ExecuteClientCommand("play sounds/ui/weapon_cant_buy.vsnd_c"); return HookResult.Stop; } diff --git a/src-plugin/Plugin/PluginManifest.cs b/src-plugin/Plugin/PluginManifest.cs index a92427f..52218b1 100644 --- a/src-plugin/Plugin/PluginManifest.cs +++ b/src-plugin/Plugin/PluginManifest.cs @@ -10,7 +10,7 @@ public sealed partial class Plugin : BasePlugin public override string ModuleAuthor => "K4ryuu"; - public override string ModuleVersion => "1.3.8 " + + public override string ModuleVersion => "1.3.9 " + #if RELEASE "(release)"; #else diff --git a/src-plugin/Plugin/PluginStock.cs b/src-plugin/Plugin/PluginStock.cs index c1c00d0..2427d2d 100644 --- a/src-plugin/Plugin/PluginStock.cs +++ b/src-plugin/Plugin/PluginStock.cs @@ -10,11 +10,15 @@ namespace K4Arenas using System.Data; using CounterStrikeSharp.API.Modules.Entities.Constants; using System.Runtime.Serialization; + using CounterStrikeSharp.API.Modules.Cvars; public sealed partial class Plugin : BasePlugin { public void TerminateRoundIfPossible(CsTeam? team = null) { + if (IsBetweenRounds) + return; + if (gameRules is null || gameRules.WarmupPeriod == true) return; @@ -50,7 +54,7 @@ public void TerminateRoundIfPossible(CsTeam? team = null) Server.NextFrame(() => { - gameRules.TerminateRound(3, tCount > ctCount ? RoundEndReason.TerroristsWin : ctCount > tCount ? RoundEndReason.CTsWin : RoundEndReason.RoundDraw); + gameRules.TerminateRound(ConVar.Find("mp_round_restart_delay")?.GetPrimitiveValue() ?? 3f, tCount > ctCount ? RoundEndReason.TerroristsWin : ctCount > tCount ? RoundEndReason.CTsWin : RoundEndReason.RoundDraw); }); } } diff --git a/src-plugin/readme.txt b/src-plugin/readme.txt index 30e90b2..f46142a 100644 --- a/src-plugin/readme.txt +++ b/src-plugin/readme.txt @@ -1,14 +1 @@ -For creating custom rounds: - - Forced weapon will be added to player (no preferred) if null, check for preferred - - Prefered weapon if enabled for primary checks for PrimaryPreference, which is a definition index (see below) - - Prefered weapon if enabled for secondary checks for Pistol preference, which is a definition index - - If teamsize is set to more than 1, the plugin check the map if capable to spawn more than 1 player per team, if yes, create teams dynamically if it can match the teamsize - - Possible PrimaryPreference values: - Rifle - 0 - Sniper - 1 - SMG - 2 - LMG - 3 - Shotgun - 4 - Pistol - 5 - All Primary - 6 \ No newline at end of file +https://github.com/K4ryuu/K4-Arenas/wiki \ No newline at end of file diff --git a/src-shared/K4-ArenaSharedApi.csproj b/src-shared/K4-ArenaSharedApi.csproj index 6942aac..a786503 100644 --- a/src-shared/K4-ArenaSharedApi.csproj +++ b/src-shared/K4-ArenaSharedApi.csproj @@ -12,7 +12,7 @@ enable - + none runtime compile; build; native; contentfiles; analyzers; buildtransitive