I wanted to add a timer of 10 seconds between xpots but I am unsure how to do so, did some researches and I found this but I am uncertain to where I should place it in baseexplosionpotion.cs


C#:
public override void Drink( Mobile from )
        {
            if ( Core.AOS && (from.Paralyzed || from.Frozen || (from.Spell != null && from.Spell.IsCasting)) )
            {
                from.SendLocalizedMessage( 1062725 );
                return;
            }

            int delay = GetDelay( from );

            if ( delay > 0 )
            {
                from.SendLocalizedMessage( 1072529, String.Format( "{0}\t{1}", delay, delay > 1 ? "seconds." : "second." ) ); // You cannot use that for another ~1_NUM~ ~2_TIMEUNITS~
                return;
            }


C#:
#region Delay
        private static Hashtable m_Delay = new Hashtable();

        public static void AddDelay( Mobile m )
        {
            Timer timer = m_Delay[ m ] as Timer;

            if ( timer != null )
                timer.Stop();

            m_Delay[ m ] = Timer.DelayCall( TimeSpan.FromSeconds( 60 ), new TimerStateCallback( EndDelay_Callback ), m );   
        }

        public static int GetDelay( Mobile m )
        {
            Timer timer = m_Delay[ m ] as Timer;

            if ( timer != null && timer.Next > DateTime.UtcNow )
                return (int) (timer.Next - DateTime.UtcNow).TotalSeconds;

            return 0;
        }

        private static void EndDelay_Callback( object obj )
        {
            if ( obj is Mobile )
                EndDelay( (Mobile) obj );
        }

        public static void EndDelay( Mobile m )
        {
            Timer timer = m_Delay[ m ] as Timer;

            if ( timer != null )
            {
                timer.Stop();
                m_Delay.Remove( m );
            }
        }
        #endregion
 
Back