Forum PayVault Best way to start player with a given coin amount

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

Best way to start player with a given coin amount

Postby wildbunny » July 13th, 2011, 6:25 pm

Hi guys,

I'm looking for the best way I can give a player an initial coin amount when they first ever register with my game - and obviously never again :)

Because everything is room-based I'm having difficulty working out how to do it correctly.

Any advice? :)

Cheers, Paul.
wildbunny
 
Posts: 217
Joined: March 9th, 2011, 10:35 am

Re: Best way to start player with a given coin amount

Postby Toby » July 13th, 2011, 7:13 pm

I would either check their PlayerObject, to see if this was their first play, or do something like this (I pretty much cut/paste this from the PayVault docs) in the first UserJoined instance.

Code: Select all
PayVault vault = player.PayVault;
vault.refresh();
//Read the player's payvault history.
vault.ReadHistory(1, 10, delegate(PayVaultHistoryEntry[] history) {
   //No payvault history, new user.
   if (history.Length == 0) {
      vault.Credit( INITCOINS, "Player started", creditCallback, creditFailureCallback );
   }
});
User avatar
Toby
 
Posts: 86
Joined: January 14th, 2010, 4:01 pm

Re: Best way to start player with a given coin amount

Postby wildbunny » July 13th, 2011, 7:22 pm

Thanks Toby :) Must have missed that in the docs....
wildbunny
 
Posts: 217
Joined: March 9th, 2011, 10:35 am


Return to PayVault