RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

where is the spawners?

Tartaryon

Wanderer
where is the spawners?

well I have some troubles to find spawners into one area.
I got this! If usefull, use it!
Code:
using Server;
//using Server.Items;
using Server.Mobiles ;
using System.Collections;

namespace Scripts.Customs
{
	/// <summary>
	/// Move the staff (seer or admin) to the next spawner in the area
	/// you could use FindSpawners or FS to search spawns and
	/// GoSpawner or GS to move to each one
	/// </summary>
	public class FindSpawns
	{
		static public Hashtable myHT;
		static ArrayList SpawnList;

		public static void Initialize()
		{
			Commands.Register( "FindSpawners", AccessLevel.Seer, new CommandEventHandler( FindSpawns_OnCommand ) );
			Commands.Register( "FS", AccessLevel.Seer, new CommandEventHandler( FindSpawns_OnCommand ) );
			Commands.Register( "GoSpawner", AccessLevel.Seer, new CommandEventHandler( GoSpawner_OnCommand )  ) ;
			Commands.Register( "GS", AccessLevel.Seer, new CommandEventHandler( GoSpawner_OnCommand )  ) ;
		}

		[Usage( "FindSpawns [range]" )]
		[Description( "Lists near range spawners." )]
		private static void FindSpawns_OnCommand( CommandEventArgs args )
		{	
			Mobile from = args.Mobile;
			if (myHT == null) myHT = new Hashtable() ;
			
			if (myHT.ContainsKey(from) )
			{
				myHT.Remove(from) ;
			}
			
			SpawnList = new ArrayList() ;
		
			int range = 10;
			if ( args.Length >= 1 )
				range = args.GetInt32( 0 );
			int total = 0;

			foreach ( Item m in from.GetItemsInRange( range )  )
			{
                                                              //if (m is Spawner || m is MegaSpawner) 
				if (m is Spawner)
				{
					from.SendMessage("spawner: X={0} Y={1} Z={2}", m.X, m.Y, m.Z) ;
					SpawnList.Add(m);
					total++;
				}
			}
			
			from.SendMessage("Total Spawners in area {0}", total) ;
			if (total==0)
			{
				SpawnList.Clear() ;
				myHT=null;
			}
			else
				myHT.Add(from, SpawnList);
		}

		[Usage( "GoSpawner" )]
		[Description( "Go to the selected spawners." )]
		private static void GoSpawner_OnCommand( CommandEventArgs args )
		{
			Mobile from = args.Mobile ;
			if ((myHT==null) || (!myHT.ContainsKey(from) ))
			{
				from.SendMessage("You must use FindSpawns first!") ;
				return;
			}
			else
			{
				SpawnList = (ArrayList)myHT[from];
				myHT.Remove(from) ;
				Item m1 = (Item)SpawnList[0];
				from.Location = new Point3D(m1.X, m1.Y,  m1.Z ) ;
				SpawnList.RemoveAt(0) ;
				if (SpawnList.Count > 0)
					myHT.Add(from, SpawnList);
				else
					from.SendMessage("No more spawns to visit!") ;
			}
		}
	}
}

Updated as suggested by Igon. thx
 

GD13

Wanderer
Tartaryon,


Great script and its very useful, I'll be changing the namespace to conform with my style but very nice script indeed and a must for all shards.


Two Thumbs Up. :D




GD13,
:)
 

Igon

Wanderer
Here are some basic mods:
To find all distro spawners even if their name has changed add
using Server.Mobiles;

and change
if (m.Name == "Spawner")

to
if ( m is Spawner )
--------------------------------------------------------
To add MegaSpawner support simply add
using Server.Items;

and change the if satement to
if ( m is Spawner || m is MegaSpawner)

ill work on a gump for his shortly, once i finish RC0 to 1.0.0 conversion
 
Top