60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using CounterStrikeSharp.API;
|
|
using CounterStrikeSharp.API.Core;
|
|
using CounterStrikeSharp.API.Modules.Admin;
|
|
using CounterStrikeSharp.API.Modules.Commands;
|
|
using CounterStrikeSharp.API.Modules.Cvars;
|
|
|
|
namespace Porning;
|
|
|
|
class AdminCommands
|
|
{
|
|
private readonly BasePlugin plugin;
|
|
|
|
public AdminCommands(BasePlugin pluginInstance)
|
|
{
|
|
plugin = pluginInstance;
|
|
}
|
|
private ConVar autoBhopCvar = ConVar.Find("sv_autobunnyhopping")!;
|
|
|
|
[CommandHelper(minArgs: 1, usage: "[map_name]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
|
[RequiresPermissions("@porning/admin")]
|
|
public void onMap(CCSPlayerController? player, CommandInfo commandInfo)
|
|
{
|
|
string map = commandInfo.GetArg(1);
|
|
if (!Server.IsMapValid(map))
|
|
{
|
|
Info info = new Info(plugin, "Map not recognised.");
|
|
info.Show(player);
|
|
return;
|
|
}
|
|
Server.ExecuteCommand($"map {map}");
|
|
}
|
|
|
|
[CommandHelper(minArgs: 0, usage: "[0/1]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
|
[RequiresPermissions("@porning/admin")]
|
|
public void onBhop(CCSPlayerController? player, CommandInfo commandInfo)
|
|
{
|
|
Info info;
|
|
if (commandInfo.ArgCount == 1)
|
|
{
|
|
bool autoBhop = autoBhopCvar.GetPrimitiveValue<bool>();
|
|
Server.ExecuteCommand($"sv_autobunnyhopping {!autoBhop}");
|
|
info = new Info(plugin, $"Toggled bhop: {!autoBhop}");
|
|
info.Show(player);
|
|
return;
|
|
}
|
|
string bhop = commandInfo.GetArg(1);
|
|
Server.ExecuteCommand($"sv_autobunnyhopping {bhop}");
|
|
info = new Info(plugin, $"Toggled bhop: {bhop}");
|
|
info.Show(player);
|
|
}
|
|
|
|
[CommandHelper(minArgs: 1, usage: "[message]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
|
[RequiresPermissions("@porning/admin")]
|
|
public void onInfo(CCSPlayerController? player, CommandInfo commandInfo)
|
|
{
|
|
string message = commandInfo.GetCommandString.Substring(9);
|
|
Info info = new Info(plugin, message);
|
|
info.Show();
|
|
}
|
|
} |