Sign In Register

How can we help you today?

Start a new topic

Awarding player random Virtual good and informing him

Hi, I’d like to implement a system in my game where players can get win random items after they won matches. From what I understood, Virtual Goods might be the way to go. How I think it should work is that after a match is completed, a is chosen and random virtual good server-side and assigned to the player. Now, the player should be informed in-game that he has received this item. - What would be the best way to chose a random item the player does not possess yet? -How can the player be informed that he received a specific Virtual Good? Thanks! Thanks a lot, as always!

Sorry for the bad formatting, I wrote this on my iPad and it seemed to got messed up. Therefore, here again:

Hi,

I’d like to implement a system in my game where players can get win random items after they won matches. From what I understood, Virtual Goods might be the way to go.
How I think it should work is that after a match is completed, a is chosen and random virtual good server-side and assigned to the player. Now, the player should be informed in-game that he has received this item.

- What would be the best way to chose a random item the player does not possess yet?
- How can the player be informed that he received a specific Virtual Good?

Thanks a lot, as always!

 

Hi Axel,


There's no out-of-the-box way to do this, but it's definitely achievable through cloud code. You'll need to obtain a list of all virtual goods (through Spark.getConfig()); and a list of the player's virtual goods (through Spark.getPlayer()) and compare the two; building an array of shortcodes that are in the first list, but not the second. You can then choose which one to award by generating a random number between 0 and the array's length and using this number to index into the array.


Regarding informing the player of the award; how you go about this would depend on the flow of your game/matches. If you're using our challenges for this your could add the details of the awarded good to the ChallengeWonMessage's scriptData. If you're using your own implementation you could send a message to the player through cloud code (Spark.message).


Hope this helps. If you run into any further issues please let us know.


Regards,

Vinnie

Login to post a comment