question

chorustempo avatar image
chorustempo asked

ExecuteCloudscriptRequest Function Parameter?

onsuccess.png

I have a function that I want to call via the client to get a list of player data for the players within a segment. The segment will only have a few players in it at one time (they have a unique currency temporarily assigned to them that is used for a minigame within the game) and the function isn't called very often by the player.

It successfully returns the correct playerIds from the segment when run (as per the output log below). However, I'm not sure how to break apart the json object that is returned in order to get the playerIds in a usable format. Is there a diagram somewhere of the different field / fieldnames within segments that I can use for this? It's the onlinePlayers list I'm trying to get.


Output log:

LogPlayFab: Request: {
    "FunctionName": "onGetGameTableSearchPlayers",
    "GeneratePlayStreamEvent": true,
    "RevisionSelection": "Live",
    "SpecificRevision": 0
}
LogPlayFab: Response : {"code":200,"status":"OK","data":{"FunctionName":"onGetGameTableSearchPlayers","Revision":5,"FunctionResult":{"onlinePlayers":["ADDB69F10466C303","2E972C415A03F7D4","BA931F93062E4435","84216BEBAF60FE9D","559972548A474089","4681A31E95948627","C5A912D46A35FE36","B419B933F2835BA5","BA3008AF57D80896","65FC4C07D1E1AB0B"]},"Logs":[],"ExecutionTimeSeconds":0.0553921,"ProcessorTimeSeconds":0.002329,"MemoryConsumedBytes":27000,"APIRequestsIssued":1,"HttpRequestsIssued":0}}
LogBlueprintUserMessages: [GameInstance_Custom_C_40] PlayFabJsonValue_1530


The function code:

// Return player data for Game Table Search Players segment.


handlers.onGetGameTableSearchPlayers = function(args, context)
{
  var onlineList = {};
  
  onlineList = server.GetPlayersInSegment({
    "SegmentId": "4F4A4A543C81A9A"
  })
  
  var playerListIDs = {"onlinePlayers":[]};
  
  for(i =0; i < onlineList.ProfilesInSegment; i++)
  {
      playerListIDs.onlinePlayers.push(onlineList.PlayerProfiles[i].PlayerId);
  }
  
  return playerListIDs;
  
};
unreal
onsuccess.png (102.4 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
chorustempo avatar image
chorustempo answered

Solved: For future reference...


blueprint.png (137.4 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.