Added ExecuteOnClient option on custom commands

This commit is contained in:
Valentin Barat
2024-03-13 11:46:09 +01:00
parent ac940259f7
commit 60c76562f9
2 changed files with 11 additions and 2 deletions

View File

@@ -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

View File

@@ -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)