question

Emil avatar image
Emil asked

Change other players leaderboard stat

Hi Playfab Forum.

I've got my game in Unity up and running with playfab leaderboard, but there's a feature i need in order to make the game.

Get two random different players from the scoreboaard.

Get the avatar images from the two players.

Be able to minus x ammount of points from another specific players score.

I don't know cloud scripting, but i do know C# so i dont think it will take that much time to learn. So my question is, what should i be training or reading about to make this cloudscript, or what would the solution be?

Sincerly Emil Gade

Player DataCloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

Cloud Script is written in JavaScript, you may have to learn some basic knowledges about JS coding. We recommend you to use TypeScript to help you write Cloud Script. A sample tutorial is provided in our website. You can also check the documents about how to write a custom Cloud Script here. For more details, you can simply search “Cloud Scripts” in PlayFab Document.

For the leaderboard statistics, GetLeaderboard function is provided both in Client API and Server API. I believe you have to write your own algorithm to generate the two random players in PlayerLeaderBoardEntry List.

We suggest you not using subquery for the avatar retrieval, you can see Advanced Leaderboard Docs here.

BTW, GetLeaderboard will return up to 100 entries at a time, and you can modify the number in the API call request.

Kind regards,

Seth Du

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

And finally, for the actual score update, a Cloud Script could easily make the call to update both players' scores. The thing you'll have to decide is which client is the one to make the call. One thing to consider is, what are the circumstances in which a player might use a hack to block that call (generally, when losing the match)?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.