diff --git a/ChaseMod.cs b/ChaseMod.cs index ae39fb5..4c6b1f5 100644 --- a/ChaseMod.cs +++ b/ChaseMod.cs @@ -59,14 +59,11 @@ public override void Unload(bool hotReload) [GameEventHandler] public HookResult OnEventRoundFreezeEnd(EventRoundFreezeEnd @event, GameEventInfo info) { - Server.NextFrame(() => - { - TriggerWorkaround.DisableWorkaroundTriggers(); - }); + Server.NextFrame(TriggerWorkaround.DisableWorkaroundTriggers); return HookResult.Continue; } - public void OnTick() + private void OnTick() { foreach (var controller in ChaseModUtils.GetAllRealPlayers()) { diff --git a/ChaseModConfig.cs b/ChaseModConfig.cs index 6092dca..4daac25 100644 --- a/ChaseModConfig.cs +++ b/ChaseModConfig.cs @@ -2,6 +2,7 @@ using System.Text.Json.Serialization; namespace ChaseMod; + public sealed class ChaseModConfig : BasePluginConfig { [JsonPropertyName("Version")] diff --git a/Commands/MiscCommands.cs b/Commands/MiscCommands.cs index be2adbd..da98424 100644 --- a/Commands/MiscCommands.cs +++ b/Commands/MiscCommands.cs @@ -1,15 +1,19 @@ -using System.Runtime.InteropServices; -using CounterStrikeSharp.API; -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core; namespace ChaseMod.Commands; + public static class MiscCommands { - public static void AddCommands(BasePlugin plugin) { + plugin.AddCommand("css_hns", "Shows the current version of the plugin", (client, args) => + { + if (client == null || !client.IsValid) + { + return; + } + client.PrintToChat($"HnS ChaseMod v{plugin.ModuleVersion}"); + }); } - } - diff --git a/KnifeCooldownManager.cs b/KnifeCooldownManager.cs index aed47eb..950a3c8 100644 --- a/KnifeCooldownManager.cs +++ b/KnifeCooldownManager.cs @@ -4,6 +4,7 @@ using CounterStrikeSharp.API.Modules.Utils; namespace ChaseMod; + internal class KnifeCooldownManager { private readonly ChaseMod _plugin; @@ -40,7 +41,6 @@ private HookResult CBaseEntity_TakeDamageOldFuncHook(DynamicHook hook) } var attacker = info.Attacker.Value!.As(); - var attackerController = attacker.Controller.Value!; var pawn = entity.As(); var controller = pawn.OriginalController.Value!; diff --git a/NadeManager.cs b/NadeManager.cs index 7438407..77e7a6d 100644 --- a/NadeManager.cs +++ b/NadeManager.cs @@ -6,6 +6,7 @@ using CounterStrikeSharp.API; namespace ChaseMod; + internal class NadeManager { private readonly ChaseMod _plugin; @@ -124,5 +125,4 @@ private void FreezeGrenadeExplode(CSmokeGrenadeProjectile smoke) smoke.Remove(); } - } diff --git a/PlayerFreezeManager.cs b/PlayerFreezeManager.cs index 25340dc..7f73fa9 100644 --- a/PlayerFreezeManager.cs +++ b/PlayerFreezeManager.cs @@ -75,7 +75,7 @@ public void Freeze(CCSPlayerController controller, float time, bool showEffect, } } - public void Unfreeze(CCSPlayerController controller, bool sendMessage) + private void Unfreeze(CCSPlayerController controller, bool sendMessage) { if (!ChaseModUtils.IsRealPlayer(controller)) return; var pawn = controller.PlayerPawn.Value!; @@ -110,10 +110,7 @@ public void Unfreeze(CCSPlayerController controller, bool sendMessage) var timeRemaining = freezeState.Time - freezeTime; return timeRemaining; } - else - { - return null; - } + + return null; } - } diff --git a/README.md b/README.md index cc410dd..6bb0b3f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # ChaseMod -CS2 HNS ChaseMod (freezetime, freezenade, antiflash, knife dmg, winstreak team switch) +CS2 HNS ChaseMod (freezetime, freezenade, antiflash, knife dmg, winstreak team switch) + ## Installation Download the .zip from the [releases](https://github.com/ipsvn/ChaseMod/releases) and extract the contents into `counterstrikesharp/plugins/ChaseMod` on your server. diff --git a/RoundStartFreezeTimeManager.cs b/RoundStartFreezeTimeManager.cs index 4ac5093..78e807c 100644 --- a/RoundStartFreezeTimeManager.cs +++ b/RoundStartFreezeTimeManager.cs @@ -48,15 +48,10 @@ public void Start() SwitchFallDamage(false); - foreach (var player in ChaseModUtils.GetAllRealPlayers()) + foreach (var player in ChaseModUtils.GetAllRealPlayers().Where(p => p.Team == CsTeam.CounterTerrorist)) { - var pawn = player.PlayerPawn.Value!; - - if (player.Team == CsTeam.CounterTerrorist) - { - _playerFreezeManager.Freeze(player, _plugin.Config.RoundStartFreezeTime, - true, false, true); - } + _playerFreezeManager.Freeze(player, _plugin.Config.RoundStartFreezeTime, + true, false, true); } if (_countdownTimer != null) diff --git a/TeamSwitchManager.cs b/TeamSwitchManager.cs index 37c4830..a0eff6d 100644 --- a/TeamSwitchManager.cs +++ b/TeamSwitchManager.cs @@ -4,6 +4,7 @@ using ChaseMod.Utils.Memory; namespace ChaseMod; + internal class TeamSwitchManager { private bool _switchingTeams; diff --git a/Utils/ChaseModUtils.cs b/Utils/ChaseModUtils.cs index 36b0b9e..dfdf828 100644 --- a/Utils/ChaseModUtils.cs +++ b/Utils/ChaseModUtils.cs @@ -48,5 +48,4 @@ public static void ChatAllPrefixed(string message) { Server.PrintToChatAll($" {ChatColors.Magenta}HNS {ChatColors.Grey}| {message}"); } - -} \ No newline at end of file +} diff --git a/Utils/Extensions.cs b/Utils/Extensions.cs index 21973cf..abc5eb9 100644 --- a/Utils/Extensions.cs +++ b/Utils/Extensions.cs @@ -5,6 +5,7 @@ using Vector = CounterStrikeSharp.API.Modules.Utils.Vector; namespace ChaseMod.Utils; + public static class Extensions { public static float Distance(this Vector thisVector, Vector vector2) @@ -59,7 +60,7 @@ public static void DisableAllWeaponsUntil(this CPlayer_WeaponServices weaponServ } } - public static void SetMoveType(this CCSPlayerPawn pawn, MoveType_t moveType) + private static void SetMoveType(this CCSPlayerPawn pawn, MoveType_t moveType) { pawn.MoveType = moveType; Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType"); diff --git a/Utils/Memory/CCSMatch.cs b/Utils/Memory/CCSMatch.cs index 8ec1d8f..6b73350 100644 --- a/Utils/Memory/CCSMatch.cs +++ b/Utils/Memory/CCSMatch.cs @@ -3,6 +3,7 @@ using System.Runtime.InteropServices; namespace ChaseMod.Utils.Memory; + public class CCSMatch { private static nint MATCH_OFFSET = 0xF3C; @@ -41,7 +42,7 @@ public static void SwapTeamScores(CCSGameRules gameRules) var marshallMatch = Marshal.PtrToStructure(structOffset); - short temp = marshallMatch.m_terroristScoreFirstHalf; + var temp = marshallMatch.m_terroristScoreFirstHalf; marshallMatch.m_terroristScoreFirstHalf = marshallMatch.m_ctScoreFirstHalf; marshallMatch.m_ctScoreFirstHalf = temp; diff --git a/Utils/Memory/GrenadeFunctions.cs b/Utils/Memory/GrenadeFunctions.cs index 05b64fe..46c24d0 100644 --- a/Utils/Memory/GrenadeFunctions.cs +++ b/Utils/Memory/GrenadeFunctions.cs @@ -1,12 +1,9 @@ using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; namespace ChaseMod.Utils.Memory; + public static class GrenadeFunctions { - // search 'decoy_projectile', xref to function string used at top - public static MemoryFunctionWithReturn CDecoyProjectile_CreateFunc = - new(@"\x55\x4C\x89\xC1\x48\x89\xE5\x41\x57\x45\x89\xCF\x41\x56\x49\x89\xFE\x41\x55\x49\x89\xD5\x48\x89\xF2\x48\x89\xFE\x41\x54\x48\x8D\x3D\x2A\x2A\x2A\x2A\x53\x4C\x89\xC3\x48\x83\xEC\x18"); - // search 'smokegrenade_projectile', xref to function string used at top public static MemoryFunctionWithReturn CSmokeGrenadeProjectile_CreateFunc = new(