Sign In Register

How can we help you today?

Start a new topic
Answered

Adding values to player private data

Hi!


It's possible to add values to a specific data inside player private data?


e.g: Player have a card collection of 5 cards. This is how it looks in NoSQL:


"privateData" : {

   "Card Collection" : {

     "Cards" : [

       "Card1",

       "Card2",

       "Card3",

       "Card4",

       "Card5"

      ]

    },

},


And when the player obtain a new card, i want to add that card inside "Cards". Is it possible?


Best Answer

Hi Adria,


This is currently being addressed in your ticket. Just posting here so the team is aware of this. To cover your original question for the benefit of other users, what you'll need to do here is get the "Card Collection" privateData, update the array and then set it again.


 

//get the card collection object
var cardCol= Spark.getPlayer().getPrivateData("Card Collection");

//add the new card to the array

//set the updated privateData
var cardColUpdate = Spark.getPlayer().setPrivateData("Card Collection", updatedObject);

 

You should now have the updated "Card Collection" object stored in the players privateData.


Regards,

Liam

1 Comment

Answer

Hi Adria,


This is currently being addressed in your ticket. Just posting here so the team is aware of this. To cover your original question for the benefit of other users, what you'll need to do here is get the "Card Collection" privateData, update the array and then set it again.


 

//get the card collection object
var cardCol= Spark.getPlayer().getPrivateData("Card Collection");

//add the new card to the array

//set the updated privateData
var cardColUpdate = Spark.getPlayer().setPrivateData("Card Collection", updatedObject);

 

You should now have the updated "Card Collection" object stored in the players privateData.


Regards,

Liam


1 person likes this
Login to post a comment