本文整理汇总了C#中CommandEventArgs.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# CommandEventArgs.Cancel方法的具体用法?C# CommandEventArgs.Cancel怎么用?C# CommandEventArgs.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandEventArgs
的用法示例。
在下文中一共展示了CommandEventArgs.Cancel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnAllPlayersCommand_Normal
void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs args) {
if (args.Command != "ag")
return;
args.Cancel();
if (args.Args.Length < 2) {
Help(sender);
return;
}
if (args.Args[0].ToLower() == "allow") {
Player who = Player.Find(args.Args[1]);
if (who == null || who is ConsolePlayer) {
sender.SendMessage("The specified player was not found");
return;
}
AllowList.AddValue<string, Player>(sender.Username, who);
return;
}
else if (args.Args[0].ToLower() == "disallow") {
Player who = Player.Find(args.Args[1]);
if (who == null || who is ConsolePlayer) {
sender.SendMessage("The specified player was not found");
return;
}
AllowList.RemoveValue<string, Player>(sender.Username, who);
return;
}
}
示例2: OnAllPlayersCommand_Normal
public void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs evt)
{
byte PerVisit = 0;
Level l = null;
ICommand cmdran = null;
try
{
cmdran = Command.All[evt.Command];
}
catch { cmdran = null; }
if (cmdran == null)
return; // no use running this unless it exists
else if (cmdran != Command.All["goto"])
return; //yet again, no use to run this if the command aint /goto or a variant
l = Level.FindLevel(evt.Args[0]);
if (l == null)
return;
try
{
PerVisit = (byte)l.Settings.pervisit;
}
catch
{
PerVisit = 0;
}
if (sender.Group.Permission <= PerVisit)
{
sender.SendMessage("You cannot visit this map!");
evt.Cancel();
}
}
示例3: OnCommand
public void OnCommand(Player sender, CommandEventArgs e)
{
ICommand cmd = null;
try
{
cmd = Command.All[e.Command];
}
catch
{
return;
}
byte perBuildMax = byte.MaxValue;
if (sender.Level.ExtraData.ContainsKey("perbuildmax"))
{
try
{
perBuildMax = (byte)sender.Level.ExtraData["perbuildmax"];
}
catch
{
perBuildMax = byte.MaxValue;
}
}
if (cmd == null) return;
if (cmd.Type == CommandTypes.Building && sender.Group.Permission > perBuildMax && sender.Group.CanExecute(cmd))
{
sender.SendMessage("You cannot use building commands on this level!");
e.Cancel();
}
}
示例4: OnCommand
//yay for being smart, instead of recoding the command just over-ride it
public void OnCommand(Player Player, CommandEventArgs args)
{
ExtraPlayerData TemporaryPlayer = FindPlayer(Player);
if (args.Command.ToLower() == "tp" || args.Command.ToLower() == "summon" || args.Command.ToLower() == "s")
{
if (!TemporaryPlayer.Referee)
{
Player.SendMessage("You need to be a referee to do that!");
args.Cancel();
return;
}
}
else if (args.Command.ToLower() == "rob" || args.Command.ToLower() == "run" || args.Command.ToLower() == "ascend"
|| args.Command.ToLower() == "bot" || args.Command.ToLower() == "test")
{
Player.SendMessage("Unknown command \"" + args.Command + "\"!");
args.Cancel();
return;
}
else if (args.Command.ToLower() == "spawn")
{
TemporaryPlayer.Spawning = true;
if (!TemporaryPlayer.Infected && ZombieRoundEnabled)
{
ZombieHelper.InfectPlayer(TemporaryPlayer);
ZombieHelper.DisplayInfectMessage(TemporaryPlayer.Player, null);
EndGame();
}
}
else
{
try
{
ICommand cmd = Command.Find(args.Command);
if (cmd.Type == CommandTypes.Building)
{
Player.SendMessage("Unknown command \"" + args.Command + "\"!");
args.Cancel();
return;
}
}
catch { }
}
}
示例5: OnCommand
public void OnCommand(Player sender, CommandEventArgs e)
{
ICommand cmd = null;
try
{
cmd = Command.All[e.Command];
}
catch
{
return;
}
byte perBuild = 0;
try
{
perBuild = (byte)sender.Level.Settings.perbuild;
}
catch
{
}
if (cmd == null) return;
if (cmd.Type == CommandTypes.Building && sender.Group.Permission < perBuild && sender.Group.CanExecute(cmd))
{
sender.SendMessage("You cannot use building commands on this level!");
e.Cancel();
}
}
示例6: OnAllPlayersCommand_Normal
public void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs evt)
{
byte PerVisitMax = byte.MaxValue;
Level l = null;
ICommand cmdran = null;
try
{
cmdran = Command.All[evt.Command];
}
catch { cmdran = null; }
if (cmdran == null)
return; // no use running this unless it exists
else if (cmdran != Command.All["goto"])
return; //yet again, no use to run this if the command aint /goto or a variant
l = Level.FindLevel(evt.Args[0]);
if (l.ExtraData.ContainsKey("pervisitmax"))
{
try
{
PerVisitMax = (byte)l.ExtraData["pervisitmax"];
}
catch
{
PerVisitMax = byte.MaxValue;
}
}
if (sender.Group.Permission >= PerVisitMax)
{
sender.SendMessage("You cannot visit this map!");
evt.Cancel();
}
}
示例7: OnAllPlayersCommand_Normal
public void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs evt)
{
byte PerVisitMax = byte.MaxValue;
Level l = null;
ICommand cmdran = null;
try
{
cmdran = Command.All[evt.Command];
}
catch { cmdran = null; }
if (cmdran == null || cmdran != Command.All["goto"])
return; // no use running this unless it exists
l = Level.FindLevel(evt.Args[0]);
if (l == null && Level.UnloadedLevels.TrueForAll((s) => { return !s.ToLower().Contains(evt.Args[0].ToLower()); })) {
cmdran.Use(sender, evt.Args);
return;
}
if (l != null && l.ExtraData.ContainsKey("pervisitmax")) {
try {
PerVisitMax = (byte)l.ExtraData["pervisitmax"];
}
catch {
PerVisitMax = byte.MaxValue;
}
}
if (sender.Group.Permission >= PerVisitMax)
{
sender.SendMessage("You cannot visit this map!");
evt.Cancel();
}
}
示例8: OnAllPlayersCommand_SystemLvl
static void OnAllPlayersCommand_SystemLvl(Player sender, CommandEventArgs args)
{
if (sender.Group.Permission >= (byte)PermissionLevel.Operator) {
if (args.Command.ToLower() == "update") {
if (cmdupdate || plugupdate || coreupdate)
ManualUpdate(sender);
else
sender.SendMessage("No updates are ready for install..");
args.Cancel();
}
}
}