Sign In Register

How can we help you today?

Start a new topic

How to Trigger an Achievement via Cloud Code - Script

Hi, my name is Víctor and I'm implementing an achivement system into my videogame.

In the documentation I saw how to implement an achievement system by using a leaderboard but what I'm looking for is to trigger the different achievements by cloud code because the achievements of my game are not based exclusively on high scores on leaderboards.

An example of what I'm looking for:

- Achievement: Find 5 monsters of a different type

- So I would like a script telling that an user got this achievement.

How can I do this ? I tried with SparkAchivement.getShortCode() in cloud code but this gives me an error.

How can I get a list of the achievements, and trigger the desired one by cloud code ?

Okey, finally I got a list of all achievements in cloud code by:

var request = new SparkRequests.ListAchievementsRequest();
var response = request.Send();
var achievements = response.achievements;

 This gives you a list of all achievements telling if the current player has achieved it or not.

I suppose that if I want to have a progresion of an especific achievement I need to create a DataType to keep the historial... Is any way to keep the progress of an especific achievement without making a new data type ?

How do you trigger an achievement via script that isn't related to a leaderboard?

Hi AlphaDog,

To trigger an achievement via cloud cloud you can use:


This will give the player an achievement if they have not gotten it yet.

To store the progress towards an achievement you will need to save your progress using a database such as a GDS or on your player document via privateData or scriptData. You could also use Redis which allows for quick access to stored data for key value pair data. 



Thanks.  I will look into that command.  What I'm looking to do is setup 'currency coupons' that I can give out.  The codes will be achievement short codes that would be a one time use per player.  I figure I can add properties to get a date range that they would work in.  The only problem with that is that it would require a new database release for any new codes.

I would much rather have them as a list in a table somewhere.  Any ideas?

Login to post a comment