question

Kim Strasser avatar image
Kim Strasser asked

How can I use CloudScript to report toxic players?

I have created limit values in Player Internal Data(permission : Private). I always call my CloudScript right after a player finished a level to compare his current level score with the limit values in Player Internal Data. If the player's level score is above the limit value, then I know that the player is cheating because it's not possible to achieve a higher score than the limit value.

How can I automatically create a report in CloudScript if a player is cheating?

How can I find out if a report was created? Is it possible to get notified if a report was created?

I use this CloudScript to check if the player is cheating or not, but I don't know how to create the report.

https://docs.microsoft.com/en-us/rest/api/playfab/server/player-item-management/reportplayer?view=playfab-rest

function CompareNumbers(result, numberkey, numbervalue)
{
            var resultdatacompare = server.GetUserInternalData({ PlayFabId: currentPlayerId, Keys: [numberkey] });
 
            if (resultdatacompare.Data.hasOwnProperty(numberkey))
            {
                if ((resultdatacompare.Data[numberkey].Value != null) && (resultdatacompare.Data[numberkey].Value != ""))
                {
                    if (resultdatacompare.Data[numberkey].Value >= numbervalue)
                    {
                        log.info("Player is not cheating" + numberkey + numbervalue);
                        return { currentkey: numberkey, addvalue: true };
                    }
                    else
                    {
                        log.info("Player is cheating, create a report" + numberkey + numbervalue);
                        return { currentkey: numberkey, addvalue: false };
                    }
                }
                else
                    return { currentkey: "", addvalue: false };
            }
            else
                return { currentkey: "", addvalue: false };
}
CloudScript
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

·
Citrus Yan avatar image
Citrus Yan answered

The Server/ReportPlayer API is designed to submit a report about a player on behalf of another player, hence you must provide both the reporter and the reported player’s Id (Usually PlayFabId ) in the request. However, you must note that players are currently limited to five reports per day, which means that the reporter you specified can only report 5 times a day. And I see you probably want to handle all the players’ reports from CloudScript using the ReportPlayer API, which seems problematic to me since:

  1. Which player to designate as the reporter?
  2. When the player you specified as the reporter runs out of reports, do we need to specify a new player? If we do, then this process will keep going on and on, which doesn’t seem to be a good practice to me.

Therefore, what I suggest is using Server/WritePlayerEvent to write a player-based event to record the cheating players and look into these events from the Event History to see which player cheated. For instance, here is a sample flow:

  • Let’s suppose the player (PlayFabId: EDC62C2C6738ECA8) is cheating, then we call Server/WritePlayerEvent with the following info in the request:
{
  "PlayFabId": "EDC62C2C6738ECA8",
  "EventName": "player_cheated",
  "Body":{
                "Comment":      "player is cheating." 
         }
}
  • Navigate to <Game Manager> - <Data> - <Event History>, search for the “player_cheated” event we just wrote into the PlayStream (note that it usually takes few minutes before they appear in the event history), you can get the following data:
{
  "PlayFabEnvironment": {
    "Application": "mainserver",
    "Vertical": "master",
    "Commit": "5689b8c",
    "Cloud": "main"
  },
  "EventNamespace": "title.xxx",
  "EntityType": "player",
  "SourceType": "GameServer",
  "EventName": "player_cheated",
  "Timestamp": "2019-11-29T03:12:19.3464766Z",
  "EntityId": "EDC62C2C6738ECA8",
  "EventId": "05e5f4ac1a9549d58f731332e184a072",
  "TitleId": "xxx",
  "Source": "xxx",
  "Comment": "player is cheating."
}
  • EntityId in the event data corresponds to the cheating player’s PlayFabId, you can use it to identify the cheating player:
  • Please note that the Event History has 7 days retention, you need to gather cheating players’ data within no more than 7 days in case of data loss.
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.