question

patrickmonville avatar image
patrickmonville asked

UnlockContainerInstance: error when uses left = 1

Hi,
I have the following method in the cloud script and it return null when uses left = 1.

// This function unlock a surprise boxes and update the beast if one is awarded
handlers.unlockSurpriseBox = function (args) {
    var playfabId = args.playfabId;
    var containerItemInstanceId = args.containerItemInstanceId;
    var unlockRequest = server.UnlockContainerInstance(
    {
        PlayFabId: playfabId,
        ContainerItemInstanceId: containerItemInstanceId
    });

    log.debug(unlockRequest)

    unlockRequest.GrantedItems.forEach(function (item)
    {
        addBeastInstanceCustomData(item, playfabId);
    });

    return unlockRequest.GrantedItems;
}

The object referenced by the itemInstanceID is a Container that is stackable and consumable.

What I found out is that the error happens when server.UnlockContainerInstance is called.

Could it be that the "By Count" variable in the Container has to be zero? It is currently 1.

If that is not it, does someone have any idea?

PS: everything work fine as long as the uses left > 1.

CloudScript
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

What's the title ID for this, and do you mind if we create a player account in it to do some testing?

Also, quick question - why are you passing in the PlayFab ID, rather than using the locally defined currentPlayerId?

4 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.

patrickmonville avatar image patrickmonville commented ·

1) The title ID is 71E4 ("ApocalypseHunters_Alpha") and I don't mind if you create an account.

2) I don't know, the cloud script was written by my predecessor and I have not touched it yet.

0 Likes 0 ·
brendan avatar image brendan patrickmonville commented ·

So, I created this player:

https://developer.playfab.com/en-us/71E4/players/2545B16AF6D05742/inventory

Added one of the container items (you can see it in the revoked item list now), and called that Cloud Script handler on it, and it worked fine. The item had 1 use remaining, was consumed, and correctly added the item that's now in the inventory. Can you walk me through your specific repro steps?

0 Likes 0 ·
patrickmonville avatar image patrickmonville brendan commented ·

I run a test ingame. I started with 2 uses left and opened twice, the second time it failed.

http://imgur.com/a/4jm1j

(the album contains stacktraces and the code that call the cloud script method in the op)

0 Likes 0 ·
Show more comments

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.