Sign In Register

How can we help you today?

Start a new topic
Answered

View/Edit Player Private Data

Curious if there is anyway to view/edit a player's privateData key value pairs from the NoSQL viewer. Trying to verify that data is getting correctly formatted and written. I am failing to see anything in the NoSQL explorer relating to privateData.


From Cloud Code:

player.setPrivateData("blah", blah);


Best Answer

Hi Evan,


Yes you could use the the REST API to connect externally, you would just need to authenticate with your Admin username and password in your REST client of choice, you can read more about REST here. You could also use the Callback URL to make HTTP calls into the GameSparks platform and then execute some custom cloud code in the Callback URL system event, this is located in the Cloud Code System menu under Callback URL. You can read more about how to implement that here. It might be easier for you to create a custom collection to store this data in. You could insert a document for each player using the the playerID to name them (this helps for retrieval) and keep all the data you need in there rather than storing in each user's privateData. If you need any more help just let me know.


Thanks,

Liam




Hi Evan,


It's best to use SparkPlayer calls to change any of the details on the player document. You can read more about SparkPlayer here.


The following will set the privateData of the current Authenticated Player in Cloud Code.


var userName = Spark.getPlayer().setPrivateData("name", "value");


 

You can then use this to get the current players privateData

 

var userName = Spark.getPlayer().getPrivateData("name");

 


Removing the privateData of the current user can be achieved with


var userName = Spark.getPlayer().removePrivateData("name");

 


Thanks,

Liam


So it sounds like there is no way to edit a player's privateData from the NoSQL viewer? Only from inside a player socket connection?


My aim is to mark userData edits in a user's private data allowing them to integrate these changes with their live data via structured calls that check for the existence of these markers. I would use these modifiers to correct userData based complaints, bugs, etc in our game such as added additional coin. So how would I be able to edit a player's private data from outside the player's socket connection?


Along similar lines, is there any way to interact with the server from outside a player socket connection?

Answer

Hi Evan,


Yes you could use the the REST API to connect externally, you would just need to authenticate with your Admin username and password in your REST client of choice, you can read more about REST here. You could also use the Callback URL to make HTTP calls into the GameSparks platform and then execute some custom cloud code in the Callback URL system event, this is located in the Cloud Code System menu under Callback URL. You can read more about how to implement that here. It might be easier for you to create a custom collection to store this data in. You could insert a document for each player using the the playerID to name them (this helps for retrieval) and keep all the data you need in there rather than storing in each user's privateData. If you need any more help just let me know.


Thanks,

Liam



Login to post a comment