Everything seems to work except for the use delay.

Code:
using System;
using Server;
using Server.Mobiles;
using Server.Misc;
using Server.Network;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
namespace Server.Items
{
public class WrongBedrollW1 : Item
{
public override int LabelNumber { get { return 1022645; } }// bedroll
private static readonly TimeSpan UseDelay = TimeSpan.FromSeconds(30.0);  
private DateTime m_LastClicked;
public DateTime LastClicked { get { return m_LastClicked; } set { m_LastClicked = value; } }
[Constructable]
public WrongBedrollW1()
: base(0xA56)
{
this.Movable = false;
}
public WrongBedrollW1(Serial serial)
: base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 1))
{
from.SendLocalizedMessage(500446); // That is too far away.
return;
}
if (DateTime.Now < m_LastClicked + TimeSpan.FromSeconds(30.0))
{
from.SendLocalizedMessage(500119); // You must wait to perform another action.
return;
}
else if (from is PlayerMobile)
{
PlayerMobile player = (PlayerMobile)from;
MysteriousTunnelWest mtw = new MysteriousTunnelWest();
if (Utility.RandomDouble() < 0.2)
{
mtw.MoveToWorld(Location, Map);
from.SendMessage(89, "As you move the bedroll it crumbles into pieces and reveals a mysterious tunnel.");
LastClicked = DateTime.Now;
Delete();
return;
}
else
from.SendMessage(89, "As you move the bedroll it crumbles into pieces but you find nothing.");
LastClicked = DateTime.Now;
Delete();
return;
}
}
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();
}
}
 
Hey Red, maybe this will help, it's part of the code for the Fountain Of Life (creates enhanced bandages every 24 hours).
Code:
	[FlipableAttribute( 0x2AC0, 0x2AC3 )]
 	public class FountainOfLife : BaseAddonContainer
	{
 		public override BaseAddonContainerDeed Deed{ get{ return new FountainOfLifeDeed( m_Charges ); } }

 		public override int LabelNumber{ get{ return 1075197; } } // Fountain of Life
 		public override int DefaultGumpID{ get{ return 0x484; } }
		public override int DefaultDropSound{ get { return 66; } }
		public override int DefaultMaxItems{ get{ return 125; } }

		public static int MaxCharges{ get{ return 100; } }
		public static TimeSpan RechargeTime{ get{ return TimeSpan.FromDays( 1 ); } }

 		private int m_Charges;

 		[CommandProperty( AccessLevel.GameMaster )]
		public int Charges
		{
			get{ return m_Charges; }
			set{ m_Charges = Math.Min( value, MaxCharges ); InvalidateProperties(); }
		}

 		private Timer m_Timer;

		[Constructable]
		public FountainOfLife() : this( MaxCharges )
		{
		}
		
		[Constructable]
		public FountainOfLife( int charges ) : base( 0x2AC0 )
		{
			m_Charges = charges;

			m_Timer = Timer.DelayCall( RechargeTime, RechargeTime, new TimerCallback( Recharge ) );
		}

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

		public override bool OnDragDrop( Mobile from, Item dropped )
		{
			if ( dropped is Bandage )
			{
				bool allow = base.OnDragDrop( from, dropped );
				
				if ( allow )
					Enhance();

				return allow;
			}
			else
			{
				from.SendLocalizedMessage( 1075209 ); // Only bandages may be dropped into the fountain.
				return false;
			}
		}

		public override bool OnDragDropInto( Mobile from, Item item, Point3D p )
		{
			if ( item is Bandage )
			{
				bool allow = base.OnDragDropInto( from, item, p );

				if ( allow )
					Enhance();

				return allow;
			}
			else
			{
				from.SendLocalizedMessage( 1075209 ); // Only bandages may be dropped into the fountain.
				return false;
			}
		}

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

			list.Add( 1075217, m_Charges.ToString() ); // ~1_val~ charges remaining
		}

		public override void OnDelete()
		{
			if ( m_Timer != null )
				m_Timer.Stop();

			base.OnDelete();
		}

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

			writer.WriteEncodedInt( 0 ); //version

			writer.Write( m_Charges );
			writer.Write( (DateTime) m_Timer.Next );
		}

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

			int version = reader.ReadEncodedInt();

			m_Charges = reader.ReadInt();

			DateTime next = reader.ReadDateTime();

			if ( next < DateTime.Now )
				m_Timer = Timer.DelayCall( TimeSpan.Zero, RechargeTime, new TimerCallback( Recharge ) );
			else
				m_Timer = Timer.DelayCall( next - DateTime.Now, RechargeTime, new TimerCallback( Recharge ) );
		}

		private void Recharge()
		{
			m_Charges = MaxCharges;
		}

		private void Enhance()
		{
			for ( int i = Items.Count - 1; i >= 0 && m_Charges > 0; i-- )
			{
				Item item = Items[ i ];

				if ( item is Bandage )
				{
					if ( item.Amount > m_Charges )
					{
						item.Amount -= m_Charges;
						DropItem( new EnhancedBandage( m_Charges ) );
						m_Charges = 0;
					}
					else 
					{
						DropItem( new EnhancedBandage( item.Amount ) );
						m_Charges -= item.Amount;
						item.Delete();
					}

					InvalidateProperties();
				}
			}
		}
	}
 
Just declaring UseDelay does nothing, you actually need to write code to use that field. tass32's example should help you understand how to do that. If not, more explanation of what you are trying to do would be helpful to us ;)
 
Back