Skip to content

Commit

Permalink
Patch v1.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Apr 26, 2024
1 parent 6e1f5e1 commit 0b8255b
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 19 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src-plugin/Plugin/Models/ArenaPlayerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src-plugin/Plugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public sealed partial class Plugin : BasePlugin, IPluginConfig<PluginConfig>
public static readonly Random rng = new();
public static MemoryFunctionVoid<IntPtr, string, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr>? GiveNamedItem2;

public bool IsBetweenRounds = false;

public void OnConfigParsed(PluginConfig config)
{
CheckCommonProblems();
Expand Down
6 changes: 6 additions & 0 deletions src-plugin/Plugin/PluginCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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"])}");
}
Expand Down
8 changes: 8 additions & 0 deletions src-plugin/Plugin/PluginEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 26 additions & 1 deletion src-plugin/Plugin/PluginListeners.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -14,14 +16,37 @@ 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)
arenaPlayer.PlayerIsSafe = true;

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;
}
Expand Down
2 changes: 1 addition & 1 deletion src-plugin/Plugin/PluginManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src-plugin/Plugin/PluginStock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<float>() ?? 3f, tCount > ctCount ? RoundEndReason.TerroristsWin : ctCount > tCount ? RoundEndReason.CTsWin : RoundEndReason.RoundDraw);
});
}
}
Expand Down
15 changes: 1 addition & 14 deletions src-plugin/readme.txt
Original file line number Diff line number Diff line change
@@ -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
https://github.com/K4ryuu/K4-Arenas/wiki
2 changes: 1 addition & 1 deletion src-shared/K4-ArenaSharedApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.205">
<PackageReference Include="CounterStrikeSharp.API" Version="*">
<PrivateAssets>none</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 0b8255b

Please sign in to comment.