|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Newbie
Join Date: Mar 2008
Age: 20
Posts: 58
|
life time on cloths here my script i need help making it show on cloths
HTML Code:
using System;
using Server;
namespace Server.Items
{
public class apron : Item
{
public virtual int Lifespan{ get{ return 0; } }
private int m_Lifespan;
[CommandProperty( AccessLevel.GameMaster )]
public int TimeLeft
{
get{ return m_Lifespan; }
set{ m_Lifespan = value; InvalidateProperties(); }
}
[Constructable]
public apron( ) : base( 0x153b )
{
LootType = LootType.Blessed;
if ( Lifespan > 0 )
{
m_Lifespan = Lifespan;
StartTimer();
}
}
public apron( Serial serial ) : base( serial )
{
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( Lifespan > 0 )
list.Add( 1072517, m_Lifespan.ToString() ); // Lifespan: ~1_val~ seconds
}
private Timer m_Timer;
public virtual void StartTimer()
{
if ( m_Timer != null )
return;
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 10 ), TimeSpan.FromSeconds( 10 ), new TimerCallback( Slice ) );
m_Timer.Priority = TimerPriority.OneSecond;
}
public virtual void StopTimer()
{
if ( m_Timer != null )
m_Timer.Stop();
m_Timer = null;
}
public virtual void Slice()
{
m_Lifespan -= 10;
InvalidateProperties();
if ( m_Lifespan <= 0 )
Decay();
}
public virtual void Decay()
{
if ( RootParent is Mobile )
{
Mobile parent = (Mobile) RootParent;
if ( Name == null )
parent.SendLocalizedMessage( 1072515, "#" + LabelNumber ); // The ~1_name~ expired...
else
parent.SendLocalizedMessage( 1072515, Name ); // The ~1_name~ expired...
Effects.SendLocationParticles( EffectItem.Create( parent.Location, parent.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
Effects.PlaySound( parent.Location, parent.Map, 0x201 );
}
else
{
Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
Effects.PlaySound( Location, Map, 0x201 );
}
StopTimer();
Delete();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (int) m_Lifespan );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_Lifespan = reader.ReadInt();
StartTimer();
}
}
}
|
|
|
|
|
|
#2 (permalink) |
|
Master of the Internet
|
you all ready have it in there for displaying it:
Code:
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( Lifespan > 0 )
list.Add( 1072517, m_Lifespan.ToString() ); // Lifespan: ~1_val~ seconds
}
you should make it a Apron (full or half based on itemid) and then just remove this part: " : base( 0x153b ) " that way it can be worn also using a time for it is not a good idea, get lots of these out there and get lots of timers causing system lag might want to consider basing it on world saves, or an other timer all ready in use in game or having checks for it also in basearmor for damage or in the onecraft if used for crafting, etc to wear it out
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#4 (permalink) |
|
Master of the Internet
|
just have a creation date for it
add in 2 new variable of public DateTime creationtime = DateTime.Now; public double wearabletime = 7.0; make sure to serialize/deserialize them then at the end of the reader section add in if(creationtime + TimeSpan.Days(wearabletime) > DateTime.Now) Delete(); (or something like that - may not be exact) this way you can also set individual items to have longer/shorter time spans by setting the wearabletime in their constructions to something other than the default of course you need daily restarts fro this to be any good (and they are smart to have for clearing out memory, unusable items, etc)
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|