Sign In Register

How can we help you today?

Start a new topic
Answered

Player database custom fields

 Hello,


It is possible to store and retrieve custom fields/values in a player record in the player database?


Thanks,

Thomas



Best Answer

Thomas,


If you look at the format of a player record (using the NoSQL Explorer), you will notice it has 2 fields: scriptData and privateData which can be used to augment the player record with additional custom fields and values.  The key difference between scriptData and privateData is that privateData does not get returned in any of the API calls that return player data whereas scriptData does.  There is a document on how these fields can be used here:


https://docs.gamesparks.net/howtos/cloud-data/how-to-store-custom-data-against-a-player-using-javascript


Regards,


John.


1 person has this question

Answer

Thomas,


If you look at the format of a player record (using the NoSQL Explorer), you will notice it has 2 fields: scriptData and privateData which can be used to augment the player record with additional custom fields and values.  The key difference between scriptData and privateData is that privateData does not get returned in any of the API calls that return player data whereas scriptData does.  There is a document on how these fields can be used here:


https://docs.gamesparks.net/howtos/cloud-data/how-to-store-custom-data-against-a-player-using-javascript


Regards,


John.

Thanks.  I have got a user event set up, linked to a piece of cloud code which sets a value in scriptData, and this works in the test harness.  I might be missing something, but I can't work out how to trigger the event (passing the required value for scriptData) from my own client code.  I've looked at several HowTo articles, and they all seem to end at the testing stage, omitting the vital step of how to trigger the event from your own code!  i.e.

https://docs.gamesparks.net/howtos/how-do-i-use-cloud-code-on-the-gamesparks-platform

https://docs.gamesparks.net/howtos/cloud-code-scripting/how-to-change-a-players-passwords

https://docs.gamesparks.net/howtos/cloud-data/partial-updates


 

Have found what I was looking for in the SDK documents. e.g. for Javascript it is

gamesparks.sendWithData("LogEventRequest",

{

eventKey : "FIRST_EVENT",

NUMBER_ATTR : 123,

STRING_ATTR : "this is a string",

JSON_ATTR : {key1 : 12, key2 : "abc"}

},

function(response){console.log(JSON.stringify(response);}

);


Still think it would be useful to include this at the end of the HowTos!

 

In the next few days we will start publishing tutorials that will cover more information on all of this.  This will be added to the SDKs area of the manual as this is where the tool specific docs live.  We will start off with Unity Tutorials and then add the same for all of other engines we support (Unreal, Marmalade, Cocos etc).

Login to post a comment