diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index 7011eb4..8aebbe1 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -22,7 +22,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "CS2-SimpleAdmin"; public override string ModuleDescription => ""; public override string ModuleAuthor => "daffyy"; - public override string ModuleVersion => "1.0.5"; + public override string ModuleVersion => "1.0.5a"; public CS2_SimpleAdminConfig Config { get; set; } = new(); @@ -32,6 +32,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig")] + [RequiresPermissions("@css/chat")] + public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command) + { + if (caller == null || !caller.IsValid || command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return; + if (command.GetCommandString[command.GetCommandString.IndexOf(' ')..].StartsWith("@")) + { + foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat"))) + { + p.PrintToChat($" {ChatColors.Lime}(ADMIN) {ChatColors.Default}{caller.PlayerName}: {command.GetCommandString[command.GetCommandString.IndexOf(' ')..]}"); + } + } + } + [ConsoleCommand("css_say", "Say to all players.")] [CommandHelper(1, "")] [RequiresPermissions("@css/chat")] diff --git a/Events.cs b/Events.cs index 08e3448..9cd1dc1 100644 --- a/Events.cs +++ b/Events.cs @@ -1,7 +1,9 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Admin; using CounterStrikeSharp.API.Modules.Commands; using CounterStrikeSharp.API.Modules.Entities; +using CounterStrikeSharp.API.Modules.Utils; using static CounterStrikeSharp.API.Core.Listeners; namespace CS2_SimpleAdmin @@ -26,6 +28,14 @@ namespace CS2_SimpleAdmin return HookResult.Handled; } + if (info.GetArg(1).StartsWith("@") && AdminManager.PlayerHasPermissions(player, "@css/chat")) + { + foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat"))) + { + p.PrintToChat($" {ChatColors.Lime}(ADMIN) {ChatColors.Default}{player.PlayerName}: {info.GetArg(1)}"); + } + } + return HookResult.Continue; } diff --git a/README.md b/README.md index 17333c7..083d7d1 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ It's only plugin base, I don't have much time for more extensive development, so - css_team <#userid or name> [] - Change player team // @css/kick - css_map - Change map // @css/changemap - css_wsmap - Change workshop map // @css/changemap +- css_asay - Say message to all admins // @css/chat - css_say - Say message as admin in chat // @css/chat - css_psay <#userid or name> - Sends private message to player // @css/chat - css_csay - Say message as admin in center // @css/chat @@ -32,6 +33,8 @@ It's only plugin base, I don't have much time for more extensive development, so - css_respawn <#userid or name> - Respawn player // @css/cheats - css_cvar - Change cvar value // @css/cvar - css_rcon - Run command as server // @css/rcon + +- @Message - Say message to all admins // @css/chat ``` ### Requirments