We have this CloudScript to get all the PlayFab Ids from player in a segment:
handlers.onGetOnlinePlayers = function(args, context) { var onlineList = {}; onlineList = server.GetPlayersInSegment({ "SegmentId": "DF433C53264DE4EF" }) var playerListIDs = {"onlinePlayers":[]}; for(i =0; i < onlineList.ProfilesInSegment; i++) { playerListIDs.onlinePlayers.push(onlineList.PlayerProfiles[i].PlayerId); } return playerListIDs; };
It works exactly how it should sometimes and finds all the players in the segment, however, this message is often received when executing it from the dashboard
{ "FunctionResult": null, "Logs": [ { "Level": "Error", "Message": "PlayFab API request failure", "Data": [ [ [] ], [ [ [ [] ] ] ], [ [] ] ] } ], "ExecutionTimeSeconds": 7.0001722, "MemoryConsumedBytes": 108888, "APIRequestsIssued": 1, "HttpRequestsIssued": 0, "Error": { "Error": "InternalServerError", "Message": "InternalServerError", "StackTrace": "Error\n at handlers.onGetOnlinePlayers (9BBE-main.js:416:23)" } }
Answer by Brendan · Nov 22, 2017 at 09:44 PM
Can we start with a high level overview of what you're attempting to accomplish? It looks like you're attempting to track on all online players. If so, that's not going to work for a few reasons:
1. Segment evaluation, which is an expensive operation, occurs on a call to GetPlayersInSegment. For that reason, you can't call it at high frequency, and certainly not based on a client-driven action.
2. Since we don't use a socket-based connection (we will provide this in a future release), you'd be tracking on this by updating some value on the player account. That's fine if you're doing it every minute or two, but if you're attempting to do this at high frequency, that runs the risk of exceeding our fair use terms.
3. For any game with a good user population, you'll exceed the limit on how many profiles can be returned in a single call to GetPlayersInSegment. Using the ContinuationToken in a Cloud Script isn't really an option because it would push the script to excessive API calls and processing time.
We will be providing a "presence" system of our own in a future release. For now, I would recommend using the player last login time (which you can get from the profile information in leaderboards, for example) as a way to get information on active players. Alternately, if your game is realtime gameplay focused, you may need to consider using a custom game server, so that you can have players connect to it for shared realtime information on others playing.
GetPlayerCombinedInfoRequest no longer includes DisplayName in response 2 Answers
TypeError when trying to declare a call to server.GetPlayersInSegment(); 1 Answer
Request timeout 3 Answers
JSON Field Reformatting on Automation Save 2 Answers
Get players in segment count Via cloud script and update title data 1 Answer