At the moment in the game it looks like this:
```
class PlayerStatsPCO_Base
{
void PlayerStatsPCO_Base()
{
Init();
}
void Init();
int GetVersion()
{
return -1;
}
ref array<ref PlayerStatBase> m_PlayerStats = new array<ref PlayerStatBase>;
PlayerStatBase GetStatObject(int id)
{
return m_PlayerStats.Get(id);
}
void RegisterStat(int id, PlayerStatBase stat)
{
m_PlayerStats.InsertAt(stat, id);
stat.Init(id/*, this*/);
}
void OnStoreSave ( ParamsWriteContext ctx )
{
for ( int i = 0; i < m_PlayerStats.Count(); i++ )
{
m_PlayerStats.Get(i).OnStoreSave(ctx);
}
}
bool OnStoreLoad ( ParamsReadContext ctx )
{
for ( int i = 0; i < m_PlayerStats.Count(); i++ )
{
if(!m_PlayerStats.Get(i).OnStoreLoad(ctx))
{
return false;
}
}
return true;
}
array<ref PlayerStatBase> Get()
{
return m_PlayerStats;
}
void ResetAllStats()
{
m_PlayerStats.Clear();
Init();
}
}
```
This problem happens because PlayerStatsPCO_Base using array as a storage PlayerStatBase.
I provide below the solution to this problem:
```
class PlayerStatsPCO_Base
{
protected ref map<int,ref PlayerStatBase> m_NewPlayerStats;
void PlayerStatsPCO_Base()
{
m_NewPlayerStats = new map<int,ref PlayerStatBase>;
Init();
}
void Init();
int GetVersion()
{
return -1;
}
PlayerStatBase GetStatObject(int id)
{
return m_NewPlayerStats.Get(id);
}
void RegisterStat(int id, PlayerStatBase stat)
{
if (!m_NewPlayerStats)
return;
m_NewPlayerStats.Insert(id,stat);
stat.Init(id);
}
void OnStoreSave( ParamsWriteContext ctx )
{
for ( int i = 0; i < m_NewPlayerStats.Count(); i++ )
{
m_NewPlayerStats.GetElement(i).OnStoreSave(ctx);
}
}
bool OnStoreLoad( ParamsReadContext ctx )
{
for ( int i = 0; i < m_NewPlayerStats.Count(); i++ )
{
if(!m_NewPlayerStats.GetElement(i).OnStoreLoad(ctx))
{
return false;
}
}
return true;
}
array<ref PlayerStatBase> Get()
{
array<ref PlayerStatBase> temp = new array<ref PlayerStatBase>;
temp.Copy(m_NewPlayerStats.GetValueArray());
return temp;
}
void ResetAllStats()
{
m_NewPlayerStats.Clear();
Init();
}
}
```