Sign In Register

How can we help you today?

Start a new topic
Answered

Should the player level be a Virtual Good?

Hi,

I noticed that the createAccountDetailsRequest() and the createListVirtualGoodsRequest() methods both return a:


GSData virtualGoods = response.getVirtualGoods(); for the first method and

List<GSTypes.VirtualGood> virtualGoods = listVirtualGoodsResponse.getVirtualGoods(); for the second method.

What's the difference between both?

And, finally, where do I create my player value? As a Virtual Good? Or should I create a property that I should attach to the player data?

Thanks


Best Answer

Hi Felipe,


The virtualGoods value obtained from the AccountDetailsResponse details the amount of each good the player has:


"virtualGoods":{

    "item1":1,

    "item2":10,

    "item3":5,

}


A ListVirtualGoodsResponse on the other hand, returns an array containing more detailed information on each virtual good:


"virtualGoods":[{

    "currency1Cost":10,

    "currency2Cost":1,

    "description":"Test good",

    "disabled":false,

    "name":"testGood",

    "propertySet":null,

    "shortCode":"testGood",

    "type":"VGOOD",

    "bundledGoods":[{

         "shortCode":"bundleTest",

         "qty":1

     }]

},....]


There are several ways to store custom player data. For something like player level I would suggest storing it in the player's scriptData or privateData.


Hope this helps.


Regards,

Vinnie


Answer

Hi Felipe,


The virtualGoods value obtained from the AccountDetailsResponse details the amount of each good the player has:


"virtualGoods":{

    "item1":1,

    "item2":10,

    "item3":5,

}


A ListVirtualGoodsResponse on the other hand, returns an array containing more detailed information on each virtual good:


"virtualGoods":[{

    "currency1Cost":10,

    "currency2Cost":1,

    "description":"Test good",

    "disabled":false,

    "name":"testGood",

    "propertySet":null,

    "shortCode":"testGood",

    "type":"VGOOD",

    "bundledGoods":[{

         "shortCode":"bundleTest",

         "qty":1

     }]

},....]


There are several ways to store custom player data. For something like player level I would suggest storing it in the player's scriptData or privateData.


Hope this helps.


Regards,

Vinnie

Hey Vinnie,


Thanks a lot for the prompt response. Definitely helps.

I will do as suggested and save my player's level in the privateData.


Cheers,

Felipe

Vinnie,


One last question... My game is Android native, so using the Android SDK.


How can I retrieve the player's private data and set any data there? I had a look at the Request API but could not find anything - I think.

I am guessing I need to create an Event for this, but not sure.


Thanks

Hi Felipe,


Yes, you are correct. A player's private data, by design, isn't returned along with the rest of the player data in, say, an AccountDetailsRequest. You would need to setup 'getter' and 'setter' events for modifying or retrieving this information. 


Your 'setter' function will need an attribute to accept the value you wish to set the privateData to. The 'getter' would look something like this:


Spark.setScriptData(Spark.getPlayer().getPrivateData("level"));


Vinnie

Login to post a comment