Sign In Register

How can we help you today?

Start a new topic
Answered

Leaderboard based on "Medals" that can be gained and lost.

So I'm designing a leaderboard and ranking system for my current project. Players will complete missions and participate in PvP battles during which they can either gain or lose "Medals." I want to create a global leaderboard that shows who has the most medals at any given time. 


I'm looking at "Summary Types" which are listed as:

Maximum – the running total will be created to track the maximum value posted

Minimum – the running total will be created to track the minimum value posted

Sum - the running total will be created to add all the values posted together

Count - the running total will be created to count the number of times the player has called the event


The leaderboard I'm trying to create is not based on a maximum, minimum, or the count of the number of times an event was called. It IS kind of a sum but a sum doesn't seem to be the most natural way to go about this particular kind of leaderboard. It would be easier to post an event that contains the actual SET value of the total number of medals but it would seem by looking at the summary types that the only option I have is to post a message with the added or subtracted number of Medals. So then every time I send the LogEventRequest for updating the medals, is the only option I have to post the positive or negative change instead of being able to directly set the value?


Also, when a PvP battle is completed the winning player will lose medals while the winning player gains medals. However, when PvP happens only the Attacker is online so I will need to somehow update the defender's score in script as well. What's the best way to update the leaderboard information for a player that isn't currently connected?


Best Answer

Hi Marc


To support your leaderboard ranking requirement you should set the "Default Cal" on your event to last. This will cause the running total to always track the last value you posted. You can then set your leaderboard to MAX. This will give you the maximum "last" value in the running total (as it's a simple running total there will only be one entry.


To post a score as another player, you can use the cloud code method Spark.sendRequestAs to post a LogEventRequest on behalf of another player. This requires you to know the JSON structure of the requests, but in the next couple of weeks we'll be adding a helper library to the cloud code editor that will give you full autocomplete of these requests.


Hope thats useful!


Gabriel


Answer

Hi Marc


To support your leaderboard ranking requirement you should set the "Default Cal" on your event to last. This will cause the running total to always track the last value you posted. You can then set your leaderboard to MAX. This will give you the maximum "last" value in the running total (as it's a simple running total there will only be one entry.


To post a score as another player, you can use the cloud code method Spark.sendRequestAs to post a LogEventRequest on behalf of another player. This requires you to know the JSON structure of the requests, but in the next couple of weeks we'll be adding a helper library to the cloud code editor that will give you full autocomplete of these requests.


Hope thats useful!


Gabriel

Thanks, that's what I needed. Not sure if I would have figured out how to set up that leaderboard otherwise. It's a bit confusing.

Login to post a comment