Merix
Initiate
Hi,
I try to add Achievements system for account.
This is my base system, where i save all achievements with the id.
I'm trying each account have this item/system, to look if the account have the achievement.
My problem is how to add this system in the account.
Regards
Merix
I try to add Achievements system for account.
This is my base system, where i save all achievements with the id.
Code:
using Server;
using System.Collections.Generic;
namespace Scripts.Systems.Achievements
{
public class AccountAchievement : Item
{
internal Dictionary<int, AchieveData> Achievements = new Dictionary<int, AchieveData>();
private int m_PointsTotal = 0;
[Constructable]
public AccountAchievement()
{
}
public int GetAchievementPoints()
{
return m_PointsTotal;
}
public void AddPoints(int points)
{
m_PointsTotal += points;
}
public override void Serialize(GenericWriter writer)
{
writer.Write((int)0); // version
writer.Write(m_PointsTotal);
writer.Write(Achievements.Count);
foreach (var ach in Achievements)
{
writer.Write(ach.Key);
ach.Value.Serialize(writer);
}
}
public override void Deserialize(GenericReader reader)
{
int version = reader.ReadInt();
m_PointsTotal = reader.ReadInt();
int count = reader.ReadInt();
if (count > 0)
{
for (int i = 0; i < count; i++)
{
Achievements.Add(reader.ReadInt(), new AchieveData(reader));
}
}
}
}
}
I'm trying each account have this item/system, to look if the account have the achievement.
My problem is how to add this system in the account.
Regards
Merix