First commit
This commit is contained in:
60
commands/admin.cs
Normal file
60
commands/admin.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
54
commands/player.cs
Normal file
54
commands/player.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
|
||||
namespace Porning;
|
||||
|
||||
class PlayerCommands
|
||||
{
|
||||
private readonly BasePlugin plugin;
|
||||
|
||||
public PlayerCommands(BasePlugin pluginInstance)
|
||||
{
|
||||
plugin = pluginInstance;
|
||||
}
|
||||
|
||||
[CommandHelper(minArgs: 0, usage: "", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void onHelp(CCSPlayerController? player, CommandInfo commandInfo)
|
||||
{
|
||||
commandInfo.ReplyToCommand("/help: Show help");
|
||||
commandInfo.ReplyToCommand("/map: Change map");
|
||||
commandInfo.ReplyToCommand("/bhop: Toggle bhop");
|
||||
}
|
||||
|
||||
[CommandHelper(minArgs:0, usage: "[map]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void onMapVote(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;
|
||||
}
|
||||
|
||||
Vote vote = new Vote(plugin, $"Map vote: {map}", ["Yes", "No"]);
|
||||
vote.BeginVote();
|
||||
vote.OnEnd((best) =>
|
||||
{
|
||||
if (best == 0)
|
||||
{
|
||||
Info info = new Info(plugin, "Changing map!");
|
||||
info.Show();
|
||||
info.OnClose(() =>
|
||||
{
|
||||
Server.ExecuteCommand($"map {map}");
|
||||
});
|
||||
} else
|
||||
{
|
||||
Info info = new Info(plugin, "Not changing map!");
|
||||
info.Show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user