Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Rizwan Babar · Jul 29, 2021 at 03:09 PM · CloudScriptPlayer DataLeaderboards and StatisticsTitle Datascheduled tasks

Leaderboard related Questions

There are few things that I want to achieve with the leaderboards system.

  1. I want to reset Leaderboard at 20:00 GMT+0 (current time zone of my account) every day via cloud script as a scheduled task but I couldn't find any thread with an example to achieve that.
  2. I want to give this function parameters of field name and value when it will execute through prize table action but I am not sure how to exactly do that.
  3. Is it possible to make a cloud function that returns the total number of players in a specific leaderboard when it is called? If yes, I'd appreciate an example.

I've searched lot of threads for solution to these but couldn't find any so I'll be thankful if I could get solution to these.

Regards.

image-2021-07-29-195834.png (8.4 kB)
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Jul 30, 2021 at 10:02 AM

>> I want to reset Leaderboard at 20:00 GMT+0 (current time zone of my account) every day via cloud script as a scheduled task but I couldn't find any thread with an example to achieve that.

Currently, we do not suggest using Scheduled Tasks and Cloud Script to reset the leaderboard. We would suggest you call the Admin API IncrementPlayerStatisticVersion regularly on an administrative tool that can run stably to reset the leaderboard using the customize frequencies.

>> I want to give this function parameters of field name and value when it will execute through prize table action but I am not sure how to exactly do that.

To pass the parameters to function, the CloudScript function must contains the incoming parameter args, and we also suggest you reserve the parameter context. Please check our documentation -- https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript/writing-custom-cloudscript for more information. Please also check the default Revision 1 of your title’s CloudScript (that contains many CloudScript function samples), and the documentations https://docs.microsoft.com/en-us/gaming/playfab/features/data/playerdata/how-to-modify-read-only-internal-player-data, https://docs.microsoft.com/en-us/gaming/playfab/features/automation/actions-rules/using-cloudscript-actions-with-playstream. For your case, the function could be something like this.

handlers.Winner = function (args, context) {
    var fieldName = args.fieldName;
    var fieldValue = args.fieldValue;

    var updateUserDataResult = server.UpdateUserInternalData({
        PlayFabId: currentPlayerId,
        Data: {
            fieldName: fieldValue
        }
    });
    return updateUserDataResult;
};

>> Is it possible to make a cloud function that returns the total number of players in a specific leaderboard when it is called? If yes, I'd appreciate an example.

You can refer to the sample of this thread -- https://community.playfab.com/questions/38373/how-do-you-get-total-number-of-entries-in-a-leader.html to get the total number of players for a specific leaderboard.

Comment

People who like this

0 Show 3 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rizwan Babar · Jul 30, 2021 at 11:28 PM 0
Share

Thank you for your response. I think calling IncrementPlayerStatisticVersion might cost additional hardware since it will need a machine to execute that call everyday at that specific time. I am thinking to set its reset frequency to daily but award leaderboard players through scheduled tasks at my required time. I have created a cloud function which I will execute using scheduled task at 20:00 GMT+0 everyday. The purpose of this function is to first get the entry fee amount as argument and then multiply it with total entries in leaderboard at that time. Then it will find 60% of result and award that amount in title data of user. Here's what I've achieved so far:

I've typed 10 as assumed player count but I want to find entries count in leaderboard and use it here instead of 10.

I tried your segment method and created a segment with leaderboard value > 0. I tried making a function like this:

I feel like I probably did it wrong way. So could you tell me how can I give players in that created segment of leaderboard to my previous function in place of 10?

Also how can I execute this function only for top 1 player of leaderboard?

c1.png (32.1 kB)
c2.png (7.2 kB)
avatar image Rizwan Babar · Jul 31, 2021 at 08:50 AM 0
Share

Update: I managed to get count of players in segment of that leaderboard.

Now all I want to know is, how can I execute this only for top 1 player of leaderboard?

c3.png (38.2 kB)
avatar image Sarah Zhang Rizwan Babar · Aug 03, 2021 at 09:24 AM 0
Share

As you said you can use the Prize Table, please navigate to this document -- Using Prize Tables - PlayFab | Microsoft Docs for more information about how to execute the Cloud Script function for the specific rankings.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    5 People are following this question.

    avatar image avatar image avatar image avatar image avatar image

    Related Questions

    GameSparks Migration 1 Answer

    What's the best way to get a custom segment of players based on the user's current stats? 1 Answer

    Leaderboard amount limitations & dynamic creation? 1 Answer

    Playfab cloudcripts Wondering 2 Answers

    Reset Leaderboard with Azure Function ? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges