mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 10:31:01 +00:00
```diff
+ `Refactored Code`: Improved code structure for better maintainability.
+ `Player Penalties Command`: Introduced the `css_penalties` command to display player penalties.
+ `Admin Penalties Information`: Added functionality to provide information for admins regarding penalties of connecting players.
+ `Disconnected Players Command`: Added the `css_disconnected` command to show a list of disconnected players.
+ `Colorful Messages`: Implemented the `css_cssay` command to send colorful messages, e.g., `css_cssay {lightgreen}Test`.
+ `Respawn Functionality`: Updated the `css_respawn` command to respawn players at their death location.
+ `Menu Type Management`: Introduced the `css_menus` command to change the menu type via `MenuManagerCS2`.
+ `Dynamic Menu Control`: Enhanced menu interaction with dynamic controls using WASD + ER keys.
+ `Language File Updates`: Updated language files for better localization.
+ `API Integration`: Added a simple API for external interaction.
+ `Configurable Timezone`: Introduced timezone settings in the configuration.
+ `Admin Activity Display Options`: Added configurable settings for displaying admin activity:
+ `0`: Do not show
+ `1`: Hide admin name
+ `2`: Show admin name
+ `Discord Notification Customization`: Made Discord duration notifications customizable with `{relative}` and `{normal}` placeholders.
+ Improved command logging
+
`Configuration Options:`
+ `Timezone`
+ `Other Settings`
+ `Disconnected Players History Count`
+ `Show Activity Type`
```
50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using CounterStrikeSharp.API;
|
|
using CounterStrikeSharp.API.Core;
|
|
using CounterStrikeSharp.API.Modules.Admin;
|
|
|
|
namespace CS2_SimpleAdmin.Menus;
|
|
|
|
public static class CustomCommandsMenu
|
|
{
|
|
public static void OpenMenu(CCSPlayerController admin)
|
|
{
|
|
if (admin.IsValid == false)
|
|
return;
|
|
|
|
var localizer = CS2_SimpleAdmin._localizer;
|
|
if (AdminManager.PlayerHasPermissions(admin, "@css/generic") == false)
|
|
{
|
|
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;
|
|
options.AddRange(from customCommand in customCommands
|
|
where !string.IsNullOrEmpty(customCommand.DisplayName) && !string.IsNullOrEmpty(customCommand.Command)
|
|
let hasRights = AdminManager.PlayerHasPermissions(admin, customCommand.Flag)
|
|
where hasRights
|
|
select new ChatMenuOptionData(customCommand.DisplayName, () =>
|
|
{
|
|
Helper.TryLogCommandOnDiscord(admin, customCommand.Command);
|
|
|
|
if (customCommand.ExecuteOnClient)
|
|
admin.ExecuteClientCommandFromServer(customCommand.Command);
|
|
else
|
|
Server.ExecuteCommand(customCommand.Command);
|
|
}));
|
|
|
|
foreach (var menuOptionData in options)
|
|
{
|
|
var menuName = menuOptionData.Name;
|
|
menu?.AddMenuOption(menuName, (_, _) => { menuOptionData.Action(); }, menuOptionData.Disabled);
|
|
}
|
|
|
|
if (menu != null) AdminMenu.OpenMenu(admin, menu);
|
|
}
|
|
} |