コード例 #1
0
ファイル: Commands.cs プロジェクト: FreeReign/forkuo
        public override bool ValidateArgs(BaseCommandImplementor impl, 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 AddGump(e.Mobile, match, 0, Type.EmptyTypes, false));
                    }
                    else
                    {
                        e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, AddGump.Match(match).ToArray(), true));
                    }
                }
                else
                {
                    return true;
                }
            }
            else
            {
                e.Mobile.SendGump(new CategorizedAddGump(e.Mobile));
            }

            return false;
        }
コード例 #2
0
ファイル: ChatCommands.cs プロジェクト: greeduomacro/hubroot
		private static void msg_invoke( CommandEventArgs args )
		{
			if( args.Length == 1 && args.GetString( 0 ) != null )
			{
				string name = args.GetString( 0 );
				bool found = false;

				for( int i = 0; !found && i < NetState.Instances.Count; i++ )
				{
					if( NetState.Instances[i].Mobile != null && NetState.Instances[i].Mobile.RawName.ToLower() == name.ToLower() )
					{
						if( ChatManager.CanChat( args.Mobile, NetState.Instances[i].Mobile ) )
						{
							args.Mobile.SendGump( new ChatMessageGump( args.Mobile, NetState.Instances[i].Mobile ) );
							found = true;
						}
					}
				}

				if( !found )
					args.Mobile.SendGump( new ChatListGump( ListPage.Everyone, args.Mobile ) );
			}
			else
			{
				args.Mobile.SendGump( new ChatListGump( ListPage.Everyone, args.Mobile ) );
			}
		}
コード例 #3
0
ファイル: Interface.cs プロジェクト: Crome696/ServUO
        public override void ExecuteList(CommandEventArgs e, ArrayList list)
        {
            if (list.Count > 0)
            {
                List<string> columns = new List<string>();

                columns.Add("Object");

                if (e.Length > 0)
                {
                    int offset = 0;

                    if (Insensitive.Equals(e.GetString(0), "view"))
                        ++offset;

                    while (offset < e.Length)
                        columns.Add(e.GetString(offset++));
                }

                e.Mobile.SendGump(new InterfaceGump(e.Mobile, columns.ToArray(), list, 0, null));
            }
            else
            {
                this.AddResponse("No matching objects found.");
            }
        }
コード例 #4
0
ファイル: Skills.cs プロジェクト: greeduomacro/hubroot
		public static void SetSkill_OnCommand( CommandEventArgs arg )
		{
			if( arg.Length != 2 )
			{
				arg.Mobile.SendMessage( "SetSkill <skill name> <value>" );
			}
			else
			{
				SkillName skill;
#if Framework_4_0
				if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
				{
					arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
				}
				else
				{
					arg.Mobile.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
				}
#else
				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 ) );
#endif
			}
		}
コード例 #5
0
		public static void RemoveAccountTag_OnCommand( CommandEventArgs e )
		{
			Mobile from = e.Mobile;
			if( from == null || from.Deleted )
				return;

			if( e.Length == 2 )
			{
				string accString = e.GetString( 0 );
				string tagString = e.GetString( 1 );

				if( !string.IsNullOrEmpty( accString ) )
				{
					Account acct = Accounts.GetAccount( accString ) as Account;

					if( acct != null )
					{
						if( !string.IsNullOrEmpty( tagString ) )
						{
							if( !string.IsNullOrEmpty(acct.GetTag( tagString )) )
							{
								string msg = string.Format( "You are going to remove tag <em><basefont color=red>{0}</basefont></em> " +
								                            "from accunt <em><basefont color=red>{1}</basefont></em>.<br>" +
							                            	"Are you sure you want to proceed?", tagString, accString );
								from.SendGump( new WarningGump( 1060635, 30720, msg, 0xFFC000, 420, 280, new WarningGumpCallback( ConfirmRemoveCallBack ), new object[]{ acct, tagString }, true ) );
							}
							else
							{
								from.SendMessage( "Target account exist but does not have that tag." );
							}
						}
						else
						{
							from.SendMessage( "Invalid tag (null or empty)." );
						}
					}
					else
					{
						from.SendMessage( "Target account does not exist." );
					}
				}
				else
				{
					from.SendMessage( "Invalid userName (null or empty)." );
				}
			}
			else
			{
				from.SendMessage( "CommandUse: [RemoveAccountTag <account> <tag>" );
			}
		}
コード例 #6
0
        public static void ChangeSeason_OnCommand(CommandEventArgs e)
        {
            Mobile m = e.Mobile;
            
            if (e.Length != 1)
            {
                m.SendMessage("Usage: [ChangeSeason [Spring|Summer|Autumn|Winter|Desolation]");
                return;
            }

            int season;

            switch (e.GetString(0).ToLower())
            {
                case "spring":
                    season = 0;
                    break;
                case "summer":
                    season = 1;
                    break;
                case "autumn":
                case "fall":
                    season = 2;
                    break;
                case "winter":
                    season = 3;
                    break;
                case "desolation":
                    season = 4;
                    break;
                default:
                    m.SendMessage("Usage: [ChangeSeason [Spring|Summer|Autumn|Winter|Desolation]");
                    return;
            }

            Map map = m.Map;
            map.Season = season;

            foreach (NetState ns in NetState.Instances)
            {
                if (ns.Mobile == null || ns.Mobile.Map != map)
                    continue;

                ns.Send(SeasonChange.Instantiate(ns.Mobile.GetSeason(), true));
                ns.Mobile.SendEverything();
            }

            m.SendMessage("{0} season changed to {1}.", map.Name, e.GetString(0));
        }
コード例 #7
0
ファイル: Equip.cs プロジェクト: greeduomacro/UO-Forever
		public static void Equip_OnCommand( CommandEventArgs e )
		{
			Mobile from = e.Mobile;

			Type type = ScriptCompiler.FindTypeByName( e.GetString( 0 ).Trim().ToLower(), true );

			if ( type != null && typeof( Item ).IsAssignableFrom( type ) )
			{
				Item item = from.Backpack.FindItemByType( type, true );

				if ( item != null && !item.Deleted )
				{
					from.DropHolding();

					bool rejected;
					LRReason reject;

					from.Lift( item, item.Amount, out rejected, out reject );

					if ( !rejected )
					{
						from.Holding = null;

						if ( !from.EquipItem( item ) )
							item.Bounce( from );
					}

					item.ClearBounce();
				}
			}
			else
				from.SendMessage( "That item type does not exist." );
		}
コード例 #8
0
        public static void OnCommand(CommandEventArgs arg)
        {
            Mobile m = arg.Mobile;

            string skillNames = string.Join(", ", Enum.GetNames(typeof(SkillName)));

            if (arg.Length != 1)
            {
                m.SendMessage("Usage: SetSkill <skill name>. List of skill names: {0}.", skillNames);
            }
            else
            {
                SkillName skillName;
                if (Enum.TryParse(arg.GetString(0), true, out skillName))
                {
                    Skill skill = m.Skills[skillName];
                    if (skill != null)
                    {
                        skill.Base = 0;
                        m.SendMessage("You've successfully reset your {0}.", skill.Name);
                    }
                }
                else
                {
                    m.SendMessage("You have specified an invalid skill to set. List of skill names: {0}.", skillNames);
                }
            }
        }
コード例 #9
0
ファイル: SeasonCommand.cs プロジェクト: greeduomacro/hubroot
		private static void Season_OnCommand( CommandEventArgs e )
		{
			Mobile m = e.Mobile;

			if( e.Length == 1 )
			{
				string seasonType = e.GetString( 0 ).ToLower();
				SeasonList season;

				try
				{
					season = (SeasonList)Enum.Parse( typeof( SeasonList ), seasonType, true );
				}
				catch
				{
					m.SendMessage( "Usage: Season spring | summer | fall | winter | desolation" );
					return;
				}

				m.SendMessage( "Setting season to: " + seasonType + "." );
				SetSeason( m, season );
			}
			else
				m.SendMessage( "Usage: Season spring | summer | fall | winter | desolation" );
		}
コード例 #10
0
        private static void DeleteMap_OnCommand( CommandEventArgs e )
        {
            try
            {
                BaseInstanceMap basemap = Map.Parse( e.GetString( 0 ) ) as BaseInstanceMap;

                if ( basemap != null )
                {
                    List<Item> items = new List<Item>();
                    List<Mobile> mobiles = new List<Mobile>();

                    foreach ( Item item in World.Items.Values )
                        if ( item.Map == basemap && item.Parent == null )
                            items.Add( item );

                    for ( int i = items.Count-1; i >= 0; i-- )
                        items[i].Delete();

                    foreach ( Mobile m in World.Mobiles.Values )
                        if ( !m.Player && m.Map == basemap )
                            mobiles.Add( m );

                    for ( int i = mobiles.Count-1; i >= 0; i-- )
                        mobiles[i].Delete();

                    basemap.Delete();
                }
            }
            catch
            {
            }
        }
コード例 #11
0
ファイル: HelpInfo.cs プロジェクト: nathanvy/runuo
		private static void HelpInfo_OnCommand( CommandEventArgs e )
		{
			if( e.Length > 0 )
			{
				string arg = e.GetString( 0 ).ToLower();
				CommandInfo c;

				if( m_HelpInfos.TryGetValue( arg, out c ) )
				{
					Mobile m = e.Mobile;

					if( m.AccessLevel >= c.AccessLevel )
						m.SendGump( new CommandInfoGump( c ) );
					else
						m.SendMessage( "You don't have access to that command." );

					return;
				}
				else
					e.Mobile.SendMessage( String.Format( "Command '{0}' not found!", arg ) );
			}

			e.Mobile.SendGump( new CommandListGump( 0, e.Mobile, null ) );

		}
コード例 #12
0
ファイル: Commands.cs プロジェクト: greeduomacro/vivre-uo
		private static void SetSeason_OnCommand(CommandEventArgs e)
		{
			Mobile from = e.Mobile;

			if (e.Length >= 1)
			{
				Region reg = from.Region;

				if (reg == null || !(reg is ISeasons))
				{
					from.SendMessage("You are not in a region that supports Seasons.");
					from.SendMessage("To set the Map Season, use {0}SetMapSeason", CommandSystem.Prefix);
				}
				else
				{
					try
					{
						ISeasons sreg = reg as ISeasons;

						sreg.Season = (Season)Enum.Parse(typeof(Season), (e.GetString(0).Trim()), true);
						from.SendMessage("Season has been set to {0}.", sreg.Season.ToString());
					}
					catch
					{
						from.SendMessage("Format: SetSeason < Spring | Summer | Autumn/Fall | Winter | Desolation >");
					}
				}
			}
			else
			{
				from.SendMessage("Format: SetSeason < Spring | Summer | Autumn/Fall | Winter | Desolation >");
			}
		}
コード例 #13
0
ファイル: Unequip.cs プロジェクト: greeduomacro/UO-Forever
		public static void Unequip_OnCommand( CommandEventArgs e )
		{
			Mobile from = e.Mobile;

			Layer layer;
			if ( Enum.TryParse<Layer>( e.GetString( 0 ).Trim().ToLower(), true, out layer ) )
			{
				if ( layer > Layer.Invalid && layer <= Layer.LastUserValid && layer != Layer.Backpack )
				{
					Item item = from.FindItemOnLayer( layer );

					if ( item != null && !item.Deleted )
					{
						from.DropHolding();

						bool rejected;
						LRReason reject;

						from.Lift( item, item.Amount, out rejected, out reject );

						if ( !rejected )
						{
							from.Drop( from.Backpack, new Point3D( -1, -1, 0 ) );
							from.Holding = null;
						}
					}
				}
				else
					from.SendMessage( "That layer is not accessible." );
			}
			else
				from.SendMessage( "That layer does not exist." );
		}
コード例 #14
0
ファイル: SendTo.cs プロジェクト: FreeReign/imaginenation
        public override void Execute(CommandEventArgs e, object obj)
        {
            Mobile from = e.Mobile;
            Mobile target = obj as Mobile;
            Map map = from.Map;
            Point3D location = Point3D.Zero;

            if (target == null || map == Map.Internal || map == null)
            {
                from.SendAsciiMessage("Invalid target.");
                return;
            }
            else if (e.Length == 0)
            {
                from.SendAsciiMessage("Format:");
                from.SendAsciiMessage("SendTo int x int y");
                from.SendAsciiMessage("SendTo int x int y int z");
                from.SendAsciiMessage("SendTo int yLat int yMins (N|S) ySount int xLong int xMins (E|W) xEast");
                return;
            }
            else if (e.Length == 2)
            {
                int x = e.GetInt32(0);
                int y = e.GetInt32(1);

                location = new Point3D(x, y, map.GetAverageZ(x, y));
            }
            else if (e.Length == 3)
                location = new Point3D(e.GetInt32(0), e.GetInt32(1), e.GetInt32(2));
            else if (e.Length == 6)
            {
                location = 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 (location == Point3D.Zero)
                    from.SendMessage("Sextant reverse lookup failed.");
            }

            if (location != Point3D.Zero)
            {
                target.MoveToWorld(location, map);
                from.SendAsciiMessage(string.Format("Sent {0} to {1}.", target.Name, location));
            }
            else
                from.SendAsciiMessage("Invalid location.");
        }
コード例 #15
0
        private static void CreateMap_OnCommand( CommandEventArgs e )
        {
            if ( e.Arguments.Length == 2 )
            {
                try
                {
                    Map map = Map.Parse( e.GetString( 0 ) );
                    if ( map != null )
                    {
                        string name = e.GetString( 1 );

                        BaseInstanceMap basemap = new BaseInstanceMap( map, name, MapRules.FeluccaRules );
                    }
                }
                catch
                {
                }
            }
        }
コード例 #16
0
ファイル: Replace.cs プロジェクト: ITLongwell/aedilis2server
		private static void ReplaceItem_OnCommand( CommandEventArgs e )
		{
			bool copyDeep = false;

			if ( e.Length == 1 && e.GetString( 0 ).Equals( "-d" ))
				copyDeep = true;

			e.Mobile.Target = new ReplaceItemTarget( copyDeep );
			e.Mobile.SendMessage( "Choose an Item to replace." );
		}
コード例 #17
0
ファイル: ExchangeSkill.cs プロジェクト: greeduomacro/hubroot
		public static void ExchangeSkill_OnCommand( CommandEventArgs args )
		{
			Mobile m = args.Mobile;

			if( args.Length != 2 )
			{
				m.SendMessage( "ExchangeSkill <skill to lower> <skill to raise>" );
			}
			else
			{
				SkillName toLower = SkillName.Swords;
				SkillName toRaise = SkillName.Swords;

				if( TryParse( m, args.GetString( 0 ), ref toLower ) && TryParse( m, args.GetString( 1 ), ref toRaise ) )
				{
					m.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( OnTarget ), new object[] { toLower, toRaise } );
					m.SendMessage( "Select the mobile." );
				}
			}
		}
コード例 #18
0
ファイル: GenScriptv1_2.cs プロジェクト: FreeReign/aosredux
        public static void GenScript_OnCommand( CommandEventArgs e )
        {
            if ( e.Length != 1 )
            {
                e.Mobile.SendMessage( "Format: genscript <ClassName>" );
                return;
            }

            e.Mobile.Target = new GenScriptTarget( e.GetString( 0 ) );
            e.Mobile.SendMessage( "What item do you want to script?" );
        }
コード例 #19
0
ファイル: AltCommand.cs プロジェクト: greeduomacro/last-wish
        public override void Execute(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 if (result.EndsWith("= True"))
                    {
                        string setResult = Properties.SetValue(e.Mobile, obj, e.GetString(i), "False");

                        if (setResult == "Property has been set.")
                            AddResponse(setResult);
                        else
                            LogFailure(setResult);
                    }
                    else if (result.EndsWith("= False"))
                    {
                        string setResult = Properties.SetValue(e.Mobile, obj, e.GetString(i), "True");

                        if (setResult == "Property has been set.")
                            AddResponse(setResult);
                        else
                            LogFailure(setResult);
                    }
                    else
                    {
                        LogFailure(e.GetString(i) + " is not a boolean property.");
                    }
                }
            }
            else
            {
                LogFailure("Format: Alt <propertyName>");
            }
        }
コード例 #20
0
ファイル: WhoGump.cs プロジェクト: zerodowned/angelisland
		private static void WhoList_OnCommand( CommandEventArgs e )
		{
			// wea: pass string parameter if there is one

			if( e.Length > 1 )
			{
				e.Mobile.SendMessage( "Format: who (<search word>)" );
				return;
			}

			e.Mobile.SendGump( new WhoGump( e.Mobile, (e.Length == 1 ? e.GetString(0) : "") ) );
		}
コード例 #21
0
ファイル: GenMulti.cs プロジェクト: greeduomacro/hubroot
		public static void GenMulti_OnCommand( CommandEventArgs args )
		{
			Mobile m = args.Mobile;
			string file = args.GetString( 0 );

			if( String.IsNullOrEmpty( file ) )
			{
				m.SendMessage( "Format: GenMulti <fileName>" );
				return;
			}

			BoundingBoxPicker.Begin( m, new BoundingBoxCallback( boxPicker_callback ), file + ".txt" );
		}
コード例 #22
0
		private static void CreateMap_OnCommand( CommandEventArgs e )
		{
			if ( e.Arguments.Length == 2 )
			{
				try
				{
					Map map = Map.Parse( e.GetString( 0 ) );
                    if (map != null)
                    {
                        string name = e.GetString(1);

                        BaseInstanceMap basemap = new BaseInstanceMap(map, name, MapRules.FeluccaRules);
                    }
                    else
                    {
                        e.Mobile.SendMessage("Usage: [createmap mapToCopy newMapName");
                    }
				}
				catch
				{
                    e.Mobile.SendMessage("Usage: [createmap mapToCopy newMapName");
				}
			}
		}
コード例 #23
0
		public static void GuildAdmin_OnCommand( CommandEventArgs args )
		{
			if( args.Length == 1 )
			{
				string notice = "";

				List<Guild> foundList = SearchForGuild( args.GetString( 0 ), false, out notice );

				if( foundList.Count == 1 )
					args.Mobile.SendGump( new GuildAdminGump( args.Mobile, Page.GuildInfo, 0, "One match found.", null, foundList[0] ) );
				else
					args.Mobile.SendGump( new GuildAdminGump( args.Mobile, Page.Guilds, 0, (notice == null ? (foundList.Count == 0 ? "Nothing matched your search terms." : null) : notice), foundList, null ) );
			}
			else
				args.Mobile.SendGump( new GuildAdminGump( args.Mobile, Page.Information, 0, null, null, null ) );
		}
コード例 #24
0
        public override void Execute(CommandEventArgs e)
        {
            if (e.Length >= 2)
            {
                Serial serial = e.GetInt32(0);

                object obj = null;

                if (serial.IsItem)
                    obj = World.FindItem(serial);
                else if (serial.IsMobile)
                    obj = World.FindMobile(serial);

                if (obj == null)
                {
                    e.Mobile.SendMessage("That is not a valid serial.");
                }
                else
                {
                    BaseCommand command = null;
                    Commands.TryGetValue(e.GetString(1), out command);

                    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 - 2];

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

                        RunCommand(e.Mobile, obj, command, args);
                    }
                }
            }
            else
            {
                e.Mobile.SendMessage("You must supply an object serial and a command name.");
            }
        }
コード例 #25
0
        public static void ChangeSeason_OnCommand(CommandEventArgs e)
        {
            if (e.Length != 1)
            {
                e.Mobile.SendMessage("Usage: [ChangeSeason [Spring|Summer|Autumn|Winter|Desolation]");
                return;
            }

            int season;

            switch (e.GetString(0).ToLower())
            {
                case "spring":
                    season = 0;
                    break;
                case "summer":
                    season = 1;
                    break;
                case "autumn":
                case "fall":
                    season = 2;
                    break;
                case "winter":
                    season = 3;
                    break;
                case "desolation":
                    season = 4;
                    break;
                default:
                    e.Mobile.SendMessage("Usage: [ChangeSeason [Spring|Summer|Autumn|Winter|Desolation]");
                    return;
            }

            foreach (Map map in Map.AllMaps)
            {
                map.Season = season;

                foreach (Network.NetState ns in Network.NetState.Instances)
                {
                    if (ns.Mobile == null)
                        continue;

                    ns.Send(Network.SeasonChange.Instantiate(ns.Mobile.GetSeason(), true));
                    ns.Mobile.SendEverything();
                }
            }
        }
コード例 #26
0
		public static void ChangeAccessLevel_OnCommand( CommandEventArgs args )
		{
			if( args.Length == 1 )
			{
				string newLevel = args.GetString( 0 );

				if( newLevel != null )
				{
					args.Mobile.SendMessage( "Select the mobile." );
					args.Mobile.Target = new InternalTarget( newLevel );
				}
				else
					args.Mobile.SendMessage( "Format: ChangeAccessLevel <newLevel>" );
			}
			else
				args.Mobile.SendMessage( "Format: ChangeAccessLevel <newLevel>" );
		}
コード例 #27
0
ファイル: CTFGame.cs プロジェクト: FreeReign/realmofdarkness
		private static void StartGame_Command( CommandEventArgs e )
		{
			if ( e.Arguments.Length < 1 )
			{
				e.Mobile.SendMessage( "Usage: startgame <ResetTeams>" );
				e.Mobile.SendMessage( "So, if you want to start the game and force everyone to choose a new team, do [startgame true" );
			}
			
			string str = e.GetString( 0 ).ToUpper().Trim();
			bool reset;
			if ( str == "YES" || str == "TRUE" || str == "Y" || str == "T" || str == "1" )
				reset = true;
			else
				reset = false;

			e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( StartGame_Target ), reset );
			e.Mobile.SendMessage( "Target the game control stone to START a game." );
		}
コード例 #28
0
ファイル: Drink.cs プロジェクト: greeduomacro/UO-Forever
		public static void Drink_OnCommand( CommandEventArgs e )
		{
			Mobile from = e.Mobile;

			Type type = ScriptCompiler.FindTypeByName( e.GetString( 0 ).Trim().ToLower(), true );

			if ( type != null && typeof( BasePotion ).IsAssignableFrom( type ) )
			{
				BasePotion potion = from.Backpack.FindItemByType( type, true ) as BasePotion;

				if ( potion != null )
                    DoubleClickCommand.CommandUseReq(from, potion);
				else
					from.SendMessage( "You do not have any of those potions." );
			}
			else
				from.SendMessage( "That is not a type of potion." );
		}
コード例 #29
0
ファイル: Skills.cs プロジェクト: nathanvy/runuo
		public static void GetSkill_OnCommand( CommandEventArgs arg )
		{
			if ( arg.Length != 1 )
			{
				arg.Mobile.SendMessage( "GetSkill <skill name>" );
			}
			else
			{
				SkillName skill;
				if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
				{
					arg.Mobile.Target = new SkillTarget( skill );
				}
				else
				{
					arg.Mobile.SendMessage( "You have specified an invalid skill to get." );
				}
			}
		}
コード例 #30
0
ファイル: Skills.cs プロジェクト: nathanvy/runuo
		public static void SetSkill_OnCommand( CommandEventArgs arg )
		{
			if ( arg.Length != 2 )
			{
				arg.Mobile.SendMessage( "SetSkill <skill name> <value>" );
			}
			else
			{
				SkillName skill;
				if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
				{
					arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
				}
				else
				{
					arg.Mobile.SendLocalizedMessage( 1005631 ); // You have specified an invalid skill to set.
				}
			}
		}
コード例 #31
0
        public static void Maintenance_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e.Length == 0)
                {
                    Usage(e);
                }
                else
                {
                    string strParam = e.GetString(0);

                    // default is 5 minutes from now
                    m_When = DateTime.Now + TimeSpan.FromMinutes(5);

                    if (e.Length > 1)
                    {                           // we have a date-time param
                        string sx = null;
                        for (int ix = 1; ix < e.Length; ix++)
                        {
                            sx += e.GetString(ix) + " ";
                        }
                        try { m_When = DateTime.Parse(sx); }
                        catch
                        {
                            e.Mobile.SendMessage("Bad date format.");
                            e.Mobile.SendMessage("Maintenance not initiated.");
                            Usage(e);
                            return;
                        }

                        TimeSpan diff = m_When.Subtract(DateTime.Now);
                        m_Countdown = (int)diff.TotalMinutes;
                    }

                    if (strParam.ToLower().Equals("cancel"))
                    {
                        m_Scheduled = false;
                        if (m_Rebuild)
                        {
                            if (KillRebuild())
                            {
                                e.Mobile.SendMessage("Rebuild.exe canceled succesfully.");
                                Rebuild = false;
                            }
                            else
                            {
                                e.Mobile.SendMessage("Error closeing rebuild.exe!!!");
                            }
                        }
                        AutoSave.SavesEnabled = true;
                        e.Mobile.SendMessage("Maintenance has been canceled.");
                        World.Broadcast(0x482, true, "Server maintenance has been canceled.");
                        m_Maintenance.Stop();
                    }
                    else if (strParam.ToLower().Equals("rebuild"))
                    {
                        if (Rebuild)
                        {
                            e.Mobile.SendMessage("The server is already prepareing for a rebuild.");
                        }
                        else
                        {
                            Rebuild               = true;
                            Shutdown              = true;
                            Scheduled             = true;
                            AutoSave.SavesEnabled = false;
                            e.Mobile.SendMessage("You have initiated a server rebuild.");
                            m_Maintenance.Start();

                            if (!StartRebuild(Misc.TestCenter.Enabled))
                            {
                                e.Mobile.SendMessage("Rebuild.exe failed to start, canceling rebuild.");
                                Rebuild   = false;
                                Scheduled = false;
                            }
                        }
                    }
                    else if (strParam.ToLower().Equals("restart") || strParam.ToLower().Equals("shutdown"))
                    {
                        if (m_Scheduled)
                        {
                            e.Mobile.SendMessage("The server is already restarting.");
                        }
                        else
                        {
                            m_Shutdown            = strParam.ToLower().Equals("shutdown") ? true : false;
                            m_Scheduled           = true;
                            AutoSave.SavesEnabled = false;
                            e.Mobile.SendMessage("You have initiated server {0}.", m_Shutdown ? "shutdown" : "restart");
                            m_Maintenance.Start();
                        }
                    }
                    else
                    {
                        Usage(e);
                    }
                }
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
                e.Mobile.SendMessage("There was a problem with the [Maintenance command!!  See console log");
                System.Console.WriteLine("Error with [Maintenance!");
                System.Console.WriteLine(exc.Message);
                System.Console.WriteLine(exc.StackTrace);
            }
        }
コード例 #32
0
        public override void Execute(CommandEventArgs e, object obj)
        {
            Mobile m = (Mobile)obj;

            //CommandLogging.WriteLine( e.Mobile, "{0} {1} {2} {3}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), m_Value ? "hiding" : "unhiding", CommandLogging.Format( m ) );

            if (e.Length == 1)
            {
                if ((m is PlayerMobile) && (m.AccessLevel == AccessLevel.Player))                     // Can't put bounty on staff.
                {
                    PlayerMobile bountyPlacer = (PlayerMobile)e.Mobile;
                    Container    cont         = bountyPlacer.BankBox;

                    int amount = 0;
                    try
                    {
                        amount = Int32.Parse(e.GetString(0));
                    }
                    catch
                    {
                        AddResponse("Bounty Amount was improperly formatted!");
                        return;
                    }

                    if (amount < 500)
                    {
                        AddResponse("No one would hunt for that low of a bounty!");
                    }
                    else if (cont != null && cont.ConsumeTotal(typeof(Gold), amount))
                    {
                        BountyKeeper.Add(new Bounty(bountyPlacer, (PlayerMobile)m, amount, false));
                        AddResponse("You have posted a bounty for the head of " + m.Name + "!");
                        AddResponse("Amount of GP removed from your bank: " + amount);
                        ((PlayerMobile)m).SendMessage(bountyPlacer.Name + " has just placed a bounty on your head for " + amount + " gold.");

                        //Flag player criminal, but don't guardwhack
                        //bountyPlacer.Criminal = true;
                        //Flag to only the player you place the bounty on.
                        if (!bountyPlacer.PermaFlags.Contains(m))
                        {
                            bountyPlacer.PermaFlags.Add(m);
                            bountyPlacer.Delta(MobileDelta.Noto);
                            ExpireTimer et = new ExpireTimer(bountyPlacer, m, TimeSpan.FromMinutes(2.0));
                            et.Start();
                        }
                    }
                    else
                    {
                        AddResponse("You do not have that much GP in your bank!");
                    }
                }
                else
                {
                    AddResponse("Please target a player.");
                }
            }
            else
            {
                AddResponse("You must specify the amount of the bounty.");
            }
        }
コード例 #33
0
        public static void Password_OnCommand(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] < 0x7F);
            }

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

            try
            {
                IPAddress ipAddress = ns.Address;

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

            catch
            {
            }
        }
コード例 #34
0
        public override void Execute(CommandEventArgs e, object obj)
        {
            Mobile from   = e.Mobile;
            Mobile target = obj as Mobile;
            Map    map    = from.Map;

            if (target == null || map == Map.Internal || map == null)
            {
                from.SendAsciiMessage("Invalid target.");
                return;
            }
            if (e.Length == 0)
            {
                from.SendAsciiMessage("Format:");
                from.SendAsciiMessage("SendRewardGump <skillname> OR SendRewardGump bard OR SendRewardGump thieving");
                return;
            }
            if (e.Length == 1)
            {
                if (e.GetString(0).ToLower() == "bard")
                {
                    if (target.Skills.Peacemaking.Base == 100.0 && target.Skills.Discordance.Base == 100.0 && target.Skills.Provocation.Base == 100.0 && target.Skills.Musicianship.Base == 100.0)
                    {
                        target.CloseGump(typeof(ChooseBardRewardGump));
                        target.CloseGump(typeof(RewardGump));
                        target.SendGump(new ChooseBardRewardGump());
                        from.SendAsciiMessage("You sent a bard rewardgump to {0}", target.Name);
                        target.SendAsciiMessage("{0} sent a bard rewardgump to you", from.Name);
                        CommandLogging.WriteLine(from, "{0} {1} sending a bard reward gump to {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(target));
                    }
                    else
                    {
                        from.SendAsciiMessage("That player does not have 100 points in all bardic skills");
                    }

                    return;
                }
                if (e.GetString(0).ToLower() == "thieving")
                {
                    if (target.Skills.Hiding.Base == 100.0 && target.Skills.Stealth.Base == 100.0 && target.Skills.Snooping.Base == 100.0 && target.Skills.Stealing.Base == 100.0)
                    {
                        target.CloseGump(typeof(RewardGump));
                        target.SendGump(new RewardGump(target.Skills[21].Info, 0, "Name"));
                        from.SendAsciiMessage("You sent a thieving rewardgump to {0}", target.Name);
                        target.SendAsciiMessage("{0} sent a thieving rewardgump to you", from.Name);
                        CommandLogging.WriteLine(from, "{0} {1} sending a thieving reward gump to {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(target));
                    }
                    else
                    {
                        from.SendAsciiMessage("That player does not have 100 points in all thieving skills");
                    }

                    return;
                }
                SkillName skillname;
                try
                {
                    skillname = (SkillName)Enum.Parse(typeof(SkillName), e.GetString(0), true);
                }
                catch
                {
                    from.SendAsciiMessage("You have specified an invalid skill");
                    return;
                }

                Skill skill = target.Skills[skillname];

                if (target is PlayerMobile)
                {
                    switch (skill.SkillID)
                    {
                    case 0:     // Alchemy
                    case 7:     // Blacksmithy
                    case 8:     // Bowcraft/fletching
                    case 23:    // Inscription
                    case 25:    // Magery
                    case 34:    // Tailoring
                    case 35:    // Animal Taming
                    case 44:    // Lumberjacking
                    case 45:    // Mining
                        if (skill.Base == 100)
                        {
                            target.CloseGump(typeof(RewardGump));
                            target.SendGump(new RewardGump(skill.Info, 0, "Name"));
                            from.SendAsciiMessage("You sent a rewardgump for {0} to {1}", skill.Name, target.Name);
                            target.SendAsciiMessage("{0} sent a rewardgump for {1} to you", from.Name, skill.Name);
                            CommandLogging.WriteLine(from, "{0} {1} sending a reward gump to {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(target));
                        }
                        else
                        {
                            from.SendAsciiMessage("That player does not have 100 points in the specified skill");
                        }
                        break;

                    case 11:     // Carpentry
                        if (skill.Base == 100)
                        {
                            target.CloseGump(typeof(RewardGump));
                            target.CloseGump(typeof(ChooseCarpRewardGump));
                            target.SendGump(new ChooseCarpRewardGump());
                            from.SendAsciiMessage("You sent a rewardgump for {0} to {1}", skill.Name, target.Name);
                            target.SendAsciiMessage("{0} sent a rewardgump for {1} to you", from.Name, skill.Name);
                            CommandLogging.WriteLine(from, "{0} {1} sending a reward gump to {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(target));
                        }
                        else
                        {
                            from.SendAsciiMessage("That player does not have 100 points in the specified skill");
                        }
                        break;

                    default:
                        from.SendAsciiMessage("That skill does not have a reward");
                        break;
                    }
                }
                else
                {
                    from.SendAsciiMessage("You must target a player.");
                    return;
                }
            }
        }
コード例 #35
0
ファイル: Maintenance.cs プロジェクト: zerodowned/angelisland
        public static void Maintenance_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e.Length == 0)
                {
                    Usage(e);
                }
                else
                {
                    string strParam = e.GetString(0);

                    if (strParam.ToLower().Equals("cancel"))
                    {
                        m_Scheduled = false;
                        if (m_Rebuild)
                        {
                            if (KillRebuild())
                            {
                                e.Mobile.SendMessage("Rebuild.exe canceled succesfully.");
                                Rebuild = false;
                            }
                            else
                            {
                                e.Mobile.SendMessage("Error closeing rebuild.exe!!!");
                            }
                        }
                        m_Countdown           = 5;
                        AutoSave.SavesEnabled = true;
                        e.Mobile.SendMessage("Maintenance has been canceled.");
                        World.Broadcast(0x482, true, "Server maintenance has been canceled.");
                        m_Maintenance.Stop();
                    }
                    else if (strParam.ToLower().Equals("rebuild"))
                    {
                        if (Rebuild)
                        {
                            e.Mobile.SendMessage("The server is already prepareing for a rebuild.");
                        }
                        else
                        {
                            Rebuild               = true;
                            Shutdown              = true;
                            Scheduled             = true;
                            AutoSave.SavesEnabled = false;
                            e.Mobile.SendMessage("You have initiated a server rebuild.");
                            m_Maintenance.Start();

                            if (!StartRebuild(Misc.TestCenter.Enabled))
                            {
                                e.Mobile.SendMessage("Rebuild.exe failed to start, canceling rebuild.");
                                Rebuild   = false;
                                Scheduled = false;
                            }
                        }
                    }
                    else if (strParam.ToLower().Equals("restart") || strParam.ToLower().Equals("shutdown"))
                    {
                        if (m_Scheduled)
                        {
                            e.Mobile.SendMessage("The server is already restarting.");
                        }
                        else
                        {
                            m_Shutdown            = strParam.ToLower().Equals("shutdown") ? true : false;
                            m_Scheduled           = true;
                            m_Countdown           = 5;
                            AutoSave.SavesEnabled = false;
                            e.Mobile.SendMessage("You have initiated server {0}.", m_Shutdown ? "shutdown" : "restart");
                            m_Maintenance.Start();
                        }
                    }
                    else
                    {
                        Usage(e);
                    }
                }
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
                e.Mobile.SendMessage("There was a problem with the [Maintenance command!!  See console log");
                System.Console.WriteLine("Error with [Maintenance!");
                System.Console.WriteLine(exc.Message);
                System.Console.WriteLine(exc.StackTrace);
            }
        }
コード例 #36
0
ファイル: SendTo.cs プロジェクト: rberiot/imaginenation
        public override void Execute(CommandEventArgs e, object obj)
        {
            Mobile  from     = e.Mobile;
            Mobile  target   = obj as Mobile;
            Map     map      = from.Map;
            Point3D location = Point3D.Zero;

            if (target == null || map == Map.Internal || map == null)
            {
                from.SendAsciiMessage("Invalid target.");
                return;
            }
            else if (e.Length == 0)
            {
                from.SendAsciiMessage("Format:");
                from.SendAsciiMessage("SendTo int x int y");
                from.SendAsciiMessage("SendTo int x int y int z");
                from.SendAsciiMessage("SendTo int yLat int yMins (N|S) ySount int xLong int xMins (E|W) xEast");
                return;
            }
            else if (e.Length == 2)
            {
                int x = e.GetInt32(0);
                int y = e.GetInt32(1);

                location = new Point3D(x, y, map.GetAverageZ(x, y));
            }
            else if (e.Length == 3)
            {
                location = new Point3D(e.GetInt32(0), e.GetInt32(1), e.GetInt32(2));
            }
            else if (e.Length == 6)
            {
                location = 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 (location == Point3D.Zero)
                {
                    from.SendMessage("Sextant reverse lookup failed.");
                }
            }

            if (location != Point3D.Zero)
            {
                target.MoveToWorld(location, map);
                from.SendAsciiMessage(string.Format("Sent {0} to {1}.", target.Name, location));
            }
            else
            {
                from.SendAsciiMessage("Invalid location.");
            }
        }
コード例 #37
0
        public override void Execute(CommandEventArgs e)
        {
            if (e.Length >= 2)
            {
                Serial serial = e.GetInt32(0);

                object obj = null;

                if (serial.IsItem)
                {
                    obj = World.FindItem(serial);
                }
                else if (serial.IsMobile)
                {
                    obj = World.FindMobile(serial);
                }

                if (obj == null)
                {
                    e.Mobile.SendMessage("That is not a valid serial.");
                }
                else
                {
                    BaseCommand command = null;
                    Commands.TryGetValue(e.GetString(1), out command);

                    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
                    {
                        switch (command.ObjectTypes)
                        {
                        case ObjectTypes.Both:
                        {
                            break;
                        }

                        case ObjectTypes.Items:
                        {
                            if (!(obj is Item))
                            {
                                e.Mobile.SendMessage("This command only works on items.");
                                return;
                            }

                            break;
                        }

                        case ObjectTypes.Mobiles:
                        {
                            if (!(obj is Mobile))
                            {
                                e.Mobile.SendMessage("This command only works on mobiles.");
                                return;
                            }

                            break;
                        }
                        }

                        string[] oldArgs = e.Arguments;
                        string[] args    = new string[oldArgs.Length - 2];

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

                        RunCommand(e.Mobile, obj, command, args);
                    }
                }
            }
            else
            {
                e.Mobile.SendMessage("You must supply an object serial and a command name.");
            }
        }
コード例 #38
0
ファイル: FightBroker.cs プロジェクト: zerodowned/angelisland
        private static void FightBroker_OnCommand(CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            try
            {
                if (e.Length == 0)
                {
                    m.SendMessage("valid command formats are:");
                    m.SendMessage("[fightbroker list");
                    m.SendMessage("[fightbroker where <name>");
                }
                else
                {
                    string cmd = e.GetString(0);
                    if (cmd.ToLower() == "list")
                    {
                        int hue = 0x58;
                        FightBroker.FlushOldParticipants();
                        if (FightBroker.Participants.Count > 0)
                        {
                            m.SendMessage("Here are the people registered:");
                            foreach (FightMember fm in FightBroker.Participants)
                            {
                                string output;
                                if (fm.Mobile.Guild == null || fm.Mobile.DisplayGuildTitle == false)
                                {
                                    output = string.Format("{0}{1}", fm.Mobile.Name, fm.Mobile.Map != Map.Internal ? "" : " (offline)");
                                }
                                else
                                {
                                    output = string.Format("{0} [{2}]{1}", fm.Mobile.Name, fm.Mobile.Map != Map.Internal ? "" : " (offline)", fm.Mobile.Guild.Abbreviation);
                                }

                                if (fm.Mobile.Kills >= 5)
                                {
                                    hue = 0x21;
                                }
                                else if (fm.Mobile.Criminal)
                                {
                                    hue = 0x3B1;
                                }
                                else
                                {
                                    hue = 0x58;
                                }
                                m.SendMessage(hue, output);
                            }
                        }
                        else
                        {
                            m.SendMessage("The fightbroker list is empty.");
                        }
                    }
                    else if (cmd.ToLower() == "where")
                    {
                        string name;
                        int    index = e.ArgString.ToLower().IndexOf("where") + 6;
                        if (index > e.ArgString.Length)
                        {
                            m.SendMessage("Please specify a name: [fightbroker where <name>");
                        }
                        else
                        {
                            name = e.ArgString.Substring(index);
                            if (FightBroker.IsMatchedAndLoggedIn(name))
                            {
                                FightBroker.SendLocation(m, name);
                            }
                            else
                            {
                                m.SendMessage("{0} is not registered or is not logged in", name);
                            }
                        }
                    }
                    else
                    {
                        m.SendMessage("valid command formats are:");
                        m.SendMessage("[fightbroker list");
                        m.SendMessage("[fightbroker where <name>");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Caught exception in [fightbroker command: " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }
        }
コード例 #39
0
        public static void Restart_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e.Length == 0)
                {
                    e.Mobile.SendMessage("Format: Restart <off|now|24hrtime(xx:xx:xx)>");
                    if (m_enabled)
                    {
                        e.Mobile.SendMessage("The server is set to restart at " + m_RestartTime);
                    }
                    else
                    {
                        e.Mobile.SendMessage("The server is not set to restart.");
                    }
                }
                else
                {
                    string strParam = e.GetString(0);

                    if (strParam.ToLower().Equals("off"))
                    {
                        m_enabled = false;
                        e.Mobile.SendMessage("Restart set to off.");
                    }
                    else if (strParam.ToLower().Equals("now"))
                    {
                        if (m_Restarting)
                        {
                            e.Mobile.SendMessage("The server is already restarting.");
                        }
                        else
                        {
                            e.Mobile.SendMessage("You have initiated server shutdown.");
                            m_enabled     = true;
                            m_RestartTime = Cron.GameTimeNow;
                            RestartDelay  = TimeSpan.Zero;
                        }
                    }
                    else
                    {
                        //should be a time format
                        char []  delimiter = { ':' };
                        string[] fields    = strParam.Split(delimiter, 3);
                        int      iHour     = Int32.Parse(fields[0]);
                        int      iMinute   = 0;
                        int      iSecond   = 0;
                        if (fields.Length > 1)
                        {
                            iMinute = Int32.Parse(fields[1]);
                        }
                        if (fields.Length > 2)
                        {
                            iSecond = Int32.Parse(fields[2]);
                        }

                        m_RestartOffset = TimeSpan.FromHours(iHour) + TimeSpan.FromMinutes(iMinute) + TimeSpan.FromSeconds(iSecond);
                        m_RestartTime   = Cron.GameTimeNow.Date + m_RestartOffset;

                        if (m_RestartTime < Cron.GameTimeNow)
                        {
                            m_RestartTime += TimeSpan.FromDays(1.0);
                        }

                        e.Mobile.SendMessage("Restarting server at " + m_RestartTime);
                        m_enabled = true;
                    }
                }
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
                m_enabled = false;
                e.Mobile.SendMessage("There was a problem with the [restart command!!  See console log");
                System.Console.WriteLine("Error with [RESTART!");
                System.Console.WriteLine(exc.Message);
                System.Console.WriteLine(exc.StackTrace);
            }
        }
コード例 #40
0
        public static void Password_OnCommand(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 = ns.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
            {
            }
        }
コード例 #41
0
        public static void ReadBookFrom_OnCommand(CommandEventArgs e)
        {
            Console.WriteLine("ReadBookFrom Command given.");

            m_Lines = new List <string>();
            string filename = e.GetString(0);

            if (string.IsNullOrEmpty(filename))
            {
                Console.WriteLine("No text file specified, so will use '{0}'.", m_DefaultFile);
                filename = m_DefaultFile;
            }
            ReadStatus newReader = ReadBook(filename);

            m_BookStream.Close();
            char[] badchars = new char[] { '.', ';', '{', '}', '=', '+', '-', '(', ')', '?', '/',
                                           '!', '@', '#', '$', '%', '^', '&', '*', ':', '<', '>' };

            switch (newReader)
            {
            case ReadStatus.BadFile:
                Console.WriteLine("Bad filename specified.");
                break;

            case ReadStatus.Finished:
                string[] words = m_Title.Split(' ');
                for (int x = 0; x < words.Length; x++)
                {
                    if (words[x].IndexOfAny(badchars) >= 0)
                    {
                        words[x] = words[x].Remove(words[x].IndexOfAny(badchars), 1);
                    }
                }
                string fname = string.Concat(words);
                Console.WriteLine("Read Successful. {0} lines were read.", m_Lines.Count);
                if (WriteBook(fname))
                {
                    Console.WriteLine("Write Successful.");
                }
                else
                {
                    Console.WriteLine("Write Failed.");
                }
                break;

            case ReadStatus.IO_Error:
                for (int x = 0; x < m_Lines.Count; x++)
                {
                    CommandLogging.WriteLine(e.Mobile, m_Lines[x]);
                }
                Console.WriteLine("IO Error detected. {0} lines written to Command Log.", m_Lines.Count);
                break;

            case ReadStatus.Open:
                for (int x = 0; x < m_Lines.Count; x++)
                {
                    CommandLogging.WriteLine(e.Mobile, m_Lines[x]);
                }
                Console.WriteLine("Read Interrupted. {0} lines written to Command Log.", m_Lines.Count);
                break;

            default:
                Console.WriteLine("Unknown error occurred.");
                break;
            }
        }
コード例 #42
0
ファイル: SendTo.cs プロジェクト: Orion321/unknown-shard
    private static void SendTo_OnCommand(CommandEventArgs e)
    {
        Mobile from = e.Mobile;

        if (e.Length == 0)
        {
            SendToGump.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.SendMessage("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.SendMessage("You can not go to what you can not see.");
                        return;
                    }
                    else if (!FixMap(ref map, ref loc, item))
                    {
                        from.SendMessage("That is an internal item and you cannot go to it.");
                        return;
                    }

                    from.Target = new SendToTarget(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.SendMessage("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.SendMessage("You can not go to what you can not see.");
                        return;
                    }
                    else if (!FixMap(ref map, ref loc, m))
                    {
                        from.SendMessage("That is an internal mobile and you cannot go to it.");
                        return;
                    }

                    from.Target = new SendToTarget(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.Target = new SendToTarget(new Point3D(r.GoLocation), from.Map);
                            return;
                        }
                    }

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

                    return;
                }
            }
            catch
            {
            }

            from.SendMessage("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.Target = new SendToTarget(new Point3D(x, y, z), map);
            }
        }
        else if (e.Length == 3)
        {
            from.Target = new SendToTarget(new Point3D(e.GetInt32(0), e.GetInt32(1), e.GetInt32(2)), from.Map);
        }
        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.Target = new SendToTarget(p, map);
                }
                else
                {
                    from.SendMessage("Sextant reverse lookup failed.");
                }
            }
        }
        else
        {
            from.SendMessage("Format: Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W)]");
        }
    }
コード例 #43
0
        public static void CharacterAccessLevelToggle_OnCommand(CommandEventArgs e)
        {
            try
            {
                Mobile      m_Mob       = e.Mobile;
                AccessLevel al_MobLevel = m_Mob.AccessLevel;
                Account     a_Account   = (Account)m_Mob.Account;
                AccessLevel al_AccLevel = a_Account.AccessLevel;
                if (!m_Mob.Player || al_AccLevel == AccessLevel.Player)
                {
                    e.Mobile.SendMessage("You no not have access to that command.");
                    return;
                }

                AccessLevel al_NewLevel;
                switch (e.Length)
                {
                case 1:
                    switch (e.GetString(0).Trim().ToLower())
                    {
                    case "player":
                    case "0":
                        al_NewLevel = AccessLevel.Player;
                        break;

                    case "counselor":
                    case "1":
                        al_NewLevel = AccessLevel.Counselor;
                        break;

                    case "game master":
                    case "gm":
                    case "2":
                        al_NewLevel = AccessLevel.GameMaster;
                        break;

                    case "seer":
                    case "3":
                        al_NewLevel = AccessLevel.Seer;
                        break;

                    case "administrator":
                    case "4":
                        al_NewLevel = AccessLevel.Administrator;
                        break;

                    case "developer":
                    case "dev":
                    case "5":
                        al_NewLevel = AccessLevel.Developer;
                        break;

                    case "owner":
                    case "6":
                        al_NewLevel = AccessLevel.Owner;
                        break;

                    default:
                        e.Mobile.SendMessage("Wrong Parameter: " + e.GetString(0));
                        return;
                    }
                    break;

                case 0:
                    if (al_MobLevel == AccessLevel.Player)
                    {
                        al_NewLevel = al_AccLevel;
                    }
                    else
                    {
                        al_NewLevel = AccessLevel.Player;
                    }
                    break;

                default:
                    e.Mobile.SendMessage("Usage: CALT [<NewLevel>]");
                    return;
                }

                if (al_NewLevel > al_AccLevel)
                {
                    al_NewLevel = al_AccLevel;
                }

                m_Mob.AccessLevel = al_NewLevel;
            }
            catch (Exception err)
            {
                e.Mobile.SendMessage("Exception: " + err.Message);
            }
        }