2016-12-22 5 views
0

게임 코드 클라우드 코드를 구현하는 방법에 문제가 있습니다. 추가 게시 버튼을 만들고 싶습니다. 데이터는 gamesparks 런타임 컬렉션에 저장됩니다. 지금까지 내가 한 것은 각 플레이어에 대해 단 하나의 버튼 하나만 저장하는 것입니다. 하지만 플레이어 데이터 목록을 만들어야하므로 한 명의 플레이어가 멀티 플레이어 데이터를 런타임 컬렉션에 저장할 수 있습니다.Gamespark 런타임 컬렉션에 데이터 목록을 게시하는 방법? Unity C#

Spark.setScriptData("player_Data", currentPlayer); // return the player via script-data 
var playerDataList = Spark.runtimeCollection("playerNewspaper"); // this will get the collection of player data 
    var playerID = Spark.getPlayer().getPlayerId(); // first we get the id of the current player 
    var playerUsername =Spark.getPlayer().getUserName(); 
    var newspaper = Spark.getData().newspaper; 

    var currentPlayer = { 
    "playerID": playerID, 
    "playerUsername": playerUsername, 
    "player_newspaper": newspaper 

    }; // we construct a new player from the data we are about to input into the player data 

    playerDataList.insert({ 
    "playerID": playerID 
    }, //Looks for a doc with the id of the current player 
    { 
    "$set": currentPlayer 
    }, // Uses the $set mongo modifier to set old player data to the current player data 
    true, // Create the document if it does not exist (upsert) 
    false // This query will only affect a single object (multi) 
); 

이 구름 코드는 하나의 플레이어에 대한 하나 개의 데이터를 저장합니다 다음은 내 클라우드 코드 gamesparks입니다. 동일한 ID 플레이어로 데이터를 저장하면 작동하지 않습니다. 다음은

가없는 NoSQL 데이터 미리보기입니다 : 아래 내 NoSQL에 미리 데이터입니다 : 나는 선수 데이터 게시 목록을 만들고 싶어

{ 
"_id": { 
    "$oid": "5850dfdb135f38fb1edbf28c" 
}, 
"playerID": "57bffe76b6a70d6e2a3855b7", 
"playerUsername": "dennis", 
"player_newspaper": "{\"ID\":\"57bffg77b6a70d6e2a3855b7\",\"Username\":\"Dennis\",\"itemName\":\"Egg\",\"Comment\":\"Promo Telur 1 Butir cuman murah\",\"Date\":\"12/14/2016\"}" 
} 

. 게시가 아닌 동일한 플레이어입니다.

이 목록을 게시하는 데이터는 다음 무작위로 5 개의 데이터를 쿼리하고이를 신문이라고합니다.

어떻게 만드시겠습니까?

감사 데니스

답변

0

마지막으로 내가 솔루션에게 자신을 얻었다.

나는 이것이 mongodb dan javascript라는 것을 알고 있습니다.

추가 데이터 :

그래서 MongoDB의에서 당신은 어떻게 여기 MySQL은 같은 데이터를 삽입 할 경우

var playerDataList = Spark.runtimeCollection("playerNewspaper"); // this will get the collection of player data 
    var playerID = Spark.getPlayer().getPlayerId(); // first we get the id of the current player 
    var playerUsername =Spark.getPlayer().getUserName(); 
    var newspaper = Spark.getData().newspaper; 

    var currentPlayer = { 
     "playerID": playerID, 
     "playerUsername": playerUsername, 
     "player_newspaper": newspaper 

    }; // we construct a new player from the data we are about to input into the player data 

    playerDataList.insert(
    { 
     "newspaper" : currentPlayer 
    } // Uses the $set mongo modifier to set old player data to the current player data 
    ); 

무작위로 5 항목과 데이터로드의 경우 :

var playerData = Spark.runtimeCollection("playerNewspaper"); // get the collection data 
var currentPlayer = playerData.find().limit(5).skip(Math.random() * playerData.count()); 

Spark.setScriptData("player_Newspaper", currentPlayer); // return the player via script-data 

모두보기