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
C
Customer Support
said
about 6 years ago
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
Customer Support
said
about 6 years ago
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.
Adrià Martín
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?
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.
You should now have the updated "Card Collection" object stored in the players privateData.
Regards,
Liam
Customer Support
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.
You should now have the updated "Card Collection" object stored in the players privateData.
Regards,
Liam
1 person likes this
-
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