Beispiel #1
0
        bool HandleIRCCommand(string nick, string userNick, string cmdName, string cmdArgs)
        {
            Command cmd = Command.all.Find(cmdName);
            Player  p   = MakeIRCPlayer(nick, userNick);

            if (cmd == null)
            {
                Player.Message(p, "Unknown command!"); return(false);
            }

            string logCmd = cmdArgs == "" ? cmdName : cmdName + " " + cmdArgs;

            Server.s.Log("IRC Command: /" + logCmd + " (by " + userNick + ")");

            try {
                if (!p.group.CanExecute(cmd))
                {
                    cmd.MessageCannotUse(p); return(false);
                }
                cmd.Use(p, cmdArgs);
            } catch (Exception ex) {
                Player.Message(p, "CMD Error: " + ex);
            }
            return(true);
        }
Beispiel #2
0
        Command GetCommand(ref string cmd, ref string cmdArgs)
        {
            Command.Search(ref cmd, ref cmdArgs);

            byte bindIndex;

            if (byte.TryParse(cmd, out bindIndex) && bindIndex < 10)
            {
                if (messageBind[bindIndex] == null)
                {
                    SendMessage("No command is bound to: /" + cmd); return(null);
                }
                cmd     = cmdBind[bindIndex];
                cmdArgs = messageBind[bindIndex] + " " + cmdArgs;
                cmdArgs = cmdArgs.TrimEnd(' ');
            }

            if (OnCommand != null)
            {
                OnCommand(cmd, this, cmdArgs);
            }
            if (PlayerCommand != null)
            {
                PlayerCommand(cmd, this, cmdArgs);
            }
            OnPlayerCommandEvent.Call(cmd, this, cmdArgs);
            if (cancelcommand)
            {
                cancelcommand = false; return(null);
            }

            Command command = Command.all.Find(cmd);

            if (command == null)
            {
                if (Block.Byte(cmd) != Block.Invalid)
                {
                    cmdArgs = cmd.ToLower(); cmd = "mode";
                    command = Command.all.Find("mode");
                }
                else
                {
                    SendMessage("Unknown command \"" + cmd + "\"."); return(null);
                }
            }

            if (!group.CanExecute(command))
            {
                command.MessageCannotUse(this); return(null);
            }
            string reason = Command.GetDisabledReason(command.Enabled);

            if (reason != null)
            {
                SendMessage("Command is disabled as " + reason); return(null);
            }
            if (level.IsMuseum && !command.museumUsable)
            {
                SendMessage("Cannot use this command while in a museum."); return(null);
            }
            return(command);
        }