Requirements
- A PlayFab developer account.
- A player must sign into both titles using the same credentials. One approach is to use Recoverable Credentials, as described in our Login Basics and Best Practices tutorial. To add a Recoverable login to an anonymous account, see our Account Linking tutorial.
- This example requires a working knowledge of CloudScript:
- Our example demonstrates basic data security to avoid player cheating. One could likewise use the server API on a custom game server, if the title makes use of them.
- Rewards triggered through PlayFab require usage of the appropriate PlayFab features. PlayFab Rewards can be in the form of Virtual Currency, Inventory Items, Custom Player Data, Statistics, etc. Distributing rewards outside of PlayFab systems is an advanced topic, and is not covered in this tutorial.
Each game reports a login to publisher data
Each game needs to report that a login occurred. For simplicity, our example only provides one reward for each title, for each other publisher title played. Feel free to expand on the idea with counters, timestamps, or other mechanisms to provide progressive or sequential rewards. The following CloudScript would need to be present in every game in your studio.- server.GetUserPublisherInternalData
- server.UpdateUserPublisherInternalData.
Each game checks for redeemable rewards
After you are tracking which titles are played, you need to track and grant the rewards. This CloudScript function will check for and grant available rewards, based on having played other titles.This particular example demonstrates the use of server.GetUserPublisherInternalData (requesting multiple keys), server.UpdateUserPublisherInternalData, and server.AddUserVirtualCurrency.
- Fetching the data from PlayFab, and parsing it into local data structures (calling GetUserPublisherInternalData).
- Examining the data and search for un-rewarded title IDs.
- Granting the rewards (calling AddUserVirtualCurrency).
- Updating the claimed rewards (calling UpdateUserPublisherInternalData).
- Making the rewarded amount available to the client (via return statement from CloudScript).
