Sign In Register

How can we help you today?

Start a new topic

Best way to store lots of stats

Hi,


I am currently investigating GameSparks as a Player stat storage and live ops solution, and I am unfamiliar with this type of product.


We want to store lots of player stats for our game. An example of the sort of stats we want to store is:

ingame:
Playerx using CharacterA gets a Kill with WeaponA

Stats to store:

CharacterA got a kill

CharacterA used weaponA to get the kill


Multiply the number of available in game characters, by the number of available weapons and that is a lot of different stats.


I was able to write some CloudCode which sets up this data inside the player data:

var Character = Spark.getData().Char;
var Weapon = Spark.getData().Weapon;

//Load the playerdata
var playerData = Spark.getPlayer().getPrivateData(Character);
if(playerData === null)//If it does not exist create one
{
    playerData = {
     "Kills": 1,
    };
    playerData[Weapon] = 1;
    Spark.getPlayer().setPrivateData(Character, playerData);
}
else
{
    playerData.Kills +=1
    if( Weapon in playerData)//If this character has used the weapon increment it
        playerData[Weapon]+=1; 
    else//Otherwise create a new key:value for the weapon
        playerData[Weapon]=1; 
    Spark.getPlayer().setPrivateData(Character, playerData); //Save the data in the player's personal private data object
}

 

 This code works fine.


However I am unsure if this is the correct approach. At any point we may want to poll the data to see, for example, what weapon is the most successful for what character. From what I can tell a good way of doing this would be a leaderboard. However it does not seem like you can access this data to use in a leaderboard, and I would have to create an event for each Character:Weapon combination (which would be a lot of events), which screams to me that there is probably a better way.


Is my approach correct? if so is it possible to set up leaderboards using that data or am I missing a step?


Thanks in advance

David


Login to post a comment