Sign In Register

How can we help you today?

Start a new topic

Info from meta collection

Hi, have been trying to get some info from my meta collection but couldn't find any updated answers. Most are about runtime(which I can't create anymore) and GetObjectList (which is deprecated).

I'm trying to create a search for a random list of other players, but I am unable to access the playerData, so I have created a playerinfo collection to make them accessible.

So far, I'm able to get the test harness to produce this :

{
  "@class": ".LogEventResponse",
  "scriptData": {
    "PlayerAccessibleInfo": [
      {
        "_id": {
          "$oid": "5b39bc066ed60904dee8f93f"
        },
        "PLAYER_ID": "5b20cb656f217904e66b1e75",
        "PLAYER_NAME": "username1"
      },
      {
        "_id": {
          "$oid": "5b39cd9d159a3704db7910d9"
        },
        "PLAYER_ID": "5b29ffc673b81004da169519",
        "PLAYER_NAME": "username3"
      }
    ]
  }
}

which is what I want.


Here is my method in Unity:


 public void SearchForList()

{

        logEventRequest.SetEventKey("SEARCH_TARGET")

                       .Send((response) =>

                     {

                         if (!response.HasErrors)

                         {

                             Debug.Log(response.JSONData.Count); <<-- returns wrong count

                             Debug.Log(data.GetString("PLAYER_ID")); <<-- returns null

                             Debug.Log(response.JSONString); <<-- returns correct JSON string

                         }

                         else

                         {

                             Debug.Log(response.Errors.JSON);

                         }

                     });

    }


I would like the response to be like this 


if (!response.HasErrors)

{

  GSData data = response.scriptData;


   string targetID = data.GetString("PLAYER_ID");

   string targetDisplayName = data.GetString("PLAYER_NAME);

 }


is this possible?

Thanks in advance.

1 Comment

Your response scriptData is an array called "PlayerAccessibleInfo" of objects. Any one of those objects can be queried for "PLAYER_ID" but not the array as a whole.


Also, a meta collection is inappropriate for this kind of thing as it can't be modified at runtime on a live server. So you would need to use Game Data Service instead.


1 person likes this
Login to post a comment