From dd7a2f4c16c762f751c28c088579ca3547a4523d Mon Sep 17 00:00:00 2001 From: originalaidn <45371311+originalaidn@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:17:12 +0100 Subject: [PATCH 1/4] huge modification - modified respawn, now the players need to respawn - added stealth command as hide, removed the team selection menu (from CSS discord) - removed silentmode - added discord webhook logging system (need to set in config -DiscordWebhook and edit Version to 4) in the future, need to add every color to replace thing and maybe need to remove those replace messages and add to sendwebhook but not yet. --- CS2-SimpleAdmin.cs | 268 +++++++++++++++++++++++++++++++++++++---- CS2-SimpleAdmin.csproj | 1 + Config.cs | 5 +- 3 files changed, 247 insertions(+), 27 deletions(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index e14d8f7..a6f5896 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -8,6 +8,7 @@ using CounterStrikeSharp.API.Modules.Commands.Targeting; using CounterStrikeSharp.API.Modules.Cvars; using CounterStrikeSharp.API.Modules.Entities; using CounterStrikeSharp.API.Modules.Memory; +using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Menu; using CounterStrikeSharp.API.Modules.Utils; using Microsoft.Extensions.Localization; @@ -36,7 +37,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "CS2-SimpleAdmin"; public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)"; public override string ModuleAuthor => "daffyy"; - public override string ModuleVersion => "1.2.8d"; + public override string ModuleVersion => "1.2.9d"; + + private MemoryFunctionVoid? CBasePlayerController_SetPawnFunc; public CS2_SimpleAdminConfig Config { get; set; } = new(); @@ -48,6 +51,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig(@"\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x55\x41\x54\x49\x89\xFC\x53\x48\x89\xF3\x48\x81\xEC\xC8\x00\x00\x00"); } public void OnConfigParsed(CS2_SimpleAdminConfig config) @@ -260,25 +265,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig { caller.ChangeTeam(CsTeam.None); }); - - command.ReplyToCommand("You are hidden now"); + if (silentPlayers.Contains((ushort)caller.UserId)) + { + silentPlayers.Remove((ushort)caller.UserId); + caller.ChangeTeam(CsTeam.Spectator); + caller.PrintToChat($"You aren't hidden now!"); + if(Config.DiscordWebhook.Length > 0) + _ = SendWebhookMessage($"{caller.PlayerName} isn't hidden now."); + } + else + { + silentPlayers.Add((ushort)caller.UserId); + Server.ExecuteCommand("sv_disable_teamselect_menu 1"); + Server.NextFrame(() => + { + caller.PlayerPawn.Value.CommitSuicide(true, false); + AddTimer(1.0f, () => { caller.ChangeTeam(CsTeam.Spectator); }); + AddTimer(1.1f, () => { caller.ChangeTeam(CsTeam.None); }); + caller.PrintToChat($"You are hidden now!"); + if(Config.DiscordWebhook.Length > 0) + _ = SendWebhookMessage($"{caller.PlayerName} is hidden now."); + }); + Server.NextFrame(() => + { + AddTimer(2.0f, () => { Server.ExecuteCommand("sv_disable_teamselect_menu 0"); }); + }); + } } [ConsoleCommand("css_who")] @@ -456,6 +464,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_kick_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } }); } @@ -544,6 +558,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -555,6 +574,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } } @@ -616,6 +640,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -627,6 +656,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } @@ -762,6 +796,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"Ungaged player with pattern {pattern}."); return; } } @@ -853,6 +889,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -864,6 +905,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } } @@ -925,6 +971,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -936,6 +987,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } @@ -1070,6 +1126,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"Unmuted player with pattern {pattern}."); return; } } @@ -1141,6 +1199,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -1152,6 +1215,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } } @@ -1216,6 +1284,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -1227,6 +1300,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } } @@ -1296,6 +1374,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } else @@ -1307,6 +1390,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } @@ -1340,6 +1428,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"Unbanned player with pattern {pattern}."); } [ConsoleCommand("css_slay")] @@ -1360,6 +1450,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_slay_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } }); } @@ -1408,6 +1503,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_give_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, weaponName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } }); } @@ -1433,6 +1533,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } }); @@ -1462,6 +1567,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } }); @@ -1495,6 +1605,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } }); @@ -1526,6 +1641,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_god_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } } @@ -1559,6 +1679,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } }); @@ -1633,6 +1758,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_team_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, _teamName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } }); } @@ -1664,6 +1794,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } voteInProgress = true; @@ -1679,12 +1814,22 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_vote_message_results", question]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } foreach (KeyValuePair kvp in voteAnswers) { sb = new(_localizer!["sa_prefix"]); sb.Append(_localizer["sa_admin_vote_message_results_answer", kvp.Key, kvp.Value]); Server.PrintToChatAll(sb.ToString()); + if(Config.DiscordWebhook.Length > 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_vote_message_results_answer", kvp.Key, kvp.Value]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } voteAnswers.Clear(); voteInProgress = false; @@ -1730,6 +1875,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_changemap_message", caller == null ? "Console" : caller.PlayerName, map]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } if (!map.StartsWith("ws:")) @@ -1765,6 +1915,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_changemap_message", caller == null ? "Console" : caller.PlayerName, map]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } AddTimer(2.0f, () => @@ -1785,6 +1940,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_adminchat_template_admin", caller == null ? "Console" : caller.PlayerName, utf8String]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat"))) { @@ -1805,6 +1965,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_adminsay_prefix", utf8String]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } [ConsoleCommand("css_psay", "Private message a player.")] @@ -1825,6 +1990,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig { player.PrintToChat(Helper.ReplaceTags($"({caller!.PlayerName}) {utf8String}")); + if(Config.DiscordWebhook.Length > 0) + _ = SendWebhookMessage($"PSAY: {caller!.PlayerName} --> {player!.PlayerName}: {utf8String}"); }); command.ReplyToCommand(Helper.ReplaceTags($" Private message sent!")); @@ -1839,6 +2006,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"CSAY: {caller!.PlayerName}: {utf8String}"); } [ConsoleCommand("css_hsay", "Say to all players (in hud).")] @@ -1853,6 +2022,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"HSAY: {caller!.PlayerName}: {utf8String}"); } [ConsoleCommand("css_noclip", "Noclip a player.")] @@ -1874,6 +2046,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } }); @@ -1904,6 +2081,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } } }); @@ -1926,6 +2108,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_unfreeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } }); } @@ -1942,7 +2129,10 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig(player.Handle, + GameData.GetOffset("CCSPlayerController_Respawn"))(player); if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId)) { @@ -1950,6 +2140,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + { + LocalizedString localizedMessage = _localizer["sa_admin_respawn_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]; + _ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", "")); + } } }); } @@ -1980,6 +2176,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"{playerName} changed cvar {cvar.Name} to {value}."); } [ConsoleCommand("css_rcon", "Run a server console command.")] @@ -1991,6 +2189,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig 0) + _ = SendWebhookMessage($"{playerName} executed command ({command.ArgString})."); } private static TargetResult? GetTarget(CommandInfo command) @@ -2029,4 +2229,20 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig + diff --git a/Config.cs b/Config.cs index 73b1a07..b1e59dc 100644 --- a/Config.cs +++ b/Config.cs @@ -5,7 +5,7 @@ namespace CS2_SimpleAdmin { public class CS2_SimpleAdminConfig : BasePluginConfig { - public override int Version { get; set; } = 3; + public override int Version { get; set; } = 4; [JsonPropertyName("DatabaseHost")] public string DatabaseHost { get; set; } = ""; @@ -31,5 +31,8 @@ namespace CS2_SimpleAdmin [JsonPropertyName("BanType")] public int BanType { get; set; } = 1; + [JsonPropertyName("DiscordWebhook")] + public string DiscordWebhook { get; set; } = ""; + } } \ No newline at end of file From 4e597d73a56131e0897b8f3ba646529f6122c28d Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Thu, 1 Feb 2024 00:03:34 +0100 Subject: [PATCH 2/4] Small changes - Correct version - Null warnings --- CS2-SimpleAdmin.cs | 119 ++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index a6f5896..f040673 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -271,14 +271,14 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig