Sign In Register

How can we help you today?

Start a new topic

how do i save user's item?

There seems to be little data on GameData.

I see this link : https://docs.gamesparks.com/tutorials/database-access-and-cloud-storage/saving-and-loading-player-inventory-data.html

It was hard to find out that Spark.RuntimeCollection was not going to work.


I want to save the items that the user has.

My Code is...


var itemIdx = Spark.getData().idx

var player = Spark.getPlayer(); 

var item = Spark.metaCollection('items').findOne({"key" : itemIdx}); 

var gamedataService = Spark.getGameDataService(); 

if(item) 

{

var entry = gamedataService.createItem("userhasitem", itemIdx); 

var data = entry.getData(); 

data.itemidx = itemIdx;

entry.persistor().persist().error();

}


When i search GameData with the user key, i get the result.

but only one is stored. be overwritten.

i think i have to use a different data storage system to store user items.

How do you usually implement them?


Login to post a comment