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!

Admin script - AddToBank

first I would like to say great idea and nice work. Second I would like to ask why does my server crash when I try to use it?
Heres the log:
Server Crash Report
===================

Operating System: Microsoft Windows NT 5.1.2600.0
.NET Framework: 1.1.4322.2032
Time: 12/14/2004 9:08:38 PM
Mobiles: 8878
Items: 147259
Clients:
- Count: 1
+ 127.0.0.1: (account = masteraccount) (mobile = 0x16 'Daniel')

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Scripts.Commands.AddToBank.GiveItemToAccounts(Item item, Int32 amount)
at Server.Scripts.Commands.AddToBank.GiveItem(Mobile from, Item item, Int32 amount, Int32 give, Int32 access)
at Server.Scripts.Commands.AddToBankGump.OnResponse(NetState sender, RelayInfo info)
at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)

Thanks for your help in advance.
 

davidmohara

Sorceror
Sorry about that soldierfortune, I wasn't checking to be sure that the Account actually HAS a character before I tried to give them the item. I'll have it fixed (version 2.1) and out ASAP.
 

tbird

Sorceror
Great script, however I am having a small problem.

When I add a container all items within the container are duplicated

so a single container with 5 items in it produced a container with 10 items in it.
 

davidmohara

Sorceror
Duplicating the items is correct behavior but I'm not sure how you're getting from 5 items to 10 items. Create a bag and then put 2 items in the bag (1 bag with 2 items), when it's duplicated a bag containing the items (1 bag with 2 items) will be placed in the bankbox. It even recurses multiple bags to ensure it dupes everything.

Maybe if you can give me a little more detail on how you're doing this (i.e. what exactly are you using item-wise) so that I can reproduce it because it appears to be working for me.
 

tbird

Sorceror
http://www.runuo.com/forum/showthread.php?t=47370

with an additional item in it (hollidaytreedeed)

Thats the item I am adding... it adds fine when I [add it with the add command ( 1 container random color containing 5 item with random attributes) however when I do an [addtobank using the add by type it creates it with duplicates (1 container with 2 of each item(10 items) with random attributes).

I'm going to test using some other items and bags, I'll let you know what I find.
 

JadeFist

Wanderer
JadeFist said:
Is it true that if you target a container that has multiple items, the items inside will all be duped?

I posted this sometime back in the thread. I see someone else has run into a similar problem. I haven't experimented with it, but when it happend to me it was the Christmas present package that I targetted to add to bank. It double everything in the package....
 

tbird

Sorceror
Ok it would appear that it isn't a problem with the [addtobank (Sorry) but with the holliday box script, cause if I add all of the items to the box manually and send it it works fine(well doesn't do randomization of names or colors) , well no dupes anyway... I'm not sure what the problem is though...

Thanks
 

davidmohara

Sorceror
tbird/JadeFist

It sounds like it's the holiday script. If you want to post the script, I'll be happy to take a look at it (or just drop me the link). Everything that I've tested thus far worked fine(Halloween stuff was all I had that sounded similar).
 

JadeFist

Wanderer
Here's the one:


Code:
using System; 
using Server;
using Server.Items;
using Server.Network;
using Server.Targeting;
using Server.Multis;
using Server.Mobiles;

namespace Server.Items
{ 
	[Furniture]
	[FlipableAttribute( 9002, 9003 )]
	public class WinterGiftPackage2004 : PGiftBox2004 
	{ 
		[Constructable] 
		public WinterGiftPackage2004() : this( 1 ) 
		{ 
		}
 
		[Constructable] 
		public WinterGiftPackage2004( int amount ) 
		{ 
			DropItem( new PHolidayCandle() ); 
			DropItem( new PMistletoeDeed() );
			DropItem( new PSnowpileGlacial() );
			switch (Utility.Random( 3 ))
			{
				case 0: DropItem( new PDecorativeTopiary() ); break;
				case 1: DropItem( new PFestiveCactus() ); break;
				case 2: DropItem( new PSnowyTree() ); break;
			}
			switch (Utility.Random( 19 ))
			{
				case 0: DropItem( new BritainGlobe() ); break;
				case 1: DropItem( new BucsGlobe() ); break;
				case 2: DropItem( new CoveGlobe() ); break;
				case 3: DropItem( new DeluciaGlobe() ); break;
				case 4: DropItem( new EmpathGlobe() ); break;
				case 5: DropItem( new JhelomGlobe() ); break;
				case 6: DropItem( new LycaeumGlobe() ); break;
				case 7: DropItem( new MaginciaGlobe() ); break;
				case 8: DropItem( new MinocGlobe() ); break;
				case 9: DropItem( new MoonglowGlobe() ); break;
				case 10: DropItem( new NujelmGlobe() ); break;
				case 11: DropItem( new OccloGlobe() ); break;
				case 12: DropItem( new PapuaGlobe() ); break;
				case 13: DropItem( new SerpentsGlobe() ); break;
				case 14: DropItem( new SkaraGlobe() ); break;
				case 15: DropItem( new TrinsicGlobe() ); break;
				case 16: DropItem( new VesperGlobe() ); break;
				case 17: DropItem( new WindGlobe() ); break;
				case 18: DropItem( new YewGlobe() ); break;
			}
		}
		
 
		public WinterGiftPackage2004( Serial serial ) : base( serial ) 
		{ 
		} 

		public override void Serialize( GenericWriter writer ) 
		{ 
			base.Serialize( writer ); 

			writer.Write( (int) 0 ); // version 
		} 

		public override void Deserialize( GenericReader reader ) 
		{ 
			base.Deserialize( reader ); 

			int version = reader.ReadInt(); 
		} 
	} 
	
	[Furniture]
	[FlipableAttribute( 9002, 9003 )]
	public class PGiftBox2004 : LockableContainer 
	{ 
		public override int DefaultGumpID{ get{ return 0x102; } }
		public override int DefaultDropSound{ get{ return 0x42; } }

		public override Rectangle2D Bounds 
		{ 
			get{ return new Rectangle2D( 35, 10, 155, 85 ); }
		}
 
		[Constructable]
		public PGiftBox2004() : this( Utility.RandomDyedHue() )
		{
		}

		[Constructable]
		public PGiftBox2004( int hue ) : base( Utility.Random( 0x232A, 2 ) )
		{ 
			Weight = 2.0;
			Hue = hue;
			Name = "A 2004 Christmas Gift";

		} 

		public PGiftBox2004( Serial serial ) : base( serial ) 
		{ 
		} 

		public override void Serialize( GenericWriter writer ) 
		{ 
			base.Serialize( writer ); 

			writer.Write( (int) 0 ); // version 
		} 

		public override void Deserialize( GenericReader reader ) 
		{ 
			base.Deserialize( reader ); 

			int version = reader.ReadInt(); 
		} 
	} 


	public class PDecorativeTopiary : Item
	{
		public override int LabelNumber{ get{ return 1070878; } } // a Decorative...

		[Constructable]
		public PDecorativeTopiary() : base(0x2378)
		{
			Weight = 1.0;
			LootType = LootType.Blessed;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add( 1070880 ); //Winter 2004
		}

		public PDecorativeTopiary(Serial serial) : base(serial)
		{
		}

		public override void OnDoubleClick( Mobile from ) 
		{ 
			if (! from.InRange( this.GetWorldLocation(), 2 ))
			{
				from.LocalOverheadMessage( MessageType.Regular, 906, 1019045 ); // I can't reach that.
			}	
		}

		public override void Serialize(GenericWriter writer)
		{
			base.Serialize(writer);

			writer.Write((int) 0);
		}

		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();
		}
	}

	public class PFestiveCactus : Item
	{
		public override int LabelNumber{ get{ return 1070879; } } // a Decorative...

		[Constructable]
		public PFestiveCactus() : base(0x2376)
		{
			Weight = 1.0;
			LootType = LootType.Blessed;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add( 1070880 ); //Winter 2004
		}

		public PFestiveCactus(Serial serial) : base(serial)
		{
		}

		public override void OnDoubleClick( Mobile from ) 
		{ 
			if (! from.InRange( this.GetWorldLocation(), 2 ))
			{
				from.LocalOverheadMessage( MessageType.Regular, 906, 1019045 ); // I can't reach that.
			}	
		}

		public override void Serialize(GenericWriter writer)
		{
			base.Serialize(writer);

			writer.Write((int) 0);
		}

		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();
		}
	}

	public class PSnowyTree : Item
	{
		public override int LabelNumber{ get{ return 1070877; } } // a Decorative...

		[Constructable]
		public PSnowyTree() : base(0x2377)
		{
			Weight = 1.0;
			LootType = LootType.Blessed;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add( 1070880 ); //Winter 2004
		}

		public PSnowyTree(Serial serial) : base(serial)
		{
		}

		public override void OnDoubleClick( Mobile from ) 
		{ 
			if (! from.InRange( this.GetWorldLocation(), 2 ))
			{
				from.LocalOverheadMessage( MessageType.Regular, 906, 1019045 ); // I can't reach that.
			}	
		}

		public override void Serialize(GenericWriter writer)
		{
			base.Serialize(writer);

			writer.Write((int) 0);
		}

		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();
		}
	}

	[Flipable( 0x236E, 0x2371 )]
	public class PHolidayCandle : Item
	{
		public override int LabelNumber{ get{ return 1070875; } } // Light of the...

		public static string GetRandomTitle()
		{
			// All hail OSI staff
			string[] titles = new string[]
				{
						"GM Exodus",
				};

			if ( titles.Length > 0 )
				return titles[Utility.Random( titles.Length )];

			return null;
		}

		private string m_Title;

		[CommandProperty( AccessLevel.GameMaster )]
		public string Title
		{
			get{ return m_Title; }
			set{ m_Title = value; InvalidateProperties(); }
		}

		[Constructable]
		public PHolidayCandle() : this( Utility.RandomDyedHue(), GetRandomTitle() )
		{
		}

		[Constructable]
		public PHolidayCandle( int hue ) : this( hue, GetRandomTitle() )
		{
		}

		[Constructable]
		public PHolidayCandle( string title ) : this( Utility.RandomDyedHue(), title )
		{
		}

		[Constructable]
		public PHolidayCandle( int hue, string title ) : base( 0x236E )
		{
			Light = LightType.Circle150;
			Weight = 1.0;
			Hue = hue;
			LootType = LootType.Blessed;

			m_Title = title;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );

			if ( m_Title != null )
				list.Add( 1070881, m_Title  ); // Hand Dipped by ~1_NAME~
				list.Add( 1070880 ); //Winter 2004
		}
	
		public PHolidayCandle( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 1 ); // version

			writer.Write( (string) m_Title );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 1:
				{
					m_Title = reader.ReadString();
					break;
				}
			}
		}
	}

	public class PSnowpileGlacial : Item
	{
		public override int LabelNumber{ get{ return 1070874; } }

		[Constructable]
		public PSnowpileGlacial() : base( 0x913 )
		{
			Stackable = false;
			Weight = 1.0;
			LootType = LootType.Blessed;
			Hue = 0x480;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add( 1070880 ); //Winter 2004
		}

		public PSnowpileGlacial( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
 
			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}
       
		public override void OnDoubleClick( Mobile from )
		{
			if (!IsChildOf(from.Backpack))
			{
				from.SendLocalizedMessage( 1042010 ); //You must have the object in your backpack to use it.
				return;
			}
			else
			{
				if ( from.Mounted )
				{
					from.SendLocalizedMessage( 1040016 ); // You cannot use this while riding a mount
				}
			
				else			
				{
					if ( from.BeginAction( typeof( PSnowpileGlacial ) ) )
					{
						from.Target = new PSnowGlacialTarget( from );
						from.SendLocalizedMessage( 1005575 );   // You carefully pack the snow into a ball...
					}
					else
					{
						from.SendLocalizedMessage( 1005574 );
					}

				}
			}
		}
	
		private class InternalTimer : Timer
		{
			private Mobile m_From;

			public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 5.0 ) )
			{
				m_From = from;
			}

			protected override void OnTick()
			{
				m_From.EndAction( typeof( PSnowpileGlacial ) );
			}
		}

		private class PSnowGlacialTarget : Target
		{
			private Mobile m_Thrower;
 
			public PSnowGlacialTarget( Mobile thrower ) : base ( 10, false, TargetFlags.None )
			{
				m_Thrower = thrower;
			}

			protected override void OnTarget( Mobile from, object target )
			{
				
				if( target == from )
					from.SendLocalizedMessage( 1005576 );
				
				else if( target is Mobile)
				{
					Mobile m = (Mobile)target;
					from.Animate( 9, 1, 1, true, false, 0 );
					from.SendLocalizedMessage( 1010573 );   // You throw the snowball and hit the target!
					m.SendLocalizedMessage( 1010572 ); // You have just been hit by a snowball!
					Effects.SendMovingEffect( from, m, 0x36E4, 4, 0, false, true, 0x481, 0 );
				}

				else
				{
					from.SendLocalizedMessage( 1005577 );
				}

				new InternalTimer( from ).Start();
			}
		}
	}

	public class PMistletoeAddon : Item
	{

		[Constructable]
		public PMistletoeAddon() : base( 0x2374 )
		{
			//Hue = hue;
			Movable = false;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add( 1070880 ); //Winter 2004
		}

		public PMistletoeAddon( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}

		public override void OnDoubleClick( Mobile from )
		{
			BaseHouse house = BaseHouse.FindHouseAt( this );

			if ( house != null && house.IsCoOwner( from ) )
			{
				if ( from.InRange( GetWorldLocation(), 1 ) )
				{
					from.AddToBackpack( new PMistletoeDeed() );
					Delete();
				}
				else
				{
					from.SendLocalizedMessage( 500295 ); // You are too far away to do that.
				}
			}
		}
	}

	public class PMistletoeDeed : Item
	{
		public override int LabelNumber{ get{ return 1070882; } } // Mistle wreath deed

		[Constructable]
		public PMistletoeDeed() : base( 0x14F0 )
		
		{
			Weight = 1.0;
			LootType = LootType.Blessed;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			
			list.Add( 1070880 ); //Winter 2004
		}

		public PMistletoeDeed( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}

		public static bool IsWall( int x, int y, int z, Map map )
		{
			if ( map == null )
				return false;

			Tile[] tiles = map.Tiles.GetStaticTiles( x, y, true );

			for ( int i = 0; i < tiles.Length; ++i )
			{
				Tile t = tiles[i];
				ItemData id = TileData.ItemTable[t.ID & 0x3FFF];

				if ( (id.Flags & TileFlag.Wall) != 0 && (z + 16) > t.Z && (t.Z + t.Height) > z )
					return true;
			}

			return false;
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( IsChildOf( from.Backpack ) )
			{
				BaseHouse house = BaseHouse.FindHouseAt( from );

				if ( house != null && house.IsCoOwner( from ) )
				{
					bool northWall = IsWall( from.X, from.Y - 1, from.Z, from.Map );
					bool westWall = IsWall( from.X - 1, from.Y, from.Z, from.Map );

					if ( northWall && westWall )
					{
						switch ( from.Direction & Direction.Mask )
						{
							case Direction.North:
							case Direction.South: northWall = true; westWall = false; break;

							case Direction.East:
							case Direction.West:  northWall = false; westWall = true; break;

							default: from.SendMessage( "Turn to face the wall on which to hang this decoration." ); return;
						}
					}

					int itemID = 0;

					if ( northWall )
						itemID = 0x2375;
					else if ( westWall )
						itemID = 0x2374;
					else
						from.SendLocalizedMessage( 1070883 ); // The decoration must be placed next to a wall.

					if ( itemID > 0 )
					{
						Item addon = new PMistletoeAddon ();

						addon.ItemID = itemID;
						addon.MoveToWorld( from.Location, from.Map );

						house.Addons.Add( addon );
						Delete();
					}
				}
				else
				{
					from.SendLocalizedMessage( 502092 ); // You must be in your house to do this.
				}
			}
			else
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
		}
	}
}
 
Problem

Well...this script works realy good untill a certain point. The one problem I have found out is when you give a item to each account with this script it will send them just fine but if the item is blessed the item will become unblessed when it enters there banks.:\
 
Need update.

Ummm....Well could you please give me a link to an update addtobank then or something becasue I did some more looking for this and it said something about a global add thing but when you do that it does not work like I want it to.:\:confused:
 

greywolf79

Sorceror
I know this is an old script but I liked the idea and wanted to try it on my shard... I use RunUO 2.0 RC1. When I load this in and try to compile the shard I get the error below:

Code:
Errors:
 + Custom/AddToBank.cs:
    CS0246: Line 31: The type or namespace name 'CommandEventArgs' could not be
found (are you missing a using directive or an assembly reference?)

Anyone know how to fix this? I would appreciate the help...

GreyWolf.
 
Top