From 60c76562f9c7e85343481fcb52773bc00777e596 Mon Sep 17 00:00:00 2001 From: Valentin Barat Date: Wed, 13 Mar 2024 11:46:09 +0100 Subject: [PATCH] Added ExecuteOnClient option on custom commands --- Config.cs | 3 +++ Menus/CustomCommandsMenu.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Config.cs b/Config.cs index 5b83208..5f07dc7 100644 --- a/Config.cs +++ b/Config.cs @@ -22,6 +22,9 @@ namespace CS2_SimpleAdmin [JsonPropertyName("Command")] public string Command { get; set; } = ""; + + [JsonPropertyName("ExecuteOnClient")] + public bool ExecuteOnClient { get; set; } = false; } public class CS2_SimpleAdminConfig : BasePluginConfig diff --git a/Menus/CustomCommandsMenu.cs b/Menus/CustomCommandsMenu.cs index 6d0805c..58ebe67 100644 --- a/Menus/CustomCommandsMenu.cs +++ b/Menus/CustomCommandsMenu.cs @@ -31,8 +31,14 @@ namespace CS2_SimpleAdmin.Menus bool hasRights = AdminManager.PlayerHasPermissions(admin, customCommand.Flag); if (!hasRights) continue; - - options.Add(new ChatMenuOptionData(customCommand.DisplayName, () => Server.ExecuteCommand(customCommand.Command))); + + options.Add(new ChatMenuOptionData(customCommand.DisplayName, () => + { + if (customCommand.ExecuteOnClient) + admin.ExecuteClientCommand(customCommand.Command); + else + Server.ExecuteCommand(customCommand.Command); + })); } foreach (ChatMenuOptionData menuOptionData in options)