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 Kim Strasser · Jul 12, 2021 at 09:31 PM · CloudScriptLeaderboards and Statisticsscheduled tasks

Title exceeded limit when I want to grant leaderboard rewards

I need to find a way to grant rewards after a weekly tournament. The reset frequency for the leaderboard is set to manually. I have tried to grant the rewards with scheduled tasks after the weekly tournament finished. My scheduled task calls the CloudScript function GrantingLeaderboardRewardsToPlayer. In this function, I sort the current leaderboard. I need to sort the leaderboard in CloudScript because I use two different statistics to sort the current leaderboard.

But I always get the error message "Title exceeded limit":

"EventName": "title_exceeded_limit",
    "LimitId": "CloudScript:ScriptExecutionAPIRequestsIssued",
    "LimitDisplayName": "Number of PlayFab API requests made from a CloudScript function called by the ExecuteCloudScript API.",
    "Unit": "Count",
    "LimitValue": 25,
    "Value": 26,

In my CloudScript function, I grant the rewards to the best 100 players in the leaderboard. But I cannot grant the rewards to the 100 players because I get the error message "Title exceeded limit".

handlers.GrantingLeaderboardRewardsToPlayer = function (args, context)
{
    // sort the leaderboard

    // Grant the rewards to the best 100 players:
    var rewardsrange;
    for (var j = 0; j <= sortedplayerslist.length - 1; j++)
    {
    var playerrank = Number(j) + 1;
    if (Number(playerrank) == 1)
        rewardsrange = 1;
    if (Number(playerrank) == 2)
        rewardsrange = 2;
    if (Number(playerrank) == 3)
        rewardsrange = 3;
    if ((Number(playerrank) > 3) && (Number(playerrank) <= 10))
        rewardsrange = 4;
    if ((Number(playerrank) > 10) && (Number(playerrank) <= 20))
        rewardsrange = 5;
    if ((Number(playerrank) > 20) && (Number(playerrank) <= 50))
        rewardsrange = 6;
    if ((Number(playerrank) > 50) && (Number(playerrank) <= 100))
        rewardsrange = 7;       
 
    switch (Number(rewardsrange))
    {
        case 1:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 1000});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
        case 2:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 800});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
        case 3:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 500});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
        case 4:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 350});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
        case 5:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 200});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
        case 6:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 100});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
        case 7:
        var updatecurrencysucc = false;
        var updatecurrency = server.AddUserVirtualCurrency({PlayFabID: sortedplayerslist[j].Playfabid, VirtualCurrency: "GO", Amount: 50});
        if ((updatecurrency != null) && (updatecurrency.Error == null))
            updatecurrencysucc = true;
        else
            updatecurrencysucc = false;
        break;
    }
    }

    // notify the player when he got a reward

    return;
}

How can I grant the rewards to the 100 players when I cannot do more than 25 API requests in my CloudScript function?

In addition, I will use at least one more API call for each of the 100 players because I need to notify the players. That would already be 200 API calls only for granting and notifying the players.

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 SethDu · Jul 13, 2021 at 02:48 AM

As you can see, the API limit in single Cloud Script/Azure Function (CSAF) execution is stated in the error callback and it cannot be increased.

To grant rewards for all players, you may need to make sure the target players are in a same segment, for example, setting specific Statistic value larger than 0 in the filter. Then in Scheduled task, you may set “Run actions on each player in a segment”, then execute CSAF. Please note that the script will only apply to single player, there is no need to add any for loop to iterate players.

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 SethDu ♦ · Jul 14, 2021 at 03:20 AM 0
Share

In addition, though I believe I have provided a most common solution to your question, please note that the current 25 API limit only applies to Cloud Script. The thing I didn't state clearly is that Azure Function only has 10s runtime limit, and there is no number limit within an execution.

It means that 200 API calls might be done in Azure function but will need your own tests. Meanwhile please also understand that putting so many APIs in one execution can have bad robustness that may affect future management.

avatar image Kim Strasser SethDu ♦ · Jul 14, 2021 at 09:59 PM 0
Share

I can only have 5 requests in CloudScript when my function is called by an action trigger.

Does Azure Function have the same limit value or can I have more than 5 API requests in an Azure Function when the function is called by an action trigger?

"EventName": "title_exceeded_limit",
    "LimitId": "PlayStream:TriggeredActionCloudScriptExecutionAPIRequestsIssued",
    "LimitDisplayName": "Number of PlayFab API requests made from a CloudScript function called by an action trigger.",
    "Unit": "Count",
    "LimitValue": 5,
    "Value": 6,
avatar image SethDu ♦ Kim Strasser · Jul 15, 2021 at 02:57 AM 0
Share

Azure function won't have API count limit, however, it still has 1s runtime limit if you implement a HTTP trigger function.

This limit won't apply to queue trigger function, and it will have up to 5 min runtime.

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

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Leaderboard related Questions 1 Answer

    Can Cloud Code Access the Admin API 1 Answer

    Reset Leaderboard with Azure Function ? 1 Answer

    Cloudscript update multiple statistics 2 Answers

    Daily, weekly and monthly leaderbord and reward player 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