question

Larry Dietz avatar image
Larry Dietz asked

Is it possible to unlock multiple containers at the same time.

I am working on a game, where the users can obtain a chest that contains a single items from a drop table. They user could potentially end up with hundreds of these chests before deciding to open them, Possibly even more.

Is there a way to tell the system to open say 200 of these in a single call, to obtain 200 items from the drop table?

I don't like the idea of having to send potentially hundreds of calls to unlock the containers 1 by 1.

Or is there a better way to accomplish this, than with containers?

**EDIT** One alternative I just thought of, but also do not know if it is possible, would be to programmatically, within cloudscript, create a bundle with the appropriate number of droptable items, and grant that bundle to the player, while at the same time, revoking the container items. Is this a possibility? I haven't found any references to creating bundles in this fashion.

Thanks,

-Larry

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

·
brendan avatar image
brendan answered

Actually, your alternative is entirely possible, and recommended for your scenario. All you would have to do is get the droptable info for the container (Player Item Management - Get Random Result Tables - REST API (PlayFab Server) | Microsoft Docs), and use that to compute what to give the player, using the API call to update the number of item uses (Player Item Management - Modify Item Uses - REST API (PlayFab Server) | Microsoft Docs).

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.

Larry Dietz avatar image Larry Dietz commented ·

Thank you for this! I will give it a shot and see if I can get it working this way.

0 Likes 0 ·
Larry Dietz avatar image Larry Dietz commented ·

Brendan, One additional question. From within cloudscript, how do I get the ItemInstanceID of a newly added item, from the return results of GrantItemsToUser. Nothing I have tried is working.

Here is where I am at... The first case below results in "Message": "InstanceID: undefined"

The 2nd case results in Cannot read property 'ItemInstanceId' of undefined

var NewItem = server.GrantItemsToUser({
 "PlayFabId": currentPlayerId,
 ItemIds
 });
 log.info("InstanceID: " + NewItem.ItemInstanceId);

also tried...

var NewItem = server.GrantItemsToUser({
  "PlayFabId": currentPlayerId,
  ItemIds
  });
  log.info("InstanceID: " + NewItem[0].ItemInstanceId);

**EDIT**

Disregard this. I finally figured it out :) It appears to be working as I want it to now.

Thanks for your help on this!!

-Larry

0 Likes 0 ·

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.