question

Jon avatar image
Jon asked

Grant items after a level via playstream or invoke cloudscript?

So I want to grant items to a player after they complete a level.

The rewards they earn are some coins + some items (all generated client side). What is the recommended way to get these into the Playfab player's inventory and virtual currency wallet?

1) I understand that one way would be to emit a custom play stream event. Then have some cloudscript parse that event and grant the item / currency.

I have some concerns about this one, as there is no control on when the event gets triggered. The player exit the level (the event is sent) and client side, we show the rewards are granted. They try to equip the new item, but it's possible there is a state mismatch between client/server as the event may not been triggered yet?

2) The second one is to request execute cloud script from client with the items/coins in the payload. Similar to the event but this one can be synchronous / waited on.

Which is the recommended way? Maybe there is a better approach?

We would also like to allow offline play to cache items, but that one shouldn't matter too much. It can be cached and either option 1 or 2 can be used when the player comes back online.

Thanks

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

Client-generated coins and items seems to be unreliable. I will suggest define the reward on PlayFab. Besides of that, I think both methods should work fine. However, in the first one, player are unknown to the item instance ID, hence the equipment state cannot be updated to PlayFab. I am not sure of the genre of your game. But if equipment is important, you may still need to update the inventory to get the instance ID. Meanwhile, the second method will be more straightforward.

2 comments
10 |1200

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

Jon avatar image Jon commented ·

Thanks for the feedback. The genre is action RPG. Inventory is an important part of the game but allowing occasional offline play is important as the game is not multiplayer.

The idea is to download / cache the drop tables. At the end of the level, if the player is online then we can send that payload to cloud script.

If the player is offline, then we can cache that payload and try to upload it when the client is online again. (some heuristics and other caps can be used to reduce the amount of cheating here. i.e. can't get more than X gold or Y items per level, can't play more than Z games offline, etc) Obviously won't prevent cheating, but it is a single player game so it is not the highest priority.

For the inventory and item instance ID, we plan to store those locally to map the items to the play fab inventory.

I.e. download the inventory from playfab, and just cache that. For items earned offline, it won't have an ItemInstanceID until the client comes back online (where cloudscript can call GrantItem).

That should be okay right?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Jon commented ·

"Download / cache the drop tables" is not recommended. The key point is generating drop table result on server. It will be better to only cache the level status of player when they get offline. A good scenario is that when a player is playing a level, and the network connection is lost after few times of attempts. Then, when the level is completed, a warning may pop up to notify the player that level status is saved and will be restored when online, then quit the game to the login page.

1 Like 1 ·

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.