예제 #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;
        }
예제 #2
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 ) );
     }
 }
예제 #3
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>" );
			}
		}
예제 #4
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;
            }
        }
        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." );
            }
        }
예제 #6
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>" );
            }
        }
예제 #7
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>" );
            }
        }
예제 #8
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>" );
            }
        }
예제 #9
0
        private static void Go_OnCommand( Server.Commands.CommandEventArgs e )
        {
            Mobile from = e.Mobile;

            if ( e.Length == 0 )
            {
                GoGump.DisplayTo( from );
            }
            else if ( e.Length == 1 )
            {
                try
                {
                    int ser = e.GetInt32( 0 );

                    IEntity ent = World.FindEntity( ser );

                    if ( ent is Item )
                    {
                        Item item = (Item)ent;

                        Map map = item.Map;
                        Point3D loc = item.GetWorldLocation();

                        Mobile owner = item.RootParent as Mobile;

                        if ( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !from.CanSee( owner ) )
                        {
                            from.SendAsciiMessage( "You can not go to what you can not see." );
                            return;
                        }
                        else if ( owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel )
                        {
                            from.SendAsciiMessage( "You can not go to what you can not see." );
                            return;
                        }
                        else if ( !FixMap( ref map, ref loc, item ) )
                        {
                            from.SendAsciiMessage( "That is an internal item and you cannot go to it." );
                            return;
                        }

                        from.MoveToWorld( loc, map );

                        return;
                    }
                    else if ( ent is Mobile )
                    {
                        Mobile m = (Mobile)ent;

                        Map map = m.Map;
                        Point3D loc = m.Location;

                        Mobile owner = m;

                        if ( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !from.CanSee( owner ) )
                        {
                            from.SendAsciiMessage( "You can not go to what you can not see." );
                            return;
                        }
                        else if ( owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel )
                        {
                            from.SendAsciiMessage( "You can not go to what you can not see." );
                            return;
                        }
                        else if ( !FixMap( ref map, ref loc, m ) )
                        {
                            from.SendAsciiMessage( "That is an internal mobile and you cannot go to it." );
                            return;
                        }

                        from.MoveToWorld( loc, map );

                        return;
                    }
                    else
                    {
                        string name = e.GetString( 0 );

                        List<Region> list = new List<Region>(from.Map.Regions.Values);

                        for ( int i = 0; i < list.Count; ++i )
                        {
                            Region r = (Region)list[i];

                            if ( Insensitive.Equals( r.Name, name ) )
                            {
                                from.Location = new Point3D( r.GoLocation );
                                return;
                            }
                        }

                        if ( ser != 0 )
                            from.SendAsciiMessage( "No object with that serial was found." );
                        else
                            from.SendAsciiMessage( "No region with that name was found." );

                        return;
                    }
                }
                catch
                {
                }

                from.SendAsciiMessage( "Region name not found" );
            }
            else if ( e.Length == 2 )
            {
                Map map = from.Map;

                if ( map != null )
                {
                    int x = e.GetInt32( 0 ), y = e.GetInt32( 1 );
                    int z = map.GetAverageZ( x, y );

                    from.Location = new Point3D( x, y, z );
                }
            }
            else if ( e.Length == 3 )
            {
                from.Location = new Point3D( e.GetInt32( 0 ), e.GetInt32( 1 ), e.GetInt32( 2 ) );
            }
            else if ( e.Length == 6 )
            {
                Map map = from.Map;

                if ( map != null )
                {
                    Point3D p = Sextant.ReverseLookup( map, e.GetInt32( 3 ), e.GetInt32( 0 ), e.GetInt32( 4 ), e.GetInt32( 1 ), Insensitive.Equals( e.GetString( 5 ), "E" ), Insensitive.Equals( e.GetString( 2 ), "S" ) );

                    if ( p != Point3D.Zero )
                        from.Location = p;
                    else
                        from.SendAsciiMessage( "Sextant reverse lookup failed." );
                }
            }
            else
            {
                from.SendAsciiMessage( "Format: Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W)]" );
            }
        }
예제 #10
0
        public static void Cast_OnCommand( Server.Commands.CommandEventArgs e )
        {
            if ( e.Length == 1 )
            {
                Spell spell = SpellRegistry.NewSpell( e.GetString( 0 ), e.Mobile, null );

                if ( spell != null )
                    spell.Cast();
                else
                    e.Mobile.SendAsciiMessage( "That spell was not found." );
            }
            else
            {
                e.Mobile.SendAsciiMessage( "Format: Cast <name>" );
            }
        }
예제 #11
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
            {
            }
        }