v1.7.8-alpha

feat: re-add `css_fexec` used for css-panel skins module
feat: Add KitsuneMenu & Remove MenuManager
update: Added StatusBlocker by @Slynx support to hide stealth admin from status
This commit is contained in:
Sachin 2025-09-25 01:20:57 +05:30
parent 1118939e62
commit a10a33edfd
36 changed files with 1055 additions and 722 deletions

View file

@ -2,6 +2,8 @@ using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Entities;
using Menu;
using Menu.Enums;
namespace CS2_SimpleAdmin.Menus;
@ -9,43 +11,50 @@ public static class CustomCommandsMenu
{
public static void OpenMenu(CCSPlayerController admin)
{
if (admin.IsValid == false)
return;
if (!admin.IsValid) return;
var localizer = CS2_SimpleAdmin._localizer;
if (AdminManager.PlayerHasPermissions(new SteamID(admin.SteamID), "@css/generic") == false)
if (!AdminManager.PlayerHasPermissions(new SteamID(admin.SteamID), "@css/generic"))
{
admin.PrintToChat(localizer?["sa_prefix"] ??
"[SimpleAdmin] " +
(localizer?["sa_no_permission"] ?? "You do not have permissions to use this command")
);
admin.PrintToChat(localizer?["sa_prefix"] ?? "[SimpleAdmin] " +
(localizer?["sa_no_permission"] ?? "You do not have permissions to use this command"));
return;
}
var menu = AdminMenu.CreateMenu(localizer?["sa_menu_custom_commands"] ?? "Custom Commands");
List<ChatMenuOptionData> options = [];
var customCommands = CS2_SimpleAdmin.Instance.Config.CustomServerCommands
.Where(c => !string.IsNullOrEmpty(c.DisplayName) && !string.IsNullOrEmpty(c.Command))
.Where(c => AdminManager.PlayerHasPermissions(new SteamID(admin.SteamID), c.Flag))
.ToList();
var customCommands = CS2_SimpleAdmin.Instance.Config.CustomServerCommands;
options.AddRange(from customCommand in customCommands
where !string.IsNullOrEmpty(customCommand.DisplayName) && !string.IsNullOrEmpty(customCommand.Command)
let hasRights = AdminManager.PlayerHasPermissions(new SteamID(admin.SteamID), customCommand.Flag)
where hasRights
select new ChatMenuOptionData(customCommand.DisplayName, () =>
{
Helper.TryLogCommandOnDiscord(admin, customCommand.Command);
if (customCommands.Count == 0) return;
if (customCommand.ExecuteOnClient)
admin.ExecuteClientCommandFromServer(customCommand.Command);
else
Server.ExecuteCommand(customCommand.Command);
}));
foreach (var menuOptionData in options)
var items = new List<MenuItem>();
for (int i = 0; i < customCommands.Count; i++)
{
var menuName = menuOptionData.Name;
menu?.AddMenuOption(menuName, (_, _) => { menuOptionData.Action(); }, menuOptionData.Disabled);
var cmd = customCommands[i];
items.Add(new MenuItem(MenuItemType.Button, [new MenuValue(cmd.DisplayName)]));
}
if (menu != null) AdminMenu.OpenMenu(admin, menu);
CS2_SimpleAdmin.Menu?.ShowScrollableMenu(
admin,
localizer?["sa_menu_custom_commands"] ?? "Custom Commands",
items,
(buttons, menu, selected) =>
{
if (selected == null) return;
if (buttons == MenuButtons.Select && selected.Option >= 0 && selected.Option < customCommands.Count)
{
var cmd = customCommands[selected.Option];
Helper.TryLogCommandOnDiscord(admin, cmd.Command);
if (cmd.ExecuteOnClient)
admin.ExecuteClientCommandFromServer(cmd.Command);
else
Server.ExecuteCommand(cmd.Command);
}
},
true,
freezePlayer: false,
disableDeveloper: true);
}
}