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 /
  • Feature Requests /
avatar image

Daxay suggested an idea · Aug 28, 2020 at 05:46 PM · CloudScriptPlayer Datadata

Return old data on update user data call

It would be great if we can have this feature.

It would be useful in preventing concurrency.

For example, I have one claimDailyRewards cloudscript function which gives reward to user in their inventory.

I want to give user reward only 1 time during day, so for that i am using DAILY_REWARD_STATS key for storing daily timer details and no of day.


Here the main problem is if two concurrent request from same user come then there are high chances that both request add rewards to user.
I am using below code. As you can see i am updating readonly data as soon as current data validation completed.

const combinedData = server.GetPlayerCombinedInfo({
  PlayFabId: currentPlayerId,
  InfoRequestParameters: {
      GetUserReadOnlyData: true,
      UserReadOnlyDataKeys: [UserReadonlyDataKeys.DAILY_REWARD_STATS],
      GetUserVirtualCurrency: true,
  },
}).InfoResultPayload;
const userReadonlyData = combinedData.UserReadOnlyData;
const userBalance = combinedData.UserVirtualCurrency;

if (!userReadonlyData[UserReadonlyDataKeys.DAILY_REWARD_STATS]) {
  throw new Error('You are not yet eligible to claim reward');
}
server.UpdateUserReadOnlyData({
  PlayFabId: currentPlayerId,
  KeysToRemove: [UserReadonlyDataKeys.DAILY_REWARD_STATS],
});

Stills it won't be enough to prevent concurrent requests.

But using this feature we can prevent concurrent requests.

thub.nodes.view.add-new-comment
Markus Henschel

People who like this

1 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

No comments

· Add your reply

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Your Opinion Counts

    We would love to know what you need. Submit your ideas and upvote others to help us prioritize.

    Sign in to post a new idea

    Follow

    Follow This Idea

    1 Person is following this .

    avatar image

    Related Ideas

    Is Friend Online ? Provide API to get last player activity timestamp.

    Dash: Save JSON recipes for args

    Add document store (database)

    User Blocking System

    Allow optional param to include full CatalogItem info for item-related calls

    fuzzy search OR Partial DisplayName search

    Update the Server API to allow UpdateUserTitleDisplayName

    Segmentation/Custom reports request

    Game Manager: RunCloudScript: Be able to set revision to latest or live instead of only specific reveisions.

    Granting multiple items

    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