コード例 #1
0
ファイル: Skills.cs プロジェクト: FreeReign/imaginenation
		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
			}
		}
コード例 #2
0
 private static void HearCommands_OnCommand(CommandEventArgs args)
 {
     if (m_HearCommands.ContainsKey(args.Mobile))
     {
         m_HearCommands.Remove(args.Mobile);
         args.Mobile.SendMessage("Hear Commands disabled.");
     }
     else
     {
         if (args.Length == 1)
         {
             if (args.GetString(0).ToLower() == "noplayers")
             {
                 m_HearCommands.Add(args.Mobile, false);
                 args.Mobile.SendMessage("Hear Commands enabled without player commands, type .hearcommands again to disable it.");
             }
             else
             {
                 args.Mobile.SendMessage("Format:");
                 args.Mobile.SendMessage("HearCommands OR HearCommands noplayers");
             }
         }
         else
         {
             m_HearCommands.Add(args.Mobile, true);
             args.Mobile.SendMessage("Hear Commands enabled with playercommands, type .hearcommands again to disable it.");
             args.Mobile.SendMessage("To enable Hear Commands without player commands, type '.hearcommands noplayers'");
         }
     }
 }
コード例 #3
0
ファイル: HelpInfo.cs プロジェクト: FreeReign/imaginenation
		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 ) );

		}
コード例 #4
0
ファイル: SayCommand.cs プロジェクト: Godkong/Origins
 private static void Say_OnCommand(CommandEventArgs e)
 {
     string message = "";
     if (e.Length >= 1)
         message = e.GetString(0);
     e.Mobile.Target = new SayTarget(message);
     e.Mobile.SendAsciiMessage("What object do you want to make speak?");
 }
コード例 #5
0
        private static void OnCommand_Construct(CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            if (e.Length == 1)
            {
                string name = e.GetString(0);
                m.BeginTarget(-1, true, TargetFlags.None, new TargetStateCallback(OnTarget_Construct), name);
                m.SendMessage("Please target the loaction where you wish to place the house.");
            }
        }
コード例 #6
0
			public override void ExecuteList(CommandEventArgs e, ArrayList list)
			{
				string filename = e.GetString(0);

				var spawners = new List<Spawner>();

				spawners.AddRange(
					list.AsParallel()
						.OfType<Spawner>()
						.Where(spawner => spawner != null && !spawner.Deleted && spawner.Map != Map.Internal && spawner.Parent == null));

				AddResponse(String.Format("{0} spawners exported to Saves/Spawners/{1}.", spawners.Count.ToString("#,0"), filename));

				ExportSpawners(spawners, filename);
			}
コード例 #7
0
ファイル: Skills.cs プロジェクト: greeduomacro/last-wish
		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." );
				}
			}
		}
コード例 #8
0
ファイル: Skills.cs プロジェクト: greeduomacro/last-wish
		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.
				}
			}
		}
コード例 #9
0
ファイル: Handlers.cs プロジェクト: FreeReign/forkuo
        public static void Cast_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                if (!Multis.DesignContext.Check(e.Mobile))
                    return; // They are customizing

                Spell spell = SpellRegistry.NewSpell(e.GetString(0), e.Mobile, null);

                if (spell != null)
                    spell.Cast();
                else
                    e.Mobile.SendMessage("That spell was not found.");
            }
            else
            {
                e.Mobile.SendMessage("Format: Cast <name>");
            }
        }
コード例 #10
0
			public override void ExecuteList( CommandEventArgs e, ArrayList list )
			{
				string filename = e.GetString( 0 );
			
				ArrayList spawners = new ArrayList();
			
				for ( int i = 0; i < list.Count; ++i )
				{
					if ( list[i] is Spawner  )
					{
						Spawner spawner = (Spawner)list[i];
						if ( spawner != null && !spawner.Deleted && spawner.Map != Map.Internal && spawner.Parent == null )
							spawners.Add( spawner );
					}
				}
				
				AddResponse( String.Format( "{0} spawners exported to Saves/Spawners/{1}.", spawners.Count, filename ) );
				
				ExportSpawners( spawners, filename );
			}
コード例 #11
0
ファイル: MoveItems.cs プロジェクト: greeduomacro/last-wish
        public static void MoveItems_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // if we have a command after just the word "MoveItems"...
            if (e.Length != 0)
            {
                switch (e.GetString(0).ToLower())
                {
                    case "exact":
                        from.Target = new PackFromTarget(from, true);
                        break;
                    default:
                        from.LocalOverheadMessage(MessageType.Regular, 1150, true, "MoveItems will allow you to move items of a specific type from one container to another. For example, you want to move all spools of thread from your main pack to another backpack. Type [moveitems, target a spool of thread, then target the backpack you want the spools of thread to be moved to. The TO container normally is outside your main backpack. If you type ' exact' after the command [moveitems it will only move very specific types. For example, [moveitems and targeting a yumi bow will move ALL baseranged items. [moveitems exact and targetting a yumi will only move yumis.");
                        break;
                }
            }
            else
                from.Target = new PackFromTarget(from, false);
        }
コード例 #12
0
ファイル: SpawnerExporter.cs プロジェクト: jasegiffin/JustUO
        public static void ImportSpawners_OnCommand(CommandEventArgs e)
        {
            if (e.Arguments.Length >= 1)
            {
                string filename = e.GetString(0);
                string filePath = Path.Combine("Saves/Spawners", filename);
				
                if (File.Exists(filePath))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(filePath);

                    XmlElement root = doc["spawners"];

                    int successes = 0, failures = 0;
					
                    foreach (XmlElement spawner in root.GetElementsByTagName("spawner"))
                    {
                        try
                        {
                            ImportSpawner(spawner);
                            successes++;
                        }
                        catch
                        {
                            failures++;
                        }
                    }
					
                    e.Mobile.SendMessage("{0} spawners loaded successfully from {1}, {2} failures.", successes, filePath, failures);
                }
                else
                {
                    e.Mobile.SendMessage("File {0} does not exist.", filePath);
                }
            }
            else
            {
                e.Mobile.SendMessage("Usage: [ImportSpawners <filename>");
            }
        }
コード例 #13
0
ファイル: FindChar.cs プロジェクト: greeduomacro/last-wish
        public static void FindChar_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                string name = e.GetString(0).ToLower();

                foreach (Account pm in Accounts.GetAccounts())
                {
                    if (pm == null)
                        return;

                    int index = 0;

                    for (int i = 0; i < pm.Length; ++i)
                    {
                        Mobile m = pm[i];
                        if (m == null)
                            continue;
                        if (m.Name.ToLower().IndexOf(name) >= 0)
                        {
                            e.Mobile.SendMessage("Character '{0}' belongs to the account '{1}'.", m.Name, pm);

                        }
                        else
                            continue;

                        ++index;

                    }
                }
                e.Mobile.SendMessage("Done.");
            }
            else
            {
                e.Mobile.SendMessage("Usage: FindChar <name>");
            }
        }
コード例 #14
0
        public static void BM_OnCommand(CommandEventArgs e)
        {
            if (e.Mobile.AccessLevel == AccessLevel.Counselor)
            {
                e.Mobile.SendMessage(1365, "Counselors are not allowed to use Blue Magic");
                return;
            }
            else if (!BlueMageControl.IsBlueMage(e.Mobile) && e.Mobile.AccessLevel == AccessLevel.Player)
            {
                e.Mobile.SendMessage("You must be a blue mage to use this command.");
                return;
            }
            else if (!Multis.DesignContext.Check(e.Mobile))
            {
                return;                 // They are customizing their house
            }
            string spellstring = e.GetString(0).ToLower();

            if (spellstring == null || spellstring == "")
            {
                if (e.Mobile.HasGump(typeof(BlueSpellsKnownGump)))
                {
                    e.Mobile.CloseGump(typeof(BlueSpellsKnownGump));
                }

                e.Mobile.SendGump(new BlueSpellsKnownGump(e.Mobile));
            }
            else if (spellstring == "help")
            {
                e.Mobile.SendMessage(1365, "\"[bm\" + spellname (lower or upper case, it don't matter) to cast the spell.");
                e.Mobile.SendMessage(1365, "\"[bm\" opens a menu listing details on the spells you know.");
                e.Mobile.SendMessage(1365, "\"[bm study\" Allows you to try and study a corpse to learn a blue spell [requires high forensics]");

                if (e.Mobile.AccessLevel >= AccessLevel.GameMaster)
                {
                    e.Mobile.SendMessage(1365, "[Seer+] \"[bm get\" allows you to target a player and get their list of spell's known.");
                    e.Mobile.SendMessage(1365, "[Seer+] \"[bm giveitem\" Gives you most of the items a blue mage would use.");
                }

                if (e.Mobile.AccessLevel > AccessLevel.Seer)
                {
                    e.Mobile.SendMessage(1365, "[Admin+] \"[bm log\" opens a gump containing the information of all registered blue mages and spells known by them.");
                }
            }
            else if (spellstring == "get" && e.Mobile.AccessLevel >= AccessLevel.GameMaster)
            {
                e.Mobile.SendMessage(1365, "Target a player you get their list of spells known.");
                e.Mobile.Target = new SpellKnownTarget();
            }
            else if (spellstring == "log" && e.Mobile.AccessLevel > AccessLevel.Seer)
            {
                if (e.Mobile.HasGump(typeof(BlueMageLogGump)))
                {
                    e.Mobile.CloseGump(typeof(BlueMageLogGump));
                }

                e.Mobile.SendGump(new BlueMageLogGump());
            }
            else if (spellstring == "learnall" && e.Mobile.AccessLevel > AccessLevel.GameMaster)
            {
                BlueMageControl.LearnAll(e.Mobile);
                e.Mobile.SendMessage(1365, "Learning all blue spells");
            }
            else if (spellstring == "giveitems" && e.Mobile.AccessLevel > AccessLevel.GameMaster)
            {
                GiveItems(e.Mobile);
                e.Mobile.SendMessage(1365, "Giving Items");
            }
            else if (spellstring == "cave" /*&& e.Mobile.AccessLevel > AccessLevel.Player*/)
            {
                e.Mobile.MoveToWorld(new Point3D(1704, 591, 9), Map.Ilshenar);
            }
            else if (spellstring == "study")
            {
                if (e.Mobile.Skills[SkillName.Forensics].Value < 100.0)
                {
                    e.Mobile.SendMessage(1365, "Your Forensics isn't high enough to use this.");
                }
                else
                {
                    e.Mobile.Target = new StudyTarget();
                    e.Mobile.SendMessage(1365, "Target the corpse of a monster you killed to study it.");
                }
            }
            else if (spellstring == "giveall" && e.Mobile.AccessLevel > AccessLevel.Counselor)
            {
                BlueMageControl.LearnAll(e.Mobile);
                e.Mobile.SendMessage(1365, "Learning all blue spells");

                string prams = e.ArgString;

                if (prams.Contains("skills"))
                {
                    if (e.Mobile.Backpack != null)
                    {
                        e.Mobile.Backpack.DropItem(new BlueSkillBall(-1));
                    }
                }
                if (prams.Contains("items"))
                {
                    GiveItems(e.Mobile);
                }
            }

            else
            {
                int number = 100;
                try { number = Convert.ToInt32(spellstring); }
                catch {}

                if (number != 100)
                {
                    BlueSpellInfo.UseBluePower(e.Mobile, number);
                }
                else
                {
                    if (BlueSpellInfo.UseBluePower(e.Mobile, spellstring) == false)
                    {
                        e.Mobile.SendMessage("No such spell can be found.");
                    }
                }
            }
        }
コード例 #15
0
ファイル: XmlSockets.cs プロジェクト: jasegiffin/JustUO
            public override bool ValidateArgs(BaseCommandImplementor impl, CommandEventArgs e)
            {
                if (e.Arguments.Length >= 2)
                {
                    this.m_augmenttype = SpawnerType.GetType(e.GetString(0));

                    if (this.m_augmenttype == null)
                    {
                        e.Mobile.SendMessage("Unknown augment type: " + e.GetString(0));
                        return false;
                    }

                    this.m_oldversion = -1;
                    try
                    {
                        this.m_oldversion = int.Parse(e.GetString(1));
                    }
                    catch
                    {
                    }

                    if (this.m_oldversion != -1)
                    {
                        return true;
                    }
                }
				
                e.Mobile.SendMessage("Usage: " + this.Usage);
                return false;
            }
コード例 #16
0
ファイル: CALT.cs プロジェクト: alucardxlx/Ulmeta
        public static void CALT_onCommand(CommandEventArgs args)
        {
            Mobile      m         = args.Mobile;
            AccessLevel acctLevel = (m.Account == null ? AccessLevel.Player : ((Account)m.Account).AccessLevel);
            AccessLevel newLevel  = m.AccessLevel;

            if (acctLevel == AccessLevel.Player)
            {
                m.SendMessage("This command has no effect on your status.");
                return;
            }

            if (args.Length == 0)
            {
                newLevel = (m.AccessLevel == AccessLevel.Player ? acctLevel : AccessLevel.Player);
            }
            else if (args.Length == 1)
            {
                switch (args.GetString(0).ToLower())
                {
                case "player":
                {
                    newLevel = AccessLevel.Player;
                    break;
                }

                case "counselor":
                {
                    newLevel = AccessLevel.Counselor;
                    break;
                }

                case "gm":
                case "gamemaster":
                {
                    newLevel = AccessLevel.GameMaster;
                    break;
                }

                case "seer":
                {
                    newLevel = AccessLevel.Seer;
                    break;
                }

                case "admin":
                case "administrator":
                {
                    newLevel = AccessLevel.Administrator;
                    break;
                }

                default:
                {
                    m.SendMessage("Invalid paramater: {0}", args.GetString(0));
                    break;
                }
                }
            }

            if (newLevel > acctLevel)
            {
                m.SendMessage("You can only raise your level to '{0}'", acctLevel);
            }
            else if (newLevel == m.AccessLevel)
            {
                m.SendMessage("Your accesslevel is already set to '{0}'", newLevel);
            }
            else
            {
                m.AccessLevel = newLevel;
            }
        }
コード例 #17
0
        public static void Grab_OnCommand(CommandEventArgs e)
        {
            //   Get LootData attachment
            LootData lootoptions = new LootData();

            // does player already have a lootdata attachment?
            if (XmlAttach.FindAttachment(e.Mobile, typeof(LootData)) == null)
            {
                XmlAttach.AttachTo(e.Mobile, lootoptions);
                // give them one free lootbag
                e.Mobile.AddToBackpack(new LootBag());
            }
            else
            {
                // they have the attachment, just load their options
                lootoptions = (LootData)XmlAttach.FindAttachment(e.Mobile, typeof(LootData));
            }

            //   Check args to see if they want to change loot options
            // if we have args after  "grab"
            if (e.Length != 0)
            {
                // we need to set the loot bag
                if (e.GetString(0) != "options")
                {
                    e.Mobile.SendMessage("Typing the command [grab  by itself loots corpses of your victims. [grab options will allow you to decide what you want to loot.");
                }
                // show loot options gump
                else if (e.GetString(0) == "options")
                {
                    e.Mobile.SendGump(new LootGump(e.Mobile));
                }
            }

            //   Check loot legalities
            Mobile from = e.Mobile;

            if (from.Alive == false)
            {
                from.PlaySound(1069);                   //hey
                from.SendMessage("You cannot do that while you are dead!");
                return;
            }
            //else if ( 0 != CompetitiveGrabRadius && BlockingMobilesInRange( from, GrabRadius ))
            //{
            //	from.PlaySound( 1069 ); //hey
            //	from.SendMessage( "You are too close to another player to do that!" );
            //	return;
            //}

            ArrayList grounditems = new ArrayList();
            ArrayList lootitems   = new ArrayList();
            ArrayList corpses     = new ArrayList();
            Container lootBag     = GetLootBag(from);

            // Gather lootable corpses and items into lists
            foreach (Item item in from.GetItemsInRange(GrabRadius))
            {
                if (!from.InLOS(item) || !item.IsAccessibleTo(from) || !(item.Movable || item is Corpse))
                {
                    continue;
                }

                // add to corpse list if corpse
                if (item is Corpse && CorpseIsLootable(from, item as Corpse, false))                     // && item.Killer == from
                {
                    Corpse deadbody = item as Corpse;
                    if (deadbody.Killer == null)
                    {
                        corpses.Add(item);
                    }
                    else if (deadbody.Killer == from)
                    {
                        corpses.Add(item);
                    }
                    else if (deadbody.Killer is BaseCreature && !(deadbody.Killer is PlayerMobile))
                    {
                        BaseCreature pet = deadbody.Killer as BaseCreature;
                        if (pet.ControlMaster == from || pet.ControlMaster == null)
                        {
                            corpses.Add(item);
                        }
                    }
                }

                // otherwise add to ground items list if loot options indicate
//ORIGINALY HERE-Trying to clear up yellow startup saying that item moble never is
//				else if ( !( item is PlayerMobile ) )
//				{
//					if(lootoptions.GetGroundItems)
//						if (!(item is Corpse))
//							grounditems.Add( item );
//				}
//END ORIGINALY HERE
                else
                if (lootoptions.GetGroundItems)
                {
                    if (!(item is Corpse))
                    {
                        grounditems.Add(item);
                    }
                }
            }

            // see if we really want any of the junk lying on the ground
            GetItems(lootoptions, from, grounditems);

            grounditems.Clear();

            // now inspect and loot appropriate items in corpses
            foreach (Item corpse in corpses)
            {
                Corpse       bod = corpse as Corpse;
                PlayerMobile pm  = from as PlayerMobile;
                //pm.PlayerLevel += 1;

                /*                                          // Uncomment for eventual modifications (not to allow grabbing certain bodies)
                 * Mobile own = bod.Owner as Mobile;
                 * if( (own is Mobile1) || (own is Mobile2) )  // Change mobile names according to what you want to get
                 */
                {
                    // if we are looting hides/scales/meat then carve the corpse
                    if (lootoptions.GetHides && !(bod.Owner is PlayerMobile))
                    {
                        bod.Carve(from, null);
                    }

                    //rummage through the corpse for good stuff
                    foreach (Item item in bod.Items)
                    {
                        lootitems.Add(item);
                    }

                    //  now see if we really want any of this junk
                    GetItems(lootoptions, from, lootitems);

                    // alrighty then, we have all the items we want, now award gold for this corpse, delete it and increment the body count
//                    AwardGold(from, bod, lootBag); //REMED OUT SO THAT REGULAR MOBS WONT GIVE GOLD WHEN USE GRAB COMMAND
                    bod.Delete();

                    // empty lootitems arraylist
                    lootitems.Clear();
                }
            }
        }
コード例 #18
0
ファイル: XmlSpawner2.cs プロジェクト: mtPrimo/ServUO
		public static void XmlImportMSF_OnCommand(CommandEventArgs e)
		{
			if (e.Arguments.Length >= 1)
			{
				/*
				// I'm not sure what the default location for .msf files is
				string filename = e.GetString( 0 );
				string filePath = Path.Combine( "Data/Megaspawner", filename );
				*/
				string filePath = e.GetString(0);
				if (File.Exists(filePath))
				{
					XmlDocument doc = new XmlDocument();
					doc.Load(filePath);
					XmlElement root = doc["MegaSpawners"];
					if (root != null)
					{
						int successes = 0, failures = 0;
						foreach (XmlElement spawner in root.GetElementsByTagName("MegaSpawner"))
						{
							try
							{
								ImportMegaSpawner(e.Mobile, spawner);
								successes++;
							}
							catch (Exception ex)
							{
								e.Mobile.SendMessage(33, "{0} {1}", ex.Message, spawner.InnerText);
								failures++;
							}
						}
						e.Mobile.SendMessage(
							"{0} megaspawners loaded successfully from {1}, {2} failures.", successes, filePath, failures);
					}
					else
					{
						e.Mobile.SendMessage("Invalid .msf file. No MegaSpawners node found");
					}
				}
				else
				{
					e.Mobile.SendMessage("File {0} does not exist.", filePath);
				}
			}
			else
			{
				e.Mobile.SendMessage("Usage: [XmlImportMSF <filename>");
			}
		}
コード例 #19
0
ファイル: CSS.cs プロジェクト: evildude807/kaltar
        private static void CSSCast_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                if (!CentralMemory.Running || !CSS.Running)
                {
                    e.Mobile.SendMessage("The Central Memory is not running.  This command is disabled.");
                    return;
                }

                if (!Multis.DesignContext.Check(e.Mobile))
                {
                    e.Mobile.SendMessage("You cannot cast while customizing!");
                    return;
                }

                CastCommandsModule module = (CastCommandsModule)CentralMemory.GetModule(e.Mobile.Serial, typeof(CastCommandsModule));
                if (module == null)
                {
                    e.Mobile.SendMessage("You do not have any commands to cast stored.");
                    return;
                }

                CastInfo info = module.Get(e.GetString(0));
                if (info == null)
                {
                    e.Mobile.SendMessage("You have not assigned that command to any spells.");
                    return;
                }

                if (SpellRestrictions.UseRestrictions && !SpellRestrictions.CheckRestrictions(e.Mobile, info.SpellType))
                {
                    e.Mobile.SendMessage("You are not allowed to cast this spell.");
                    return;
                }

                if (!CSpellbook.MobileHasSpell(e.Mobile, info.School, info.SpellType))
                {
                    e.Mobile.SendMessage("You do not have this spell.");
                    return;
                }

                Spell spell = SpellInfoRegistry.NewSpell(info.SpellType, info.School, e.Mobile, null);
                if (spell != null)
                    spell.Cast();
                else
                    e.Mobile.SendMessage("This spell has been disabled.");
            }
            else
            {
                e.Mobile.SendMessage("Format: Cast <text>");
            }
        }
コード例 #20
0
ファイル: Handlers.cs プロジェクト: alucardxlx/Ulmeta
        public static void DeleteByType_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                Type type = ScriptCompiler.FindTypeByName(e.GetString(0), true);

                if (type == null)
                {
                    e.Mobile.SendMessage("No type with that name was found : {0}", e.GetString(0));
                }
                else
                {
                    if (type == typeof(Item) || type.IsSubclassOf(typeof(Item)))
                    {
                        ArrayList list       = new ArrayList();
                        bool      isAbstract = type.IsAbstract;

                        foreach (Item item in World.Items.Values)
                        {
                            if (isAbstract ? item.GetType().IsSubclassOf(type) : item.GetType() == type)
                            {
                                list.Add(item);
                            }
                        }

                        if (list.Count > 0)
                        {
                            CommandLogging.WriteLine(e.Mobile, "{0} {1} starting delete by type of {2} ({3} instances)", e.Mobile.AccessLevel, CommandLogging.Format(e.Mobile), type, list.Count);

                            e.Mobile.SendGump(
                                new WarningGump(1060635, 30720,
                                                String.Format("You are about to delete {0} item{1} from the world; <u>all {2} {3}</u><br><br>Do you really wish to continue?",
                                                              list.Count, list.Count == 1 ? "" : "s", isAbstract ? "instances derived from" : "instances of", type),
                                                0xFFC000, 360, 260, new WarningGumpCallback(DeleteList_Callback), list, true));
                        }
                        else
                        {
                            e.Mobile.SendMessage("There are no items in the world with that type.");
                        }
                    }
                    else if (type == typeof(Mobile) || type.IsSubclassOf(typeof(Mobile)))
                    {
                        ArrayList list       = new ArrayList();
                        bool      isAbstract = type.IsAbstract;
                        bool      hadPlayer  = false;

                        foreach (Mobile m in World.Mobiles.Values)
                        {
                            if (isAbstract ? m.GetType().IsSubclassOf(type) : m.GetType() == type)
                            {
                                if (m.Player)
                                {
                                    hadPlayer = true;
                                }
                                else
                                {
                                    list.Add(m);
                                }
                            }
                        }

                        if (list.Count > 0)
                        {
                            CommandLogging.WriteLine(e.Mobile, "{0} {1} starting delete by type of {2} ({3} instances)", e.Mobile.AccessLevel, CommandLogging.Format(e.Mobile), type, list.Count);

                            e.Mobile.SendGump(
                                new WarningGump(1060635, 30720,
                                                String.Format("You are about to delete {0} mobile{1} from the world; <u>all {2} {3}</u><br><br>Do you really wish to continue?",
                                                              list.Count, list.Count == 1 ? "" : "s", isAbstract ? "instances derived from" : "instances of", type),
                                                0xFFC000, 360, 260, new WarningGumpCallback(DeleteList_Callback), list));
                        }
                        else
                        {
                            if (hadPlayer)
                            {
                                e.Mobile.SendMessage("You may not delete players with this command.");
                            }
                            else
                            {
                                e.Mobile.SendMessage("There are no mobiles in the world with that type.");
                            }
                        }
                    }
                    else
                    {
                        e.Mobile.SendMessage("The type specified is not an item or mobile.");
                    }
                }
            }
            else
            {
                e.Mobile.SendMessage("Format: DeleteByType <typeName>");
            }
        }
コード例 #21
0
ファイル: XmlSpawner2.cs プロジェクト: mtPrimo/ServUO
			public override void Execute(CommandEventArgs e, object obj)
			{
				if (e.Length >= 2)
				{
					string result = BaseXmlSpawner.SetPropertyValue(null, obj, e.GetString(0), e.GetString(1));

					if (result == "Property has been set.")
					{
						AddResponse(result);
					}
					else
					{
						LogFailure(result);
					}
				}
				else
				{
					LogFailure("Format: XmlSet <propertyName> <value>");
				}
			}
コード例 #22
0
ファイル: Sort.cs プロジェクト: Orion321/unknown-shard
        public static void Sort_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // if we have a command after just the word "sort", as we should
            if (e.Length != 0)
            {
                switch (e.GetString(0).ToLower())
                {
                case "wands":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[9]);
                    break;

                case "gems":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[8]);
                    break;

                case "regs":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[4]);
                    break;

                case "scrolls":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[3]);
                    break;

                case "armor":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[0]);
                    break;

                case "clothing":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[2]);
                    break;

                case "weapons":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[1]);
                    break;

                case "hides":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[5]);
                    break;

                case "potions":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[6]);
                    break;

                case "jewelry":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.Target = new PackFromTarget(from, m_SortType[7]);
                    break;

                case "help":
                    from.LocalOverheadMessage(MessageType.Regular, 0x1150, true, "Select the container you want to sort FROM.");
                    from.LocalOverheadMessage(MessageType.Regular, 1150, true, "Usage: [sort and one of the following words: gems, wands, regs, scrolls, armor, weapons, clothing, potions, hides, jewelry");
                    break;

                default:
                    from.LocalOverheadMessage(MessageType.Regular, 1150, true, "Usage: [sort and one of the following words: gems, wands, regs, scrolls, armor, weapons, clothing, potions, hides, jewelry");
                    break;
                }
            }
            else
            {
                from.LocalOverheadMessage(MessageType.Regular, 1150, true, "Usage: [sort and one of the following words: gems, wands, regs, scrolls, armor, weapons, clothing, potions, hides, jewelry");
            }
        }
コード例 #23
0
		public static void MLQuestsInfo_OnCommand( CommandEventArgs e )
		{
			Mobile m = e.Mobile;

			if ( e.Length == 0 )
			{
				m.SendMessage( "Quest table length: {0}", m_Quests.Count );
				return;
			}

			Type index = ScriptCompiler.FindTypeByName( e.GetString( 0 ) );
			MLQuest quest;

			if ( index == null || !m_Quests.TryGetValue( index, out quest ) )
			{
				m.SendMessage( "Invalid quest type name." );
				return;
			}

			m.SendMessage( "Activated: {0}", quest.Activated );
			m.SendMessage( "Number of objectives: {0}", quest.Objectives.Count );
			m.SendMessage( "Objective type: {0}", quest.ObjectiveType );
			m.SendMessage( "Number of active instances: {0}", quest.Instances.Count );
		}
コード例 #24
0
        public static void Grab_OnCommand(CommandEventArgs e)
        {
            //   Get LootData attachment
            LootData lootoptions = new LootData();

            // does player already have a lootdata attachment?
            if (XmlAttach.FindAttachment(e.Mobile, typeof(LootData)) == null)
            {
                XmlAttach.AttachTo(e.Mobile, lootoptions);
                // give them one free DocLootBag
                e.Mobile.AddToBackpack(new DocLootBag());
            }
            else
            {
                // they have the attachment, just load their options
                lootoptions = (LootData)XmlAttach.FindAttachment(e.Mobile, typeof(LootData));
            }

            //   Check args to see if they want to change loot options
            // if we have args after  "grab"
            if (e.Length != 0)
            {
                // we need to set the loot bag
                if (e.GetString(0) != "options")
                {
                    e.Mobile.SendMessage("Typing the command [grab  by itself loots corpses of your victims. [grab options will allow you to decide what you want to loot.");
                }
                // show loot options gump
                else if (e.GetString(0) == "options")
                {
                    e.Mobile.SendGump(new LootGump(e.Mobile));
                }
            }

            //   Check loot legalities
            Mobile from = e.Mobile;

            if (from.Alive == false)
            {
                from.PlaySound(1069);                   //hey
                from.SendMessage("You cannot do that while you are dead!");
                return;
            }
            else if (0 != CompetitiveGrabRadius && BlockingMobilesInRange(from, GrabRadius))
            {
                from.PlaySound(1069);                   //hey
                from.SendMessage("You are too close to another player to do that!");
                return;
            }

            ArrayList grounditems = new ArrayList();
            ArrayList lootitems   = new ArrayList();
            ArrayList corpses     = new ArrayList();
            Container DocLootBag  = GetLootBag(from);

            // Gather lootable corpses and items into lists
            foreach (Item item in from.GetItemsInRange(GrabRadius))
            {
                if (!from.InLOS(item) || !item.IsAccessibleTo(from) || !(item.Movable || item is Corpse))
                {
                    continue;
                }

                // add to corpse list if corpse
                if (item is Corpse && CorpseIsLootable(from, item as Corpse, false))
                {
                    corpses.Add(item);
                }

                // otherwise add to ground items list if loot options indicate
                else
                if (lootoptions.GetGroundItems)
                {
                    if (!(item is Corpse))
                    {
                        grounditems.Add(item);
                    }
                }
            }

            // see if we really want any of the junk lying on the ground
            GetItems(lootoptions, from, grounditems);

            grounditems.Clear();

            // now inspect and loot appropriate items in corpses
            foreach (Item corpse in corpses)
            {
                Corpse bod = corpse as Corpse;

                // if we are looting hides/scales/meat then carve the corpse
                if (lootoptions.GetHides && !(bod.Owner is PlayerMobile))
                {
                    bod.Carve(from, null);
                }

                //rummage through the corpse for good stuff
                foreach (Item item in bod.Items)
                {
                    lootitems.Add(item);
                }

                //  now see if we really want any of this junk
                GetItems(lootoptions, from, lootitems);

                // alrighty then, we have all the items we want, now award gold for this corpse, delete it and increment the body count
                AwardGold(from, bod, DocLootBag);
                bod.Delete();

                // empty lootitems arraylist
                lootitems.Clear();
            }
        }
コード例 #25
0
ファイル: SendGump.cs プロジェクト: greeduomacro/last-wish
        public static void SendGump_OnCommand(CommandEventArgs e)
        {
            if (e.Length >= 1)
            {
                Type t = ScriptCompiler.FindTypeByName(e.GetString(0));

                if (t == null)
                {
                    e.Mobile.SendMessage("No Gump with that name was found.");
                }
                else
                {
                    e.Mobile.Target = new SendGumpTarget(e.Arguments);
                }
            }
            else
            {
                e.Mobile.SendMessage("Format: SendGump <name> [params]");
            }
        }
コード例 #26
0
ファイル: Handlers.cs プロジェクト: Grimoric/RunUO.T2A
		public static void Cast_OnCommand( CommandEventArgs e )
		{
			if ( e.Length == 1 )
			{
				Spell spell = SpellRegistry.NewSpell( e.GetString( 0 ), e.Mobile, null );

				if ( spell != null )
					spell.Cast();
				else
					e.Mobile.SendMessage( "That spell was not found." );
			}
			else
			{
				e.Mobile.SendMessage( "Format: Cast <name>" );
			}
		}
コード例 #27
0
ファイル: Handlers.cs プロジェクト: FreeReign/forkuo
        private static void Go_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            if (e.Length == 0)
            {
                GoGump.DisplayTo(from);
                return;
            }

            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) && !BaseCommand.IsAccessible(from, owner) /* !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.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) && !BaseCommand.IsAccessible(from, owner) /* !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.MoveToWorld(loc, map);

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

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            map = Map.AllMaps[i];

                            if (map.MapIndex == 0x7F || map.MapIndex == 0xFF)
                                continue;

                            if (Insensitive.Equals(name, map.Name))
                            {
                                from.Map = map;
                                return;
                            }
                        }

                        Dictionary<string, Region> list = from.Map.Regions;

                        foreach (KeyValuePair<string, Region> kvp in list)
                        {
                            Region r = kvp.Value;

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

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            Map m = Map.AllMaps[i];

                            if (m.MapIndex == 0x7F || m.MapIndex == 0xFF || from.Map == m)
                                continue;

                            foreach (Region r in m.Regions.Values)
                            {
                                if (Insensitive.Equals(r.Name, name))
                                {
                                    from.MoveToWorld(r.GoLocation, m);
                                    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 || e.Length == 3)
            {
                Map map = from.Map;

                if (map != null)
                {
                    try
                    {
                        /*
                        * This to avoid being teleported to (0,0) if trying to teleport
                        * to a region with spaces in its name.
                        */
                        int x = int.Parse(e.GetString(0));
                        int y = int.Parse(e.GetString(1));
                        int z = (e.Length == 3) ? int.Parse(e.GetString(2)) : map.GetAverageZ(x, y);

                        from.Location = new Point3D(x, y, z);
                    }
                    catch
                    {
                        from.SendMessage("Region name not found.");
                    }
                }
            }
            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.SendMessage("Sextant reverse lookup failed.");
                }
            }
            else
            {
                from.SendMessage("Format: Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W)]");
            }
        }
コード例 #28
0
        private static void Go_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            if (e.Length == 0)
            {
                GoGump.DisplayTo(from);
                return;
            }

            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) && !BaseCommand.IsAccessible(from, owner) /* !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.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) && !BaseCommand.IsAccessible(from, owner) /* !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.MoveToWorld(loc, map);

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

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            map = Map.AllMaps[i];

                            if (map.MapIndex == 0x7F || map.MapIndex == 0xFF)
                            {
                                continue;
                            }

                            if (Insensitive.Equals(name, map.Name))
                            {
                                from.Map = map;
                                return;
                            }
                        }

                        Dictionary <string, Region> list = from.Map.Regions;

                        foreach (KeyValuePair <string, Region> kvp in list)
                        {
                            Region r = kvp.Value;

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

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            Map m = Map.AllMaps[i];

                            if (m.MapIndex == 0x7F || m.MapIndex == 0xFF || from.Map == m)
                            {
                                continue;
                            }

                            foreach (Region r in m.Regions.Values)
                            {
                                if (Insensitive.Equals(r.Name, name))
                                {
                                    from.MoveToWorld(r.GoLocation, m);
                                    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 || e.Length == 3)
            {
                Map map = from.Map;

                if (map != null)
                {
                    try
                    {
                        /*
                         * This to avoid being teleported to (0,0) if trying to teleport
                         * to a region with spaces in its name.
                         */
                        int x = int.Parse(e.GetString(0));
                        int y = int.Parse(e.GetString(1));
                        int z = (e.Length == 3) ? int.Parse(e.GetString(2)) : map.GetAverageZ(x, y);

                        from.Location = new Point3D(x, y, z);
                    }
                    catch
                    {
                        from.SendMessage("Region name not found.");
                    }
                }
            }
            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.SendMessage("Sextant reverse lookup failed.");
                    }
                }
            }
            else
            {
                from.SendMessage("Format: Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W)]");
            }
        }
コード例 #29
0
		public static void SaveQuest_OnCommand( CommandEventArgs e )
		{
			Mobile m = e.Mobile;

			if ( e.Length == 0 || e.Length > 2 )
			{
				m.SendMessage( "Syntax: SaveQuest <id> [saveEnabled=true]" );
				return;
			}

			Type index = ScriptCompiler.FindTypeByName( e.GetString( 0 ) );
			MLQuest quest;

			if ( index == null || !m_Quests.TryGetValue( index, out quest ) )
			{
				m.SendMessage( "Invalid quest type name." );
				return;
			}

			bool enable = ( e.Length == 2 ) ? e.GetBoolean( 1 ) : true;

			quest.SaveEnabled = enable;
			m.SendMessage( "Serialization for quest {0} is now {1}.", quest.GetType().Name, enable ? "enabled" : "disabled" );

			if ( AutoGenerateNew && !enable )
				m.SendMessage( "Please note that automatic generation of new quests is ON. This quest will be regenerated on the next server start." );
		}
コード例 #30
0
ファイル: Handlers.cs プロジェクト: greeduomacro/hubroot
		public static void DeleteByType_OnCommand( CommandEventArgs e )
		{
			if( e.Length == 1 )
			{
				Type type = ScriptCompiler.FindTypeByName( e.GetString( 0 ), true );

				if( type == null )
				{
					e.Mobile.SendMessage( "No type with that name was found : {0}", e.GetString( 0 ) );
				}
				else
				{
					if( type == typeof( Item ) || type.IsSubclassOf( typeof( Item ) ) )
					{
						ArrayList list = new ArrayList();
						bool isAbstract = type.IsAbstract;

						foreach( Item item in World.Items.Values )
						{
							if( isAbstract ? item.GetType().IsSubclassOf( type ) : item.GetType() == type )
								list.Add( item );
						}

						if( list.Count > 0 )
						{
							CommandLogging.WriteLine( e.Mobile, "{0} {1} starting delete by type of {2} ({3} instances)", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), type, list.Count );

							e.Mobile.SendGump(
								new WarningGump( 1060635, 30720,
								String.Format( "You are about to delete {0} item{1} from the world; <u>all {2} {3}</u><br><br>Do you really wish to continue?",
								list.Count, list.Count == 1 ? "" : "s", isAbstract ? "instances derived from" : "instances of", type ),
								0xFFC000, 360, 260, new WarningGumpCallback( DeleteList_Callback ), list, true ) );
						}
						else
						{
							e.Mobile.SendMessage( "There are no items in the world with that type." );
						}
					}
					else if( type == typeof( Mobile ) || type.IsSubclassOf( typeof( Mobile ) ) )
					{
						ArrayList list = new ArrayList();
						bool isAbstract = type.IsAbstract;
						bool hadPlayer = false;

						foreach( Mobile m in World.Mobiles.Values )
						{
							if( isAbstract ? m.GetType().IsSubclassOf( type ) : m.GetType() == type )
							{
								if( m.Player )
									hadPlayer = true;
								else
									list.Add( m );
							}
						}

						if( list.Count > 0 )
						{
							CommandLogging.WriteLine( e.Mobile, "{0} {1} starting delete by type of {2} ({3} instances)", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), type, list.Count );

							e.Mobile.SendGump(
								new WarningGump( 1060635, 30720,
								String.Format( "You are about to delete {0} mobile{1} from the world; <u>all {2} {3}</u><br><br>Do you really wish to continue?",
								list.Count, list.Count == 1 ? "" : "s", isAbstract ? "instances derived from" : "instances of", type ),
								0xFFC000, 360, 260, new WarningGumpCallback( DeleteList_Callback ), list ) );
						}
						else
						{
							if( hadPlayer )
								e.Mobile.SendMessage( "You may not delete players with this command." );
							else
								e.Mobile.SendMessage( "There are no mobiles in the world with that type." );
						}
					}
					else
					{
						e.Mobile.SendMessage( "The type specified is not an item or mobile." );
					}
				}
			}
			else
			{
				e.Mobile.SendMessage( "Format: DeleteByType <typeName>" );
			}
		}
コード例 #31
0
ファイル: XmlSpawner2.cs プロジェクト: mtPrimo/ServUO
		public static void XmlImportSpawners_OnCommand(CommandEventArgs e)
		{
			if (e.Arguments.Length >= 1)
			{
				string filename = e.GetString(0);
				string filePath = Path.Combine("Saves/Spawners", filename);
				if (File.Exists(filePath))
				{
					XmlDocument doc = new XmlDocument();
					try
					{
						doc.Load(filePath);
					}
					catch
					{
						e.Mobile.SendMessage("unable to load file {0}.", filePath);
						return;
					}

					XmlElement root = doc["spawners"];
					int successes = 0, failures = 0;
					if (root != null && root.GetElementsByTagName("spawner") != null)
					{
						foreach (XmlElement spawner in root.GetElementsByTagName("spawner"))
						{
							try
							{
								ImportSpawner(spawner, e.Mobile);
								successes++;
							}
							catch (Exception ex)
							{
								e.Mobile.SendMessage(33, "{0} {1}", ex.Message, spawner.InnerText);
								failures++;
							}
						}
					}
					e.Mobile.SendMessage("{0} spawners loaded successfully from {1}, {2} failures.", successes, filePath, failures);
				}
				else
				{
					e.Mobile.SendMessage("File {0} does not exist.", filePath);
				}
			}
			else
			{
				e.Mobile.SendMessage("Usage: [XmlImportSpawners <filename>");
			}
		}
コード例 #32
0
        public static void AddressDump_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // check arguments
            if (e.Length < 1)
            {
                Usage(from);
                return;
            }

            int iChecked  = 0;
            int Reminders = 0;

            try
            {
                // loop through the accouints looking for current users
                ArrayList results = new ArrayList();

                // assume DaysActive
                if (e.Length == 1 && LooksLikeInt(e.GetString(0)))
                {
                    int days = 0;
                    try { days = Convert.ToInt32(e.GetString(0)); }
                    catch { Usage(from); return; }
                    foreach (Account acct in Accounts.Table.Values)
                    {
                        iChecked++;
                        // logged in the last n days.
                        if (Server.Engines.CronScheduler.EmailHelpers.RecentLogin(acct, days) == true)
                        {
                            if (ValidEmail(acct.EmailAddress))
                            {
                                Reminders++;
                                results.Add(acct.EmailAddress);
                            }
                        }
                    }
                }
                // assume activations since date
                else
                {
                    string buff = null;
                    for (int ix = 0; ix < e.Length; ix++)
                    {
                        buff += e.GetString(ix) + " ";
                    }

                    DateTime Since;
                    try { Since = DateTime.Parse(buff); }
                    catch { Usage(from); return; }

                    foreach (Account acct in Accounts.Table.Values)
                    {
                        iChecked++;
                        // account created since...
                        if (acct.Created >= Since && acct.EmailAddress != null)
                        {
                            if (ValidEmail(acct.EmailAddress))
                            {
                                Reminders++;
                                results.Add(acct.EmailAddress);
                            }
                        }
                    }
                }

                if (Reminders > 0)
                {
                    from.SendMessage("Logging {0} email address(es).", Reminders);
                    LogHelper Logger = new LogHelper("accountEmails.log", true);

                    foreach (object ox in results)
                    {
                        string address = ox as string;
                        if (address == null)
                        {
                            continue;
                        }
                        Logger.Log(LogType.Text, address);
                    }
                    Logger.Finish();
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Exception Caught in generic emailer: " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }

            return;
        }
コード例 #33
0
        public static void FindMobile_OnCommand(CommandEventArgs e)
        {
            if (e.Length > 1)
            {
                LogHelper Logger = new LogHelper("findMobile.log", e.Mobile, false);

                // Extract property & value from command parameters

                string sProp = e.GetString(0);
                string sVal  = "";

                if (e.Length > 2)
                {
                    sVal = e.GetString(1);

                    // Concatenate the strings
                    for (int argi = 2; argi < e.Length; argi++)
                    {
                        sVal += " " + e.GetString(argi);
                    }
                }
                else
                {
                    sVal = e.GetString(1);
                }

                Regex PattMatch = new Regex("= \"*" + sVal, RegexOptions.IgnoreCase);

                // Loop through assemblies and add type if has property

                Type[]     types;
                Assembly[] asms = ScriptCompiler.Assemblies;

                ArrayList MatchTypes = new ArrayList();

                for (int i = 0; i < asms.Length; ++i)
                {
                    types = ScriptCompiler.GetTypeCache(asms[i]).Types;

                    foreach (Type t in types)
                    {
                        if (typeof(Mobile).IsAssignableFrom(t))
                        {
                            // Reflect type
                            PropertyInfo[] allProps = t.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                            foreach (PropertyInfo prop in allProps)
                            {
                                if (prop.Name.ToLower() == sProp.ToLower())
                                {
                                    MatchTypes.Add(t);
                                }
                            }
                        }
                    }
                }

                // Loop items and check vs. types

                foreach (Mobile m in World.Mobiles.Values)
                {
                    Type t     = m.GetType();
                    bool match = false;

                    foreach (Type MatchType in MatchTypes)
                    {
                        if (t == MatchType)
                        {
                            match = true;
                            break;
                        }
                    }

                    if (match == false)
                    {
                        continue;
                    }

                    // Reflect instance of type (matched)

                    if (PattMatch.IsMatch(Properties.GetValue(e.Mobile, m, sProp)))
                    {
                        Logger.Log(LogType.Mobile, m);
                    }
                }

                Logger.Finish();
            }
            else
            {
                // Badly formatted
                e.Mobile.SendMessage("Format: FindMobile <property> <value>");
            }
        }
コード例 #34
0
ファイル: SendTo.cs プロジェクト: zerodowned/Ulmeta
        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);

                        System.Collections.Generic.Dictionary <string, Region> dict = from.Map.Regions;

                        foreach (System.Collections.Generic.KeyValuePair <string, Region> kvp in dict)
                        {
                            Region r = kvp.Value;

                            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)]");
            }
        }
コード例 #35
0
        private static void OnCommand_ImportFileBasedBuilding(CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            if (e.Length == 1)
            {
                string name = e.GetString(0);
                if (FileBasedBuilding.ImportBuilding(name))
                {
                    FileBasedBuilding.SeperateData.Save();
                    m.SendMessage("The building has been succesfully imported and is ready to be used.");
                }
                else
                    m.SendMessage("The building could not be imported, either the file does not exist or an error occured dureing the load.");
            }

            else
                m.SendMessage("Wrong format: [Command] [buildingname] >> [buildingname] = filename without .bin (castle.bin = castle)");
        }
コード例 #36
0
        public static void AC_OnCommand(CommandEventArgs e)
        {
            if (!AssassinControl.IsAssassin(e.Mobile) && e.Mobile.AccessLevel == AccessLevel.Player)
            {
                e.Mobile.SendMessage(1194, "You must be an assassin to use this command.");
                return;
            }
            else if (!Multis.DesignContext.Check(e.Mobile))
            {
                return;                 // They are customizing their house
            }
            string words = e.GetString(0).ToLower();

            if (words == null || words == "")
            {
                e.Mobile.CloseGump(typeof(AssassinSkillsGump));
                e.Mobile.SendGump(new AssassinSkillsGump(e.Mobile));
            }
            else if (words == "help")
            {
                e.Mobile.SendMessage(1194, "\"[ACreed\" opens the assassin's skills menu where you can use other weapon abilities.");
                e.Mobile.SendMessage(1194, "\"[ACreed assassinate\" sets your weapon ability to Assassinate.");
                e.Mobile.SendMessage(1194, "\"[ACreed armorignore\" sets your weapon ability to Armor Ignore.");
                e.Mobile.SendMessage(1194, "\"[ACreed bleedattack\" sets your weapon ability to Bleed Attack.");
                e.Mobile.SendMessage(1194, "\"[ACreed mortalstrike\" sets your weapon ability to Mortal Strike.");
                e.Mobile.SendMessage(1194, "\"[ACreed shadowstrike\" sets your weapon ability to Shadow Strike.");
                e.Mobile.SendMessage(1194, "\"[ACreed heal\" Attempts to heal. In order of attempts; assassin's belt, bandage, heal potions.");
                e.Mobile.SendMessage(1194, "\"[ACreed title\" Updates your Assassin title based on assassin gear worn.");
                //e.Mobile.SendMessage( 1194, "\"[ACreed travel\" opens a special assassin only recall/mark menu.");
            }
            else if (words == "assassinate")
            {
                SpecialMove.SetCurrentMove(e.Mobile, new AssassinateMove());
                e.Mobile.SendMessage(1194, "You prepare to use Assassinate.");
            }
            else if (words == "armorignore")
            {
                SpecialMove.SetCurrentMove(e.Mobile, new ArmorIgnoreMove());
                e.Mobile.SendMessage(1194, "You prepare to use Armor Ignore");
            }
            else if (words == "bleedattack")
            {
                SpecialMove.SetCurrentMove(e.Mobile, new BleedAttackMove());
                e.Mobile.SendMessage(1194, "You prepare to use Bleed Attack");
            }
            else if (words == "mortalstrike")
            {
                SpecialMove.SetCurrentMove(e.Mobile, new MortalStrikeMove());
                e.Mobile.SendMessage(1194, "You prepare to use Mortal Strike");
            }
            else if (words == "shadowstrike")
            {
                SpecialMove.SetCurrentMove(e.Mobile, new ShadowStrikeMove());
                e.Mobile.SendMessage(1194, "You prepare to use Shadow Strike");
            }
            else if (words == "heal")
            {
                if (e.Mobile.Hits == e.Mobile.HitsMax)
                {
                    e.Mobile.SendMessage(1194, "You are already at full life.");
                    return;
                }

                // Belt
                ACreedBelt belt = e.Mobile.FindItemOnLayer(Layer.Waist) as ACreedBelt;

                if (belt != null)
                {
                    if (DateTime.Now > belt.HealDelay)
                    {
                        belt.OnDoubleClick(e.Mobile);
                        return;
                    }
                }

                if (e.Mobile.Backpack == null)
                {
                    return;
                }

                // Bandage
                if (e.Mobile.Backpack.ConsumeTotal(typeof(Bandage), 1))
                {
                    if (BandageContext.GetContext(e.Mobile) == null)
                    {
                        e.Mobile.SendLocalizedMessage(500956);                           // You begin applying the bandages.
                        BandageContext.BeginHeal(e.Mobile, e.Mobile);
                        return;
                    }
                }

                // Heal Potions
                BaseHealPotion potion = e.Mobile.Backpack.FindItemByType(typeof(GreaterHealPotion)) as BaseHealPotion;

                if (potion == null)
                {
                    potion = e.Mobile.Backpack.FindItemByType(typeof(HealPotion)) as BaseHealPotion;
                }
                if (potion == null)
                {
                    potion = e.Mobile.Backpack.FindItemByType(typeof(LesserHealPotion)) as BaseHealPotion;
                }

                if (potion != null)
                {
                    potion.OnDoubleClick(e.Mobile);
                    return;
                }

                e.Mobile.SendMessage(1194, "No way to heal found.");
            }
            else if (words == "title")
            {
                int gear = 0;

                if (e.Mobile.FindItemOnLayer(Layer.Helm) is ACreedGarb)                     // Chain Coif
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Neck) is ACreedGarb)                     // Mempo
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.MiddleTorso) is ACreedGarb)                     // Jin Bori
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.InnerTorso) is ACreedGarb)                     // Studded Chest
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Waist) is ACreedGarb)                     // Belt
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Pants) is ACreedGarb)                     // Thigh Boots
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Shoes) is ACreedGarb)                     // Skirt
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Arms) is ACreedGarb)                     // Bone Arms
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.OuterLegs) is ACreedGarb)                     // Kilt
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Shirt) is ACreedGarb)                     // Shirt
                {
                    ++gear;
                }
                if (e.Mobile.FindItemOnLayer(Layer.Gloves) is ACreedGarb)                     // Gloves
                {
                    ++gear;
                }

                switch (gear)
                {
                case 0:
                case 1: e.Mobile.Title = "the Thief"; break;

                case 2:
                case 3: e.Mobile.Title = "the Rogue"; break;

                case 4:
                case 5: e.Mobile.Title = "the Assassin"; break;

                case 6:
                case 7: e.Mobile.Title = "the Skilled Assassin"; break;

                case 8:
                case 9: e.Mobile.Title = "the Master Assassin"; break;

                case 10:
                case 11: e.Mobile.Title = "the Grandmaster Assassin"; break;
                }
            }
            else if (words == "travel")
            {
                // Todo: Finish
                e.Mobile.CloseGump(typeof(AssassinSkillsGump));
                e.Mobile.SendGump(new AssassinSkillsGump(e.Mobile));
            }
        }
コード例 #37
0
        public static void Announcement_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // check arguments
            if (e.Length != 3)
            {
                Usage(from);
                return;
            }

            // can only be run on Test Center
            if (TestCenter.Enabled == false)
            {
                from.SendMessage("This command may only be executed on Test Center.");
                return;
            }

            int iChecked  = 0;
            int Reminders = 0;

            try
            {
                // loop through the accouints looking for current users
                ArrayList results = new ArrayList();

                int days = 0;
                try { days = Convert.ToInt32(e.GetString(0)); }
                catch { Usage(from); return; }

                foreach (Account acct in Accounts.Table.Values)
                {
                    iChecked++;
                    // logged in the last n days.
                    if (Server.Engines.CronScheduler.EmailHelpers.RecentLogin(acct, days) == true)
                    {
                        Reminders++;
                        results.Add(acct.EmailAddress);
                    }
                }

                if (Reminders > 0)
                {
                    from.SendMessage("Sending {0} email announcement(s).", Reminders);

                    string subject = String.Format(e.GetString(1));
                    string body    = null;

                    try
                    {
                        // create reader & open file
                        TextReader tr = new StreamReader(String.Format("Msgs/{0}", e.GetString(2)));

                        // read it
                        body = tr.ReadToEnd();

                        // close the stream
                        tr.Close();
                    }
                    catch (Exception ex)
                    {
                        LogHelper.LogException(ex);
                        from.SendMessage(ex.Message);
                        Usage(from);
                        return;
                    }

                    // okay, now hand the list of users off to our mailer daemon
                    new Emailer().SendEmail(results, subject, body, false);
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Exception Caught in generic emailer: " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }

            return;
        }
コード例 #38
0
ファイル: XmlSockets.cs プロジェクト: jasegiffin/JustUO
            public override bool ValidateArgs(BaseCommandImplementor impl, CommandEventArgs e)
            {
                if (e.Arguments.Length >= 1)
                {
                    try
                    {
                        this.m_maxsockets = int.Parse(e.GetString(0));
                    }
                    catch
                    {
                        e.Mobile.SendMessage("Usage: " + this.Usage);
                        return false;
                    }

                    return true;
                }
				
                e.Mobile.SendMessage("Usage: " + this.Usage);
                return false;
            }
コード例 #39
0
        public static void FindItemByType_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false)
                {
                    return;
                }

                string name = null;

                if (e.Length >= 1)
                {
                    name = e.GetString(0);

                    // if you are a GM the world needs to be in 'Build' mode to access this comand
                    if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false)
                    {
                        e.Mobile.SendMessage("The server must be in build mode for you to access this command.");
                        return;
                    }

                    PlayerMobile pm     = e.Mobile as PlayerMobile;
                    LogHelper    Logger = new LogHelper("FindNPCResourceByType.log", e.Mobile, false);

                    // reset jump table
                    pm.JumpIndex = 0;
                    pm.JumpList  = new ArrayList();
                    Type tx = ScriptCompiler.FindTypeByName(name);

                    if (tx != null)
                    {
                        foreach (Mobile mob in World.Mobiles.Values)
                        {
                            if (mob is BaseVendor == false)
                            {
                                continue;
                            }

                            BaseVendor vendor = mob as BaseVendor;

                            if (vendor.Inventory == null || vendor.Inventory.Count == 0)
                            {
                                continue;
                            }

                            foreach (object ox in vendor.Inventory)
                            {
                                if (ox is SBInfo == false)
                                {
                                    continue;
                                }

                                SBInfo sbi = ox as SBInfo;

                                if (sbi.BuyInfo == null || sbi.BuyInfo.Count == 0)
                                {
                                    continue;
                                }

                                ArrayList bi = sbi.BuyInfo;

                                foreach (GenericBuyInfo gbi in bi)
                                {
                                    if (tx.IsAssignableFrom(gbi.Type))
                                    {
                                        pm.JumpList.Add(vendor);
                                        Logger.Log(LogType.Mobile, vendor);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        e.Mobile.SendMessage("{0} is not a recognized type.", name);
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindNPCResourceByType <type>");
                }
            }
            catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
        }
コード例 #40
0
        public static void ReplaceItemByType_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 2)
            {
                Type OldItem = ScriptCompiler.FindTypeByName(e.GetString(0), true);
                Type NewItem = ScriptCompiler.FindTypeByName(e.GetString(1), true);

                ArrayList OldItemslist = new ArrayList();

                foreach (Item item in World.Items.Values)
                {
                    if (item.GetType() == OldItem)
                    {
                        OldItemslist.Add(item);
                    }
                }

                e.Mobile.SendMessage("ReplaceItemByType " + OldItemslist.Count + "] items");

                for (int i = 0; i < OldItemslist.Count; i++)
                {
                    Item item    = (Item)OldItemslist[i];
                    Item ItemNew = null;
                    try
                    {
                        ItemNew = Activator.CreateInstance(NewItem) as Item;
                    }
                    catch { e.Mobile.SendMessage("An error has ocurred or invalid item type... Please Check Format: ReplaceItemByType <OldItemType> <NewItemType>"); }

                    if (ItemNew != null)
                    {
                        if (item.Parent is BaseCreature)
                        {
                            item.Delete();
                        }
                        else if (item.Parent is PlayerMobile)
                        {
                            PlayerMobile pm   = (PlayerMobile)item.Parent;
                            Container    cont = pm.Backpack;
                            if (!item.Movable)
                            {
                                ItemNew.Movable = false;
                            }

                            item.Delete();
                            cont.DropItem(ItemNew);

                            ItemNew.Amount   = item.Amount;
                            ItemNew.LootType = item.LootType;
                        }
                        else if (item.Parent is Container)
                        {
                            Container cont = (Container)item.Parent;
                            if (!item.Movable)
                            {
                                ItemNew.Movable = false;
                            }

                            item.Delete();
                            cont.DropItem(ItemNew);

                            ItemNew.Amount   = item.Amount;
                            ItemNew.LootType = item.LootType;
                        }
                        else
                        {
                            ItemNew.MoveToWorld(item.Location, item.Map);
                            if (!item.Movable)
                            {
                                ItemNew.Movable = false;
                            }

                            ItemNew.Amount   = item.Amount;
                            ItemNew.LootType = item.LootType;

                            item.Delete();
                        }
                    }
                }
                e.Mobile.SendMessage("ReplaceItemByType Complete!");
            }
            else
            {
                e.Mobile.SendMessage("Format: ReplaceItemByType <OldItemType> <NewItemType>");
            }
        }
コード例 #41
0
ファイル: SpawnEntry.cs プロジェクト: m309/ForkUO
        private static BaseRegion GetCommandData(CommandEventArgs args)
        {
            Mobile from = args.Mobile;

            Region reg;
            if (args.Length == 0)
            {
                reg = from.Region;
            }
            else
            {
                string name = args.GetString(0);
                //reg = (Region) from.Map.Regions[name];

                if (!from.Map.Regions.TryGetValue(name, out reg))
                {
                    from.SendMessage("Could not find region '{0}'.", name);
                    return null;
                }
            }

            BaseRegion br = reg as BaseRegion;

            if (br == null || br.Spawns == null)
            {
                from.SendMessage("There are no spawners in region '{0}'.", reg);
                return null;
            }

            return br;
        }
コード例 #42
0
        public static void FindItemByType_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false)
                {
                    return;
                }

                string sProp = null;
                string sVal  = null;
                string name  = null;

                if (e.Length >= 1)
                {
                    name = e.GetString(0);

                    if (e.Length >= 2)
                    {
                        sProp = e.GetString(1);
                    }

                    if (e.Length >= 3)
                    {
                        sVal = e.GetString(2);
                    }

                    // if you are a GM the world needs to be in 'Build' mode to access this comand
                    if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false)
                    {
                        e.Mobile.SendMessage("The server must be in build mode for you to access this command.");
                        return;
                    }

                    PlayerMobile pm     = e.Mobile as PlayerMobile;
                    LogHelper    Logger = new LogHelper("FindItemByType.log", e.Mobile, false);

                    // reset jump table
                    pm.JumpIndex = 0;
                    pm.JumpList  = new ArrayList();
                    Type tx = ScriptCompiler.FindTypeByName(name);

                    if (tx != null)
                    {
                        foreach (Item item in World.Items.Values)
                        {
                            if (item != null && !item.Deleted && tx.IsAssignableFrom(item.GetType()))
                            {
                                // read the properties
                                PropertyInfo[] allProps = item.GetType().GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                                if (sProp != null)
                                {
                                    foreach (PropertyInfo prop in allProps)
                                    {
                                        if (prop.Name.ToLower() == sProp.ToLower())
                                        {
                                            bool   ok  = false;
                                            string val = Properties.GetValue(e.Mobile, item, sProp);

                                            // match a null value
                                            if ((val == null || val.Length == 0 || val.EndsWith("(-null-)", StringComparison.CurrentCultureIgnoreCase)) && (sVal == null || sVal.Length == 0))
                                            {
                                                ok = true;
                                            }

                                            // see if the property matches
                                            else if (val != null && sVal != null)
                                            {
                                                string[] toks = val.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                                if (toks.Length >= 3 && toks[2].Equals(sVal, StringComparison.CurrentCultureIgnoreCase))
                                                {
                                                    ok = true;
                                                }
                                                else
                                                {
                                                    break;
                                                }
                                            }

                                            if (ok)
                                            {
                                                pm.JumpList.Add(item);
                                                Logger.Log(LogType.Item, item);
                                                break;
                                            }
                                        }
                                    }
                                }
                                else
                                {                                       // no prop to check, everything matches
                                    pm.JumpList.Add(item);
                                    Logger.Log(LogType.Item, item);
                                }
                            }
                        }
                    }
                    else
                    {
                        e.Mobile.SendMessage("{0} is not a recognized type.", name);
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindItemByType <type>");
                }
            }
            catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
        }
コード例 #43
0
ファイル: AccountHandler.cs プロジェクト: Crome696/ServUO
        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.");
                }
                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
            {
            }
        }
コード例 #44
0
ファイル: ReadBookFromTxt.cs プロジェクト: Godkong/RunUO
        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;
            }
        }