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
F
Felipe Caldas
said
over 6 years ago
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
Customer Support
said
over 6 years ago
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:
Felipe Caldas
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
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
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
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
Felipe Caldas
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
Felipe Caldas
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
Customer Support
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
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics