UoFanta
Member
I am working on a way to give players points overtime.
This is kinda like a veteran rewards system (intended to replace)
Using XML Attachments this system is intended to give player 1 vet point (currently every 10 seconds) 10 days although the script complies with 0 errors im not getting any points added [xmlgetatt doesn't show the vet points but it does show some of my other attachments..
This is kinda like a veteran rewards system (intended to replace)
Code:
using System;
using Server.Mobiles;
using Server.Network;
namespace Server.Engines.XmlSpawner2
{
public class VetPoints : Timer
{
public VetPoints() : base(TimeSpan.FromSeconds(10))
{
}
public static void DistributePoints(Mobile from)
{
XmlVetPoints a = (XmlVetPoints)XmlAttach.FindAttachment(from, typeof(XmlVetPoints));
if (a == null) // if no attachment, attach it
{
XmlAttach.AttachTo(from, new XmlVetPoints());
a = (XmlVetPoints)XmlAttach.FindAttachment(from, typeof(XmlVetPoints));
}
}
}
public class XmlVetPoints : XmlAttachment
{
private int m_VetPoints = 0;
[CommandProperty(AccessLevel.GameMaster)]
public int VetPoints { get { return m_VetPoints; } set { m_VetPoints = value; } }
public XmlVetPoints(ASerial serial)
: base(serial)
{
}
[Attachable]
public XmlVetPoints()
: this(0)
{
}
[Attachable]
public XmlVetPoints(int points)
{
Name = "Vet Points";
VetPoints = points;
}
public override void OnAttach()
{
base.OnAttach();
if (AttachedTo is PlayerMobile)
{
InvalidateParentProperties();
}
else
{
Delete();
}
}
public override void OnDelete()
{
base.OnDelete();
InvalidateParentProperties();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write((int)m_VetPoints);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_VetPoints = reader.ReadInt();
}
}
}
Using XML Attachments this system is intended to give player 1 vet point (currently every 10 seconds) 10 days although the script complies with 0 errors im not getting any points added [xmlgetatt doesn't show the vet points but it does show some of my other attachments..