Sign In Register

How can we help you today?

Start a new topic
Answered

How do I access a custom currency returned from ListVirtualGoodsRequest

Okay how do I access a custom currency from GameSparks.Api.Responses.ListVirtualGoodsResponse._VirtualGood?


I can see there is a currencyCosts  in the returned response but how do I access it with the Unity SDK?


Thanks

Quentin


Best Answer

Hi Quentin,


Sorry for the late reply. Our SDK will update shortly to allow you to interact with  the new currency system. I apologise for the delay.


It will be:


  

int currencyCosts =(int) virtualGood.CurrencyCosts.getNumber("currencyName");

  


Cheers,

Omar


Answer

Hi Quentin,


Sorry for the late reply. Our SDK will update shortly to allow you to interact with  the new currency system. I apologise for the delay.


It will be:


  

int currencyCosts =(int) virtualGood.CurrencyCosts.getNumber("currencyName");

  


Cheers,

Omar

Thanks for your reply. Is there a way I can pull this information with a logevent and cloud code? I'm thinking it might be better that way.

Have this in your event's cloud code:


 

Spark.setScriptData("balance",Spark.getPlayer().getBalance("currencyName"));

 


Cheers,

Omar

Thanks, I haven't tried that but won't that just get me the balance of the virtual  currency?   I was looking for the currency cost of a virtual good. I did some digging around and found I can get the value using the rest api for Virtual goods.  it's mapped under  currencyCostMap ? but it's not available in the JSON returned from ListVirtualGoods when using cloud code. 


I tried   SparkConfig.getVirtualGoods() but I'm getting a "ReferenceError: "SparkConfig" is not defined "when I run it in the test harness.


Thanks for your help

Quentin



Hi Quentin,


To get an instance of a SparkConfig object, you need to use Spark.getConfig(), e.g.


var virtualGoods = Spark.getConfig().getVirtualGoods();


Hope this helps,


Jon.


That works. Thanks for your help Quentin
Login to post a comment