I have a cleaner in my server.But It clean everything very fast, I want to add delay time 30 seconds for it , but I couldn't , how can I do that?

" Cleaner script is not mine "
Here is script:


Code:
 public class Temizleyici : BaseCreature
    {
        [Constructable]
        public Temizleyici() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
        {
            Name = "Temizleyici";

            Body = 51;
            BaseSoundID = 456;
            Hue = 1150;
            SetStr(22, 34);
            SetDex(16, 21);
            SetInt(16, 20);
            SetHits(15, 19);
            SetDamage(1, 5);
            VirtualArmor = 70;
            Blessed = true;
        }

        public override void OnThink()
        {
            base.OnThink();


            ArrayList list = new ArrayList();
            foreach (Item item in this.GetItemsInRange(3))
            {




                if (item.Movable || item is Corpse && !(((Corpse)item).Owner is PlayerMobile))
                    list.Add(item);

            }
            for (int i = 0; i < list.Count; ++i)
                ((Item)list[i]).Delete();
        }
 
You're right for wanting to put a delay on this action - that code in OnThink() will be running like 10 times a second and it will be piling up on wasted RAM.

The easiest way to put in a delay here, is like this:

Code:
private long _NextClean;

public override void OnThink()
{
	base.OnThink();

	if( _NextClean > Core.TickCount )
		return;

	_NextClean = Core.TickCount + 3000; // 3 seconds in milliseconds

	var items = GetItemsInRange( 3 );

	foreach ( var item in items )
	{
		if ( item.Movable || ( item is Corpse && !( ( (Corpse)item ).Owner is PlayerMobile ) ) )
			item.Delete( );
	}

	items.Free( );
}
 
Back