question

[not provided] avatar image
[not provided] asked

Using normal code with playfab code

I was wondering, could I use normal code with playfab code?

I know, that makes no sense, so I'll provide an example which should make it a lot more clear (Im quite tired right now but I wanted to ask this before I forgot)

So lets say I wanted to make something have a 1 in 10 chance of granting the user 1 coin. Could I do this (within Unity I suppose)

 

if (RandomNumber1to10 = 1){

Playfab.grantcoin (obviously not the actual code, but you get the idea)

}

Hopefully you can help me out with this, since Im still new to learning playfab.

 

Cheers

Tom

P.s. I hate to ask 2 questions that arent related in one thread, but in case you know, do catalog purchases and inventories and stuff like that cache on the users device and allow them to use the game offline/whilst not logged it?

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

For the first question, yes, you can put a random number check in a Cloud Script to do what you describe. Alternately, if what you want to do is set up an array of possible rewards, you can use our Drop Tables in your game's economy to set up the list of possible items to give the player, and the odds for each. What you would do then is to either make the Drop Table part of a container and grant that to the player, or else make it part of a bundle (you can set the bundle to expire after 1 second, if you want it to go away after adding the loot). And if you want to give the player VC, just make that a bundle and add the VC to it (and set the bundle itself to expire). You can then add that item to the Drop Table.

For the second question, our SDKs don't automatically cache the inventory for you, but that's definitely an option. All the PlayFab API calls are Web API calls at the core, so you do need an active internet connection to update the player's data in our service.

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.