At the moment the automated leaderboard achievements don't store the date, I'll get onto our dev team and see about getting it added in, however if you are unlocking the achievement through cloud code you can store the achievement information in a collection.
Start off by creating a collection:
Then create an event:
Then we'll write the cloud code that will unlock whatever achievement and store any information about the achievement we want:
//Store our runtime collection as a var var achievmentInfoNoSQL = Spark.runtimeCollection("achievementInfo"); //Pull in the attributes we enter from the event var achievementName = Spark.data.achievementName; var achievementDate = Spark.data.achievementDate; //Unlock the achievement for the player Spark.getPlayer().addAchievement(achievementName); //Save our playerId, the achievement shortCode, and the time and date it was unlocked var success = achievmentInfo.save({"userId" : Spark.getPlayer().getPlayerId(), "achievementName" : achievementName, "achievementDate" : achievementDate});
Now when we call our "Unlock Achievement" event our NoSQL Database should now contain information about the achievement as well as the playerId it is stored against:
Now we need to retrieve that information, so we make a new event:
and in cloud code:
//Store our runtimeCollection for easierAccess var achievmentDateTimeNoSQL = Spark.runtimeCollection("achievementInfo"); //Pull in the shortCode from the eventAttribute var achievementName = Spark.data.achievementName; //Find the entry for our playerId and the acheivement shortCode var achievementMeta = achievementInfo.findOne({ "userId" : Spark.getPlayer().getPlayerId(), "achievementName": achievementName}); //Save it out in the scriptData Spark.setScriptData("achievementMeta", achievementMeta);
Now when we make our get achievement event you should get back the time and date:
Hope that helps!
Shane
Jim Perry
I'd like to see the date a player unlocked an achievement added. Unless I'm missing it this isn't tracked.