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!

[Set Decay False?

twizfire

Wanderer
[Set Decay False?

I want to put a Pay Dye Tub that any one can use but if no one uses it for an hour, Poof! I can't set decay because it is read-only. I tried looking at some other codes but I can't figure out where to set something to not decay.
Code:
using System;
using Server;
using Server.Multis;
using Server.Targeting;
using Server.Items;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;

namespace Server.Items
{
	public class PayDyeTub : Item
	{
		private bool m_Redyable;
		private int m_DyedHue;
		private int m_Price;

		public virtual CustomHuePicker CustomHuePicker{ get{ return null; } }

		public virtual bool AllowRunebooks
		{
			get{ return false; }
		}

		public virtual bool AllowFurniture
		{
			get{ return false; }
		}

		public virtual bool AllowStatuettes
		{
			get{ return false; }
		}

		public virtual bool AllowLeather
		{
			get{ return false; }
		}

		public virtual bool AllowDyables
		{
			get{ return true; }
		}
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );			
			list.Add( "Price Per Item Dyed: "+m_Price.ToString()  );
		}

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

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

			writer.Write( (bool) m_Redyable );
			writer.Write( (int) m_DyedHue );
			writer.Write( (int) m_Price );
		}

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

			int version = reader.ReadInt();

			switch ( version )
			{
				case 0:
				{
					m_Redyable = reader.ReadBool();
					m_DyedHue = reader.ReadInt();
					m_Price = reader.ReadInt();

					break;
				}
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int Price
		{
			get{return m_Price;}
			set{m_Price = value;}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Redyable
		{
			get{return m_Redyable;}
			set{m_Redyable = value;}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int DyedHue
		{
			get{return m_DyedHue;}
			set
			{
				if ( m_Redyable )
				{
					m_DyedHue = value;
					Hue = value;
				}
			}
		}

		[Constructable] 
		public PayDyeTub() : base( 0xFAB )
		{
			Hue = DyedHue = 1;
			Weight = 1.0;
			Redyable = false;
			Price = 150000;
		}

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

		// Select the clothing to dye.
		public virtual int TargetMessage{ get{ return 500859; } }

		// You can not dye that.
		public virtual int FailMessage{ get{ return 1042083; } }

		public override void OnDoubleClick( Mobile from )
		{
			if ( from.InRange( this.GetWorldLocation(), 1 ) )
			{
				from.SendLocalizedMessage( TargetMessage );
				from.Target = new InternalTarget( this, Price );
			}
			else
			{
				from.SendLocalizedMessage( 500446 ); // That is too far away.
			}
		}

		private class InternalTarget : Target
		{
			private PayDyeTub m_Tub;
			private int m_Price;

			public InternalTarget( PayDyeTub tub, int Price ) : base( 1, false, TargetFlags.None )
			{
				m_Tub = tub;
				m_Price = Price;
			}

			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( targeted is Item )
				{
					Item item = (Item)targeted;

					if ( item is Gold || item is BaseWeapon || item is BaseMeleeWeapon || item is BaseArmor || item is BoltOfCloth || item is DyeTub || item is Cloth || item is BaseTool || item is MonsterStatuette || item is Runebook ) ///Items that can't be dyed!///
					{
						from.SendLocalizedMessage( m_Tub.FailMessage );
					}
					else if ( from.Backpack != null && from.Backpack.ConsumeTotal( typeof( Gold ), m_Price ) )
					{
						from.PlaySound( 0x23E );
						from.SendMessage( "{0} has been taken from your backpack!", m_Price.ToString() ); // Amount charged
						item.Hue = m_Tub.DyedHue;
					}
					else if ( from.BankBox != null && from.BankBox.ConsumeTotal( typeof( Gold ), m_Price ) )
					{
						from.PlaySound( 0x23E );
						from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // Amount charged
						item.Hue = m_Tub.DyedHue;
					}
					else
					{
						from.SendMessage( "You cannot afford to dye that!" );
					}
				}
				else
				{
					from.SendLocalizedMessage( m_Tub.FailMessage );
				}
			}
		}
	}
}
Any help is appreciated.
 

Hammerhand

Knight
You could put it on a spawner. Or.. have you tried [props on it? It might have a decay setting that can be set to false and then just make sure its set movable = false and it should be fine. Or it may be that it isnt locked down in the first place.
 

twizfire

Wanderer
If I lock it down, I'm the only one that can use it.
If I don't lock it down, it decays.
I'd rather not have to lock it down in my house because I will probably end up putting some throughout the world, but I will if that's what I need to do.
I did [props but you can't change the decay properties there either.
I'm going to try the spawner but the issue I have there is I want it to always be black. Even though:
Code:
		[Constructable] 
		public PayDyeTub() : base( 0xFAB )
		{
			[COLOR="Red"]Hue = DyedHue = 1;[/COLOR]
			Weight = 1.0;
			Redyable = false;
			Price = 150000;
		}
, Hue = 1 but the DyedHue = 0 when it is created.
 

Murzin

Knight
soteric has the right of it.

decays is an indicator, not by default a configurable variable. its to let a staff member see if an item is decayable.
 

twizfire

Wanderer
So here's what I got. Probably didn't put it in the right place. If it wasn't for this community, I never would have even considered learning how to code. The issue is now that the Decays property can no longer be found when I [props. I did [set decays and it says the same thing. I went ahead and placed a dye tub and I'm going to visit it in a few hours to see what happens but if you know I placed the line in the wrong spot go ahead and yell at me.
Code:
using System;
using Server;
using Server.Multis;
using Server.Targeting;
using Server.Items;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;

namespace Server.Items
{
	public class PayDyeTub : Item
	{
		private bool m_Redyable;
		private int m_DyedHue;
		private int m_Price;

        [COLOR="Red"]public override bool Decays { get { return false; } }[/COLOR]

		public virtual CustomHuePicker CustomHuePicker{ get{ return null; } }

		public virtual bool AllowRunebooks
		{
			get{ return false; }
		}

		public virtual bool AllowFurniture
		{
			get{ return false; }
		}

		public virtual bool AllowStatuettes
		{
			get{ return false; }
		}

		public virtual bool AllowLeather
		{
			get{ return false; }
		}

		public virtual bool AllowDyables
		{
			get{ return true; }
		}
		
		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );			
			list.Add( "Price Per Item Dyed: "+m_Price.ToString()  );
		}

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

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

			writer.Write( (bool) m_Redyable );
			writer.Write( (int) m_DyedHue );
			writer.Write( (int) m_Price );
		}

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

			int version = reader.ReadInt();

			switch ( version )
			{
				case 0:
				{
					m_Redyable = reader.ReadBool();
					m_DyedHue = reader.ReadInt();
					m_Price = reader.ReadInt();

					break;
				}
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int Price
		{
			get{return m_Price;}
			set{m_Price = value;}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Redyable
		{
			get{return m_Redyable;}
			set{m_Redyable = value;}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public int DyedHue
		{
			get{return m_DyedHue;}
			set
			{
				if ( m_Redyable )
				{
					m_DyedHue = value;
					Hue = value;
				}
			}
		}

		[Constructable] 
		public PayDyeTub() : base( 0xFAB )
		{
			Hue = DyedHue = 1;
			Weight = 1.0;
			Redyable = false;
			Price = 150000;
		}

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

		// Select the clothing to dye.
		public virtual int TargetMessage{ get{ return 500859; } }

		// You can not dye that.
		public virtual int FailMessage{ get{ return 1042083; } }

		public override void OnDoubleClick( Mobile from )
		{
			if ( from.InRange( this.GetWorldLocation(), 1 ) )
			{
				from.SendLocalizedMessage( TargetMessage );
				from.Target = new InternalTarget( this, Price );
			}
			else
			{
				from.SendLocalizedMessage( 500446 ); // That is too far away.
			}
		}

		private class InternalTarget : Target
		{
			private PayDyeTub m_Tub;
			private int m_Price;

			public InternalTarget( PayDyeTub tub, int Price ) : base( 1, false, TargetFlags.None )
			{
				m_Tub = tub;
				m_Price = Price;
			}

			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( targeted is Item )
				{
					Item item = (Item)targeted;

					if ( item is Gold || item is BaseWeapon || item is BaseMeleeWeapon || item is BaseArmor || item is BoltOfCloth || item is DyeTub || item is Cloth || item is BaseTool || item is MonsterStatuette || item is Runebook ) ///Items that can't be dyed!///
					{
						from.SendLocalizedMessage( m_Tub.FailMessage );
					}
					else if ( from.Backpack != null && from.Backpack.ConsumeTotal( typeof( Gold ), m_Price ) )
					{
						from.PlaySound( 0x23E );
						from.SendMessage( "{0} has been taken from your backpack!", m_Price.ToString() ); // Amount charged
						item.Hue = m_Tub.DyedHue;
					}
					else if ( from.BankBox != null && from.BankBox.ConsumeTotal( typeof( Gold ), m_Price ) )
					{
						from.PlaySound( 0x23E );
						from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // Amount charged
						item.Hue = m_Tub.DyedHue;
					}
					else
					{
						from.SendMessage( "You cannot afford to dye that!" );
					}
				}
				else
				{
					from.SendLocalizedMessage( m_Tub.FailMessage );
				}
			}
		}
	}
}

Thanks guys, MUCH appreciated.
 

brixey2451

Wanderer
i beleve it would go under or below the red, either or, im not the best scripter, so i could be wrong, its just the guess where id try and put it

Code:
		[Constructable] 
		public PayDyeTub() : base( 0xFAB )
		{
			Hue = DyedHue = 1;
			Weight = 1.0;
			Redyable = false;
			Price = 150000;
		}

		[COLOR="Red"]public PayDyeTub( Serial serial ) : base( serial )
		{
		}[/COLOR]
 

twizfire

Wanderer
Well the decay property has seemed to disappear but the dye tub doesn't so it's good enough for me.
THANKS for the help
 

marcus93

Wanderer
Movable = false does the trick for dyeing tubs.
Btw, if you set Movable false for containers, you need LiftOveride = true for players to be able to take items.
 

David

Moderate
if you put [CommandProperty( AccessLevel.GameMaster )] on the line immediately before your public override bool Decays { get { return false; } } then GM's will be able to see the Property. And where you had it in the script is just fine.
 
Top