54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
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();
|
|
}
|
|
});
|
|
}
|
|
} |