cs2-SimpleAdmin/CS2-SimpleAdmin/Commands/funcommands.cs
Salvatore 460d8b2b85 Migrate menus and votes to Panorama UI Kit
Replace MenuManagerCS2 with Panorama UI Kit for the admin menus and
css_vote. Layout names (menu, vote, banner, toast) are configurable
under MenuConfig and preloaded on startup; MenuType is removed and
ConfigVersion bumped to 26.

- Drop MenuManagerApi.dll and the old chat menu classes
- Reference PanoramaUiKit.Shared.dll, bump CounterStrikeSharp to 1.0.376
- Add .editorconfig and CODING_CONVENTIONS.md, apply them codebase-wide
- Remove the CS2-SimpleAdmin-docs site
- Rewrite README for the fork
2026-10-21 18:51:18 +02:00

307 lines
13 KiB
C#

// using System.Globalization;
// using CounterStrikeSharp.API;
// using CounterStrikeSharp.API.Core;
// using CounterStrikeSharp.API.Modules.Admin;
// using CounterStrikeSharp.API.Modules.Commands;
//
// namespace CS2_SimpleAdmin;
//
// public partial class CS2_SimpleAdmin
// {
// /// <summary>
// /// Enables or disables no-clip mode for specified player(s).
// /// </summary>
// /// <param name="caller">The player issuing the command.</param>
// /// <param name="command">The command input containing targets.</param>
// [CommandHelper(1, "<#userid or name>")]
// [RequiresPermissions("@css/cheats")]
// public void OnNoclipCommand(CCSPlayerController? caller, CommandInfo command)
// {
// var callerName = caller == null ? _localizer?["sa_console"] ?? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
//
// var targets = GetTarget(command);
// if (targets == null) return;
// var playersToTarget = targets.Players.Where(player =>
// player.IsValid &&
// player is { IsHLTV: false, Connected: PlayerConnectedState.PlayerConnected, PlayerPawn.Value.LifeState: (int)LifeState_t.LIFE_ALIVE }).ToList();
//
// playersToTarget.ForEach(player =>
// {
// if (caller!.CanTarget(player))
// {
// NoClip(caller, player, callerName);
// }
// });
//
// Helper.LogCommand(caller, command);
// }
//
// /// <summary>
// /// Toggles no-clip mode for a player and shows admin activity messages.
// /// </summary>
// /// <param name="caller">The player/admin toggling no-clip.</param>
// /// <param name="player">The target player whose no-clip state changes.</param>
// /// <param name="callerName">Optional caller name for messages.</param>
// /// <param name="command">Optional command info for logging.</param>
// internal static void NoClip(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
// {
// if (!player.IsValid) return;
// if (!caller.CanTarget(player)) return;
//
// // Set default caller name if not provided
// callerName ??= Helper.GetCallerName(caller);
//
// // Toggle no-clip mode for the player
// player.Pawn.Value?.ToggleNoclip();
//
// // Determine message keys and arguments for the no-clip notification
// var (activityMessageKey, adminActivityArgs) =
// ("sa_admin_noclip_message",
// new object[] { "CALLER", player.PlayerName });
//
// // Display admin activity message to other players
// if (caller == null || !SilentPlayers.Contains(caller.Slot))
// {
// Helper.ShowAdminActivity(activityMessageKey, callerName, false, adminActivityArgs);
// }
//
// // Log the command
// if (command == null)
// Helper.LogCommand(caller, $"css_noclip {Helper.GetLogName(player)}");
// }
//
// /// <summary>
// /// Enables or disables god mode for specified player(s).
// /// </summary>
// /// <param name="caller">The player issuing the command.</param>
// /// <param name="command">The command input containing targets.</param>
//
// [RequiresPermissions("@css/cheats")]
// [CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
// public void OnGodCommand(CCSPlayerController? caller, CommandInfo command)
// {
// var callerName = Helper.GetCallerName(caller);
// var targets = GetTarget(command);
// if (targets == null) return;
//
// var playersToTarget = targets.Players.Where(player => player.IsValid && player is {IsHLTV: false, PlayerPawn.Value.LifeState: (int)LifeState_t.LIFE_ALIVE }).ToList();
//
// playersToTarget.ForEach(player =>
// {
// if (player.Connected != PlayerConnectedState.PlayerConnected)
// return;
//
// if (caller!.CanTarget(player))
// {
// God(caller, player, command);
// }
// });
//
// Helper.LogCommand(caller, command);
// }
//
// /// <summary>
// /// Toggles god mode for a player and notifies admins.
// /// </summary>
// /// <param name="caller">The player/admin toggling god mode.</param>
// /// <param name="player">The target player whose god mode changes.</param>
// /// <param name="command">Optional command info for logging.</param>
// internal static void God(CCSPlayerController? caller, CCSPlayerController player, CommandInfo? command = null)
// {
// if (!caller.CanTarget(player)) return;
//
// // Set default caller name if not provided
// var callerName = Helper.GetCallerName(caller);
//
// // Toggle god mode for the player
// if (!GodPlayers.Add(player.Slot))
// {
// GodPlayers.Remove(player.Slot);
// }
//
// // Log the command
// if (command == null)
// Helper.LogCommand(caller, $"css_god {Helper.GetLogName(player)}");
//
// // Determine message key and arguments for the god mode notification
// var (activityMessageKey, adminActivityArgs) =
// ("sa_admin_god_message",
// new object[] { "CALLER", player.PlayerName });
//
// // Display admin activity message to other players
// if (caller == null || !SilentPlayers.Contains(caller.Slot))
// {
// Helper.ShowAdminActivity(activityMessageKey, callerName, false, adminActivityArgs);
// }
// }
//
// /// <summary>
// /// Freezes target player(s) for an optional specified duration.
// /// </summary>
// /// <param name="caller">The player issuing the freeze command.</param>
// /// <param name="command">The command input containing targets and duration.</param>
// [CommandHelper(1, "<#userid or name> [duration]")]
// [RequiresPermissions("@css/slay")]
// public void OnFreezeCommand(CCSPlayerController? caller, CommandInfo command)
// {
// var callerName = Helper.GetCallerName(caller);
// int.TryParse(command.GetArg(2), out var time);
//
// var targets = GetTarget(command);
// if (targets == null) return;
// var playersToTarget = targets.Players.Where(player => player is { IsValid: true, IsHLTV: false, PlayerPawn.Value.LifeState: (int)LifeState_t.LIFE_ALIVE }).ToList();
//
// playersToTarget.ForEach(player =>
// {
// if (caller!.CanTarget(player))
// {
// Freeze(caller, player, time, callerName, command);
// }
// });
//
// Helper.LogCommand(caller, command);
// }
//
// /// <summary>
// /// Resizes the target player(s) models to a specified scale.
// /// </summary>
// /// <param name="caller">The player issuing the resize command.</param>
// /// <param name="command">The command input containing targets and scale factor.</param>
// [CommandHelper(1, "<#userid or name> [size]")]
// [RequiresPermissions("@css/slay")]
// public void OnResizeCommand(CCSPlayerController? caller, CommandInfo command)
// {
// var callerName = Helper.GetCallerName(caller);
// float.TryParse(command.GetArg(2), NumberStyles.Float, CultureInfo.InvariantCulture, out var size);
//
// var targets = GetTarget(command);
// if (targets == null) return;
// var playersToTarget = targets.Players.Where(player => player is { IsValid: true, IsHLTV: false, PlayerPawn.Value.LifeState: (int)LifeState_t.LIFE_ALIVE }).ToList();
//
// playersToTarget.ForEach(player =>
// {
// if (!caller!.CanTarget(player)) return;
//
// var sceneNode = player.PlayerPawn.Value!.CBodyComponent?.SceneNode;
// if (sceneNode == null) return;
//
// sceneNode.GetSkeletonInstance().Scale = size;
// player.PlayerPawn.Value.AcceptInput("SetScale", null, null, size.ToString(CultureInfo.InvariantCulture));
//
// Server.NextWorldUpdate(() =>
// {
// Utilities.SetStateChanged(player.PlayerPawn.Value, "CBaseEntity", "m_CBodyComponent");
// });
//
// var (activityMessageKey, adminActivityArgs) =
// ("sa_admin_resize_message",
// new object[] { "CALLER", player.PlayerName });
//
// // Display admin activity message to other players
// if (caller == null || !SilentPlayers.Contains(caller.Slot))
// {
// Helper.ShowAdminActivity(activityMessageKey, callerName, false, adminActivityArgs);
// }
// });
//
// Helper.LogCommand(caller, command);
// }
//
// /// <summary>
// /// Freezes a single player and optionally schedules automatic unfreeze after a duration.
// /// </summary>
// /// <param name="caller">The player/admin freezing the player.</param>
// /// <param name="player">The player to freeze.</param>
// /// <param name="time">Duration of freeze in seconds.</param>
// /// <param name="callerName">Optional name for notifications.</param>
// /// <param name="command">Optional command info for logging.</param>
// internal static void Freeze(CCSPlayerController? caller, CCSPlayerController player, int time, string? callerName = null, CommandInfo? command = null)
// {
// if (!player.IsValid) return;
// if (!caller.CanTarget(player)) return;
//
// // Set default caller name if not provided
// callerName ??= Helper.GetCallerName(caller);
//
// // Freeze player pawn
// player.Pawn.Value?.Freeze();
//
// // Determine message keys and arguments for the freeze notification
// var (activityMessageKey, adminActivityArgs) =
// ("sa_admin_freeze_message",
// new object[] { "CALLER", player.PlayerName });
//
// // Display admin activity message to other players
// if (caller == null || !SilentPlayers.Contains(caller.Slot))
// {
// Helper.ShowAdminActivity(activityMessageKey, callerName, false, adminActivityArgs);
// }
//
// // Schedule unfreeze for the player if time is specified
// if (time > 0)
// {
// Instance.AddTimer(time, () => player.Pawn.Value?.Unfreeze(), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
// }
//
// // Log the command and send Discord notification
// if (command == null)
// Helper.LogCommand(caller, $"css_freeze {Helper.GetLogName(player)} {time}");
// }
//
// /// <summary>
// /// Unfreezes target player(s).
// /// </summary>
// /// <param name="caller">The player issuing the unfreeze command.</param>
// /// <param name="command">The command input with targets.</param>
// [CommandHelper(1, "<#userid or name>")]
// [RequiresPermissions("@css/slay")]
// public void OnUnfreezeCommand(CCSPlayerController? caller, CommandInfo command)
// {
// var callerName = Helper.GetCallerName(caller);
//
// var targets = GetTarget(command);
// if (targets == null) return;
// var playersToTarget = targets.Players.Where(player => player is { IsValid: true, IsHLTV: false, PlayerPawn.Value.LifeState: (int)LifeState_t.LIFE_ALIVE }).ToList();
//
// playersToTarget.ForEach(player =>
// {
// Unfreeze(caller, player, callerName, command);
// });
//
// Helper.LogCommand(caller, command);
// }
//
// /// <summary>
// /// Unfreezes a single player and notifies admins.
// /// </summary>
// /// <param name="caller">The player/admin unfreezing the player.</param>
// /// <param name="player">The player to unfreeze.</param>
// /// <param name="callerName">Optional name for notifications.</param>
// /// <param name="command">Optional command info for logging.</param>
// internal static void Unfreeze(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
// {
// if (!player.IsValid) return;
// if (!caller.CanTarget(player)) return;
//
// // Set default caller name if not provided
// callerName ??= Helper.GetCallerName(caller);
//
// // Unfreeze player pawn
// player.Pawn.Value?.Unfreeze();
//
// // Determine message keys and arguments for the unfreeze notification
// var (activityMessageKey, adminActivityArgs) =
// ("sa_admin_unfreeze_message",
// new object[] { "CALLER", player.PlayerName });
//
// // Display admin activity message to other players
// if (caller == null || !SilentPlayers.Contains(caller.Slot))
// {
// Helper.ShowAdminActivity(activityMessageKey, callerName, false, adminActivityArgs);
// }
//
// // Log the command and send Discord notification
// if (command == null)
// Helper.LogCommand(caller, $"css_unfreeze {Helper.GetLogName(player)}");
// }
// }