I remember some of the SA items having the lifespan timer, but I don't think they were for days. I'm sure some one can help with this as I don't see why it couldn't be done :)
 
I remember some of the SA items having the lifespan timer, but I don't think they were for days. I'm sure some one can help with this as I don't see why it couldn't be done :)

I'm working on the exodus encounter quest. I have the items with the lifespan set for 168 hours (total is 7 days on each). I just think it'd be a grand idea to have it count down so players could actually see exactly how long they have til it *poofs*. :D
 
I'm interested in this too, I found a picture of it once and now I can't find it to give the example. :|
 
If you post your code I could give it a whirl. It should be as easy as overriding GetProperties and adding text to show how long is left.
 
I assume you mean when you hover over an item and see it's properties? If so then it's as simple as adding the time left to GetProperties of the item.

Edit: Lol dmurphy just beat me to it :p.
 
If you post your code I could give it a whirl. It should be as easy as overriding GetProperties and adding text to show how long is left.

Code:
using System;
using System.Collections.Generic;
using Server;
using Server.Mobiles;
namespace Server.Items
{
	public class ExodusSacrificalDagger : Dagger
	{
           
        private TimeSpan m_LifeSpan;

        [CommandProperty(AccessLevel.GameMaster)]
        public TimeSpan LifeSpan
        {
            get { return m_LifeSpan; }
            set { m_LifeSpan = value; }
        }

        private DateTime m_CreationTime;

        [CommandProperty(AccessLevel.GameMaster)]
        public DateTime CreationTime
        {
            get { return m_CreationTime; }
            set { m_CreationTime = value; }
        }

        private Timer m_Timer;

        public override bool Nontransferable { get { return true; } }

        public virtual void Expire(Mobile parent)
        {
            if (parent != null)
                parent.SendMessage(38, "Time's up! Your sacrifical dagger has disappeared.");
            Effects.PlaySound(GetWorldLocation(), Map, 0x201);

            this.Delete();
        }

        public virtual void SendTimeRemainingMessage(Mobile to)
        {
            to.SendLocalizedMessage(1072516, String.Format("{0}\t{1}", (this.Name == null ? String.Format("#{0}", LabelNumber) : this.Name), (int)m_LifeSpan.TotalHours)); // ~1_name~ will expire in ~2_val~ Hours!
        }

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

            base.OnDelete();
        }

        public virtual void CheckExpiry()
        {
            if ((m_CreationTime + m_LifeSpan) < DateTime.UtcNow)
                Expire(RootParent as Mobile);
            else
                InvalidateProperties();
        }


        [Constructable]
        public ExodusSacrificalDagger(int lifeSpan)
            : this(TimeSpan.FromHours(lifeSpan))
        {
        }
        [Constructable]
        public ExodusSacrificalDagger(TimeSpan lifeSpan)
           
          {
            Name = "Exodus Sacrifical Dagger";
            ItemID = 0x2D2D;
            Weight = 4.0;
            m_CreationTime = DateTime.UtcNow;
            m_LifeSpan = lifeSpan;

            m_Timer = Timer.DelayCall(TimeSpan.FromHours(5), TimeSpan.FromHours(5), new TimerCallback(CheckExpiry));
        }

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

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

            TimeSpan remaining = ((m_CreationTime + m_LifeSpan) - DateTime.UtcNow);
            list.Add(1074049);
            list.Add(1153090, ((int)remaining.TotalHours).ToString());
        }

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

            writer.Write(m_LifeSpan);
            writer.Write(m_CreationTime);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            m_LifeSpan = reader.ReadTimeSpan();
            m_CreationTime = reader.ReadDateTime();

            m_Timer = Timer.DelayCall(TimeSpan.FromHours(5), TimeSpan.FromHours(5), new TimerCallback(CheckExpiry));
        }
    }
}
 
I assume you mean when you hover over an item and see it's properties? If so then it's as simple as adding the time left to GetProperties of the item.

Edit: Lol dmurphy just beat me to it :p.


Yup, that's exactly what I'm looking for! To show the timer maybe a 00:00:00 format.
 
I rare go to RunUO
That is a shame because there is piles and piles and piles and piles and piles and piles and piles..... of code that you can learn from there.
Type into google "site:runuo.com "Question"" (Without any "") 7/10 you'll find a thread with something to point you in a direction.
For example: http://lmgtfy.com/?q=site:runuo.com item time limit
not trying to be rude, just informative.
Also it is our responsibility here as members of ServUO to make sure that this knowledge gets preserved here in the servuo community. So people can do that same searches on servuo with better results.
 
That is a shame because there is piles and piles and piles and piles and piles and piles and piles..... of code that you can learn from there.
Type into google "site:runuo.com "Question"" (Without any "") 7/10 you'll find a thread with something to point you in a direction.
For example: http://lmgtfy.com/?q=site:runuo.com item time limit
not trying to be rude, just informative.

Yeah, I know :oops:...I just...well...I just love ServUO so much I forget about RunUO. :p
 
Here you go. Replace your GetProperties override with this

Code:
 public override void GetProperties(ObjectPropertyList list)
        {
            TimeSpan remaining = ((m_CreationTime + m_LifeSpan) - DateTime.UtcNow);
            base.GetProperties(list);
            string timeLeft = null;
            if (remaining.Minutes > 0)
            {
                var min = remaining.Minutes;
                timeLeft = String.Format("Time Left: {0} minutes.", min);
            }
            else if (remaining.Seconds > 0)
            {
                var sec = remaining.Seconds;
                timeLeft = String.Format("Time Left: {0} seconds.", sec);
            }
            list.Add((timeLeft));
            list.Add(1074049);
            list.Add(1153090, ((int)remaining.TotalHours).ToString());
            Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerCallback( InvalidateProperties ) );

        }

I didn't remove your additions as I have no idea what they are as I do not have those clilocs. (Custom?)
 
Here you go. Replace your GetProperties override with this

Code:
public override void GetProperties(ObjectPropertyList list)
        {
            TimeSpan remaining = ((m_CreationTime + m_LifeSpan) - DateTime.UtcNow);
            base.GetProperties(list);
            string timeLeft = null;
            if (remaining.Minutes > 0)
            {
                var min = remaining.Minutes;
                timeLeft = String.Format("Time Left: {0} minutes.", min);
            }
            else if (remaining.Seconds > 0)
            {
                var sec = remaining.Seconds;
                timeLeft = String.Format("Time Left: {0} seconds.", sec);
            }
            list.Add((timeLeft));
            list.Add(1074049);
            list.Add(1153090, ((int)remaining.TotalHours).ToString());
            Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerCallback( InvalidateProperties ) );

        }

I didn't remove your additions as I have no idea what they are as I do not have those clilocs. (Custom?)

Yes, those are Cliloc #s, not custom. (client 7.0.34.6)
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back