Forum PayVault PayVault Consume Item Problem

Discussion and help relating to the PlayerIO payment solution, PayVault.

PayVault Consume Item Problem

Postby X-Jack Rich » August 1st, 2015, 9:08 pm

Ive been making a action in my game where you can delete (consume) and item u want and as many times you want. I already made it to add with the repeat function and it works great, now in consume the repeat function doesnt work THIS IS IN C# !


Code: Select all
int repeat = 10;
                                for (int i = 0; i < repeat; i++)
                                {
                                    vault.Refresh(null);
                                    VaultItem boost = vault.First("glasses");
                                    vault.Consume(new VaultItem[] { boost }, null
                                    });
                                }


It doesnt repeat. It deletes the item only once. I think the problem is in VaultItem boost = vault.First("glasses"); is there any other identifier you can use but not .First


If anyone has any other solution please help! thanks
X-Jack Rich
 
Posts: 13
Joined: July 26th, 2014, 10:14 am

Re: PayVault Consume Item Problem

Postby Henrik » August 4th, 2015, 12:27 am

I'm amazed that that actually even works one time, it shouldn't even do that, since the Consume method needs to take an actual VaultItem, not one you just constructed.

Also, Consume can take an array of VaultItem, so if you want to consume the first 10 items of a specific key, I'd do something like this:

Code: Select all
var list = new List<VaultItem>();
foreach(var item in vault.Items) {
   if(item.ItemKey == "glasses") {
      list.Add(item);
      if(list.Count == 10) {
         break;
      }
   }
}
vault.Consume(list.ToArray(), null);
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: PayVault Consume Item Problem

Postby X-Jack Rich » August 4th, 2015, 4:08 pm

THANK YOU VERY MUCH! :D :D :D :D :D :D :D :D :D :D :D :D :D
X-Jack Rich
 
Posts: 13
Joined: July 26th, 2014, 10:14 am


Return to PayVault