Очень важная консольная команда.
This commit is contained in:
49
Content.Server/White/Commands/PoshelnahuiCommand.cs
Normal file
49
Content.Server/White/Commands/PoshelnahuiCommand.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Administration;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
|
namespace Content.Server.White.Commands;
|
||||||
|
|
||||||
|
[AdminCommand(AdminFlags.Admin)]
|
||||||
|
public sealed class PoshelnahuiCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "poshelnahui";
|
||||||
|
public string Description => "Close client game lol";
|
||||||
|
public string Help => "poshelnahui <ckey>";
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length != 1 || string.IsNullOrEmpty(args[0]))
|
||||||
|
{
|
||||||
|
shell.WriteLine("Wrong number of arguments");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||||
|
var players = playerManager.ServerSessions.ToList();
|
||||||
|
|
||||||
|
var player = players.Find(x => x.Name == args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
shell.WriteLine("Player not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var consoleHost = IoCManager.Resolve<IConsoleHost>();
|
||||||
|
consoleHost.RemoteExecuteCommand(player, "hardquit");
|
||||||
|
shell.WriteLine("Message sent");
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) {
|
||||||
|
if (args.Length == 1)
|
||||||
|
{
|
||||||
|
var playerMgr = IoCManager.Resolve<IPlayerManager>();
|
||||||
|
var options = playerMgr.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray();
|
||||||
|
return CompletionResult.FromHintOptions(options, "ckey");
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompletionResult.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user