question

brendan avatar image
brendan asked

UnlockContainerItemResult.VirtualCurrency = NULL

flekoun
started a topic on Sun, 10 May 2015 at 10:22 AM

Hello,

Either I am doing something wrong or there is a bug in this callback. UnlockContainerItemResult.VirtualCurrency should contain dictionary of all VC granted to player for opening the container but this dictionary is always null even though I add many VCs to the player in the container. However the VCs are granted to player correctly.

Am I doing something wrong here?

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

7 Comments
Brendan Vanous said on Mon, 11 May 2015 at 11:44 AM

This is a known issue, which we're working to resolve. I'll update here as soon as a fix has been deployed.


flekoun said on Fri, 15 May 2015 at 4:20 AM

Hello,

thanks for looking into this. I am waiting for a fix. However I have one more issue to discuss:

When a player opens a container which suppose to be a gift for example "Egg Gift" ( so no key is needed and the container has 1 use and the container is EMPTY ...as it should be a gift of 1 Egg for example (some in game stuff) and not VC neither any other container/bundle). So I will call UnlockContainer with Item ID = "EggGift". Then the callback is returned and I will get UnlockContainerItemResult. That is all nice. However I am now in situation that I know player unlocked SOME container/bundle but I do not know which one. As the UnlockContainerItemResult does not return ContainerItemID it only returns ItemInstanceID and other stuff which wont help me to detect what the player actually opened and what should I give to him. The best would be if the UnlockContainerItemResult also returns ContainerItemID. If it would I will simply check whether ContainerItemID.Equals ("EggGift") and grant a player an Egg. Or I am doing this all wrong? I simply get to the point where I want grant player items and when player click on them I will grant him some of my ingame items (not VCs not other items in catalog).

PS: I should be using ConsumeItem and not Open Container. However the result is the same ConsumeItemResult is not returning ItemID but just ItemInstanceID and I still cannot tell what the player actually consumed.


flekoun said on Fri, 15 May 2015 at 4:27 AM

Also is there any way how to determine whether the item is Container or just Item in inventory? Just seems that I can Call both UnlockContainer or ConsumeItem on item in inventory.


flekoun said on Fri, 15 May 2015 at 4:30 AM

Also the UnlockContainer requests "ItemID" and the ConsumeItem requests "ItemInstanceID" in order to be called correctly. Just cant see why this is different. Ok, Hope you don't get confused by my messages too much :D


Brendan Vanous said on Tue, 19 May 2015 at 1:04 AM

Hi again,

There seems to be some confusion, so let me walk through all the aspects of using containers, to see if I can help:

First off, you should not need to make any determination of what items to add to a player's inventory when a container is opened. That's the point of a container in our system - it holds a set of items (which may include randomly determined items), which are automatically added to the player's inventory when the container is opened using the UnlockContainerItem API call.

You should not be using the ConsumeItem call on a container, as that will decrement the usage count without delivering any items to the player inventory. The difference between the calls is that ConsumeItem is meant to be called on a specific consumable item in the player's inventory (hence the need for the ItemInstanceId). Imagine a player with three health potions, each with three uses - when drinking one use, you would need to specify which instance he's using, so that you know which one now has only two uses left. For containers, since the contents aren't known, you would just specify the ItemId, so that you know the general item and pick one in the active player inventory.

When you do unlock the container, the results will include an UnlockedItemInstanceId, which is the ItemId of the container. To see if a given ItemId is a container, you would need to check the details for the item in the game's Catalog, which you could read once into memory for purposes of a gameplay session. Alternately, you could use the ItemClass property to store data about an item specific to your title, so you could specify something there which indicates that the item is a container.

So in short, always use UnlockContainerItem when opening a container in the player's inventory, whether or not a Key item is used to open it.


flekoun said on Tue, 19 May 2015 at 1:50 AM

Hi,

thanks a lot for your explanation! However one thing is still not clear for me. If I consume an Item in inventory. The callback which returns ConsumeItemResult contains only ItemInstanceId of item which has been consumed and RemainingUses of this item. But how can I know which item has been consumed to give a player correct reward?

In your example of Health potions. When I call Consume item it will decrease the remaining uses of health potions but also I have to add player the health. But only thing I know from callback is that item with itemID "XXX" has "YYY" remaining uses but I do not know that player consumed Health potion or Mana potion in order to give him correct reward.


Brendan Vanous said on Tue, 19 May 2015 at 6:32 PM

The ItemInstanceId matches the ID in the user's inventory, which contains all the info on the item in question (ItemId, etc.). Once you read the player's inventory from the service, you should keep it around, so that you can look up the corresponding info in these operations.

Brendan

10 |1200

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

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.