From 070edec44a16d2564e94148440049488f6ca2c72 Mon Sep 17 00:00:00 2001 From: daffyyyy Date: Mon, 20 Nov 2023 23:35:27 +0100 Subject: [PATCH] New temporary fix for commands Old method throws exception and duplicate messages --- CS2-Tags.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/CS2-Tags.cs b/CS2-Tags.cs index 3ce2253..d536802 100644 --- a/CS2-Tags.cs +++ b/CS2-Tags.cs @@ -101,7 +101,7 @@ public class CS2_Tags : BasePlugin if (player == null || !player.IsValid) return HookResult.Continue; string steamid = new SteamID(player.SteamID).SteamId64.ToString(); - if (info.GetArg(1) == "rtv") return HookResult.Continue; + if (info.GetArg(1).StartsWith("!") || info.GetArg(1).StartsWith("/") || info.GetArg(1) == "rtv") return HookResult.Continue; if (JsonTags != null && JsonTags.TryGetValue("tags", out var tags) && tags is JObject tagsObject) { @@ -113,13 +113,15 @@ public class CS2_Tags : BasePlugin Server.PrintToChatAll(ReplaceTags($" {prefix}{nickColor}{player.PlayerName}{ChatColors.Default}: {messageColor}{info.GetArg(1)}")); + /* Temp fix for commands OLD if (info.GetArg(1).StartsWith("!") || info.GetArg(1).StartsWith("/")) { CBasePlayerPawn pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex((int)player.EntityIndex!.Value.Value)); - var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value; + int playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value; NativeAPI.IssueClientCommand(playerIndex, $"css_{info.GetArg(1).Replace("!", "")}"); } + */ return HookResult.Handled; } @@ -141,14 +143,6 @@ public class CS2_Tags : BasePlugin Server.PrintToChatAll(ReplaceTags($" {prefix}{nickColor}{player.PlayerName}{ChatColors.Default}: {messageColor}{info.GetArg(1)}")); - if (info.GetArg(1).StartsWith("!") || info.GetArg(1).StartsWith("/")) - { - CBasePlayerPawn pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex((int)player.EntityIndex!.Value.Value)); - var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value; - - NativeAPI.IssueClientCommand(playerIndex, $"css_{info.GetArg(1).Replace("!", "")}"); - } - return HookResult.Handled; } }