public static void Register(string command, AccessLevels access, CommandEventHandler handler) { m_Entries[command] = new CommandEntry(command, handler, access, Server.Scripts.Commands.TargetType.None); }
public static bool Handle(Character ch, Mobile target, string text, bool isempl) { if (text.StartsWith(".")) { text = text.Substring(1); int indexOf = text.IndexOf(' '); string command; string[] args; string argString; if (indexOf >= 0) { argString = text.Substring(indexOf + 1); command = text.Substring(0, indexOf); args = Split(argString); } else { argString = ""; command = text.ToLower(); args = new string[0]; } CommandEntry entry = (CommandEntry)m_Entries[command]; if (entry != null) { if (ch.Player.AccessLevel >= entry.AccessLevel) { if (entry.Handler != null) { CommandEventArgs e = new CommandEventArgs(ch, target, command, argString, args, entry.TargetType, isempl, entry.AccessLevel); if ((entry.TargetType != Server.Scripts.Commands.TargetType.None) && (e.Target == null)) { ch.SendMessage("You must sellect target first."); return(false); } else if ((entry.TargetType == Server.Scripts.Commands.TargetType.PlayerOnly) && !(e.Target is Character)) { ch.SendMessage("Target must be a Player."); return(false); } else if ((entry.TargetType == Server.Scripts.Commands.TargetType.CreatureOnly) && !(e.Target is BaseCreature)) { ch.SendMessage("Target must be a Creature."); return(false); } else { bool isOK = entry.Handler(e); EventSink.InvokeCommand(e); return(isOK); } } else { return(false); } } else { if (ch.Player.AccessLevel <= m_BadCommandIngoreLevel) { return(false); } ch.SendMessage("You do not have access to that command."); } } else { ch.SendMessage("Command " + command + " dont exist."); return(false); } } return(false); }
public static void Register(string command, AccessLevels access, CommandEventHandler handler, TargetType targ) { m_Entries[command] = new CommandEntry(command, handler, access, targ); }