Example #1
0
        public override bool ValidateArgs(BaseCommandImplementor impl, Server.Commands.CommandEventArgs e)
        {
            if (e.Length >= 1)
            {
                Type t = ScriptCompiler.FindTypeByName(e.GetString(0));

                if (t == null)
                {
                    e.Mobile.SendMessage("No type with that name was found.");

                    string match = e.GetString(0).Trim();

                    if (match.Length < 3)
                    {
                        e.Mobile.SendMessage("Invalid search string.");
                        e.Mobile.SendGump(new Server.Gumps.AddGump(e.Mobile, match, 0, Type.EmptyTypes, false));
                    }
                    else
                    {
                        e.Mobile.SendGump(new Server.Gumps.AddGump(e.Mobile, match, 0, (Type[])Server.Gumps.AddGump.Match(match).ToArray(typeof(Type)), true));
                    }
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                e.Mobile.SendGump(new Server.Gumps.CategorizedAddGump(e.Mobile));
            }

            return(false);
        }
Example #2
0
        public static void FindByName_OnCommand(Server.Commands.CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                string name = e.GetString(0).ToLower();

                foreach (Item item in World.Items.Values)
                {
                    if (item.Name != null && item.Name.ToLower().IndexOf(name) >= 0)
                    {
                        object root = item.RootParent;

                        if (root is Mobile)
                        {
                            e.Mobile.SendAsciiMessage("{0} [{1}]: {2} ({3})", item.GetWorldLocation(), item.Map, root.GetType().Name, ((Mobile)root).Name);
                        }
                        else
                        {
                            e.Mobile.SendAsciiMessage("{0} [{1}]: {2}", item.GetWorldLocation(), item.Map, root == null ? "(null)" : root.GetType().Name);
                        }
                    }
                }
            }
            else
            {
                e.Mobile.SendAsciiMessage("Format: FindByName <name>");
            }
        }
Example #3
0
        public override void Execute(Server.Commands.CommandEventArgs e, object obj)
        {
            if (e.Length == 1)
            {
                Mobile mob  = (Mobile)obj;
                Mobile from = e.Mobile;

                if (mob.Player)
                {
                    NetState ns = mob.NetState;

                    if (ns == null)
                    {
                        LogFailure("That player is not online.");
                    }
                    else
                    {
                        string url = e.GetString(0);

                        CommandLogging.WriteLine(from, "{0} {1} requesting to open web browser of {2} to {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(mob), url);
                        AddResponse("Awaiting user confirmation...");
                        mob.SendGump(new WarningGump(1060637, 30720, String.Format("A game master is requesting to open your web browser to the following URL:<br>{0}", url), 0xFFC000, 320, 240, new WarningGumpCallback(OpenBrowser_Callback), new object[] { from, url }));
                    }
                }
                else
                {
                    LogFailure("That is not a player.");
                }
            }
            else
            {
                LogFailure("Format: OpenBrowser <url>");
            }
        }
Example #4
0
        public virtual void Execute(Server.Commands.CommandEventArgs e)
        {
            if (e.Length >= 1)
            {
                BaseCommand command = (BaseCommand)m_Commands[e.GetString(0)];

                if (command == null)
                {
                    e.Mobile.SendMessage("That is either an invalid command name or one that does not support this modifier.");
                }
                else if (e.Mobile.AccessLevel < command.AccessLevel)
                {
                    e.Mobile.SendMessage("You do not have access to that command.");
                }
                else
                {
                    string[] oldArgs = e.Arguments;
                    string[] args    = new string[oldArgs.Length - 1];

                    for (int i = 0; i < args.Length; ++i)
                    {
                        args[i] = oldArgs[i + 1];
                    }

                    Process(e.Mobile, command, args);
                }
            }
            else
            {
                e.Mobile.SendMessage("You must supply a command name.");
            }
        }
Example #5
0
 public static void SetSkill_OnCommand(Server.Commands.CommandEventArgs arg)
 {
     if (arg.Length != 2)
     {
         arg.Mobile.SendMessage("SetSkill <skill name> <value>");
     }
     else
     {
         SkillName skill;
         try
         {
             skill = (SkillName)Enum.Parse(typeof(SkillName), arg.GetString(0), true);
         }
         catch
         {
             arg.Mobile.SendLocalizedMessage(1005631);                       // You have specified an invalid skill to set.
             return;
         }
         arg.Mobile.Target = new SkillTarget(skill, arg.GetDouble(1));
     }
 }
Example #6
0
        private static void Cmd_SkillUsage(Server.Commands.CommandEventArgs args)
        {
            Mobile    from = args.Mobile;
            SkillName skill;

            try
            {
                skill = (SkillName)Enum.Parse(typeof(SkillName), args.GetString(0), true);

                from.SendAsciiMessage("Global Usage for {0} : ", skill);
                if (m_TotalUses > 0)
                {
                    from.SendAsciiMessage("{0:F2}% ({1}/{2})", (((double)m_SkillUsage[(int)skill]) / ((double)m_TotalUses)) * 100.0, m_SkillUsage[(int)skill], m_TotalUses);
                }
            }
            catch
            {
                from.SendAsciiMessage("That is not a valid skill name.");
                return;
            }
        }
Example #7
0
        public override void Execute(Server.Commands.CommandEventArgs e, object obj)
        {
            if (e.Length >= 2)
            {
                for (int i = 0; (i + 1) < e.Length; i += 2)
                {
                    string result = Properties.SetValue(e.Mobile, obj, e.GetString(i), e.GetString(i + 1));

                    if (result == "Property has been set.")
                    {
                        AddResponse(result);
                    }
                    else
                    {
                        LogFailure(result);
                    }
                }
            }
            else
            {
                LogFailure("Format: Set <propertyName> <value>");
            }
        }
Example #8
0
        public override void Execute(Server.Commands.CommandEventArgs e, object obj)
        {
            if (e.Length >= 1)
            {
                for (int i = 0; i < e.Length; ++i)
                {
                    string result = Properties.GetValue(e.Mobile, obj, e.GetString(i));

                    if (result == "Property not found." || result == "Property is write only." || result.StartsWith("Getting this property"))
                    {
                        LogFailure(result);
                    }
                    else
                    {
                        AddResponse(result);
                    }
                }
            }
            else
            {
                LogFailure("Format: Get <propertyName>");
            }
        }
Example #9
0
        public static void Password_OnCommand(Server.Commands.CommandEventArgs e)
        {
            Mobile  from = e.Mobile;
            Account acct = from.Account as Account;

            if (acct == null)
            {
                return;
            }

            IPAddress[] accessList = acct.LoginIPs;

            if (accessList.Length == 0)
            {
                return;
            }

            NetState ns = from.NetState;

            if (ns == null)
            {
                return;
            }

            if (e.Length == 0)
            {
                from.SendMessage("You must specify the new password.");
                return;
            }
            else if (e.Length == 1)
            {
                from.SendMessage("To prevent potential typing mistakes, you must type the password twice. Use the format:");
                from.SendMessage("Password \"(newPassword)\" \"(repeated)\"");
                return;
            }

            string pass  = e.GetString(0);
            string pass2 = e.GetString(1);

            if (pass != pass2)
            {
                from.SendMessage("The passwords do not match.");
                return;
            }

            bool isSafe = true;

            for (int i = 0; isSafe && i < pass.Length; ++i)
            {
                isSafe = (pass[i] >= 0x20 && pass[i] < 0x80);
            }

            if (!isSafe)
            {
                from.SendMessage("That is not a valid password.");
                return;
            }

            try
            {
                IPAddress ipAddress = ((IPEndPoint)ns.Socket.RemoteEndPoint).Address;

                if (Utility.IPMatchClassC(accessList[0], ipAddress))
                {
                    acct.SetPassword(pass);
                    from.SendMessage("The password to your account has changed.");
                }
                else
                {
                    PageEntry entry = PageQueue.GetEntry(from);

                    if (entry != null)
                    {
                        if (entry.Message.StartsWith("[Automated: Change Password]"))
                        {
                            from.SendMessage("You already have a password change request in the help system queue.");
                        }
                        else
                        {
                            from.SendMessage("Your IP address does not match that which created this account.");
                        }
                    }
                    else if (PageQueue.CheckAllowedToPage(from))
                    {
                        from.SendMessage("Your IP address does not match that which created this account.  A page has been entered into the help system on your behalf.");

                        from.SendLocalizedMessage(501234, "", 0x35);                           /* The next available Counselor/Game Master will respond as soon as possible.
                                                                                                * Please check your Journal for messages every few minutes.
                                                                                                */

                        PageQueue.Enqueue(new PageEntry(from, String.Format("[Automated: Change Password]<br>Desired password: {0}<br>Current IP address: {1}<br>Account IP address: {2}", pass, ipAddress, accessList[0]), PageType.Account));
                    }
                }
            }
            catch
            {
            }
        }