JBob
Member
I'm having some issues with Serializing and Deserializing Timers.
I've read some stuff on them and done some searches, but for the most part... I just don't get it. Ser/Des is a tough subject for me so be gentle.
Can someone Explain/Show me how someone would go about doing it?
Below is my item and timer i am trying to Ser/Des. The item is mostly done. I just need to save and load the time on server restart. If I don't, this wont work properly as most of you know.
Please save us lost ones from the torture of timer Ser/Des!
I've read some stuff on them and done some searches, but for the most part... I just don't get it. Ser/Des is a tough subject for me so be gentle.
Can someone Explain/Show me how someone would go about doing it?
Below is my item and timer i am trying to Ser/Des. The item is mostly done. I just need to save and load the time on server restart. If I don't, this wont work properly as most of you know.
Code:
namespace Server.Items
{
[FlipableAttribute( 0xE41, 0xE40 )]
public class AccountDepositBox : BaseContainer
{
public override int MaxWeight{ get{ return 1200; } }
public virtual int MaxItems{ get{ return 250; } }
#region Account Info
public string m_Account;
[CommandProperty(AccessLevel.GameMaster)]
public string Account
{
get
{
return this.m_Account;
}
set
{
this.m_Account = value;
}
}
#endregion
Random random = new Random();
[Constructable]
public AccountDepositBox() : this(null){}
[Constructable]
public AccountDepositBox(string account) : this(account, 0xE41, 0xE40){}
public AccountDepositBox(string account, int itemID) : this(account, itemID, itemID){}
public AccountDepositBox(string account, int inactiveItemID, int activeItemID) : base(inactiveItemID)
{
this.m_Account = account;
Name = "Account Deposit Box";
Movable = false;
}
public AccountDepositBox( Serial serial ) : base( serial )
{
}
#region Ser/Des
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
writer.Write((string)this.m_Account);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
this.m_Account = reader.ReadString();
}
#endregion
}
#region Timer
public class AccountDBoxTimer : Timer
{
AccountDepositBox adbox;
Mobile player;
public AccountDBoxTimer( AccountDepositBox item, Mobile from ) : base( TimeSpan.FromSeconds( 59 ) )
{
adbox = item;
player = from;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
...
}
}
}
#endregion
Please save us lost ones from the torture of timer Ser/Des!