I am working on a way to give players points overtime.
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..
 
its a new script which is based off a xml voting system i made a while ago. Althought its slightly different the way the points are rewarded. It is still a working xml attachment i can add the points manually ingame using commands they are just not rewarded as part of the timer.
 
Sorry for such short answers. One more question. How are you attaching this or wanting it to be attached to the players? If you want the Server to do it automatically, you will need a section like this:

Code:
public static void Initialize()
{
     //your code goes here...
}
 
There is currently no other script i guess i forget to do a timer so i will add one in.
i thought it would have attached itself using the distrubute points method..

Guess ill have to take a deeper look into how xml points are added
 
Your timer in the script above is checking for an attachment, and if they dont have an attachment, then it adds the attachment. However, its not doing anything else, shouldn't it be awarding points or something?

a.VetPoints += 10;

Also don't see where the timer is being started and I don't see where the DistributePoints is being called from.
 
Last edited:
Back