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
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.
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 .
Have yall ever taken a look in/at those Half Life weapons on runuo? It's not exactly the same, but it is kind of on subject.
http://www.runuo.com/community/resources/halflife-item-pack.44/
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.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.
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 ) );
}
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?)
Ahh I have 7.0.15.1 Don't like the new despiseYes, those are Cliloc #s, not custom. (client 7.0.34.6)
Me either, I'm using old maps.Ahh I have 7.0.15.1 Don't like the new despise
We use essential cookies to make this site work, and optional cookies to enhance your experience.