Sign In Register

How can we help you today?

Start a new topic
Answered

Achievements by playerid

Hi,

I've been searching for a way to get the achievements by playerid but couldn't find anything.

It feels like it should be pretty obvious, am I missing something?


Thanks.


Best Answer

I'm gonna answer my own question since I figured it out.


Hope this helps someone.


I created an event to get the achievements array with an attribute called "player_id".

Then I added following cloud code to return the achievements.


 

var playerId = Spark.getData().player_id

var player = Spark.loadPlayer(playerId)
var achievements = player.getAchievements()
Spark.setScriptData("achievements", achievements)

 


Answer

I'm gonna answer my own question since I figured it out.


Hope this helps someone.


I created an event to get the achievements array with an attribute called "player_id".

Then I added following cloud code to return the achievements.


 

var playerId = Spark.getData().player_id

var player = Spark.loadPlayer(playerId)
var achievements = player.getAchievements()
Spark.setScriptData("achievements", achievements)

 

Hi Alp,


Yes you are correct here, you would use loadPlayer to get the achievements for the supplied playerID. For the current player you would use the following.

 

var ACH = Spark.getPlayer().getAchievements();

 

That should cover everything. If you have any further questions just let me know.


Thanks,

Liam

Login to post a comment