Sign In Register

How can we help you today?

Start a new topic
Answered

Save a data field for each player

Hello , I need to save a integer for each player , this integer must be able to be consulted and updated by the client.
I'm thinking of implement it in ScripData of each player. 
How I can do in android?
I 'm right when implemented in ScripData or should I use NoSQL database.


THANKS

Best Answer

1.) Add a runtime collection to the NoSQL database. You can call this collection something like customPlayerData.

2.) Add your integer field to this collection.


3.) Create an event that can be called from the client

4.) Create cloud code that queries the customPlayerData collection, you can use something like this...

 

var playerId = Spark.getPlayer().getPlayerId();
var playerCustomData = Spark.runtimeCollection("playerCustomData").find({"playerId":playerId});

Spark.setScriptData("playerCustomData", playerCustomData);

 


Answer

1.) Add a runtime collection to the NoSQL database. You can call this collection something like customPlayerData.

2.) Add your integer field to this collection.


3.) Create an event that can be called from the client

4.) Create cloud code that queries the customPlayerData collection, you can use something like this...

 

var playerId = Spark.getPlayer().getPlayerId();
var playerCustomData = Spark.runtimeCollection("playerCustomData").find({"playerId":playerId});

Spark.setScriptData("playerCustomData", playerCustomData);

 

Thanks Greg!!!! but how I can do in android?

The code of client side to do a update in server ?


Thanks Greg!!! but how I can do the consult and update in android code in the client side.?

Hi Ignacio,


Are you using the Unity SDK? Or are you using the native Android Java SDK?


If you're using native Java sorry I don't know how to help, I would suggest creating a support ticket and ask them to help you with the code on that.

Login to post a comment