question

shin chang seop avatar image
shin chang seop asked

server.DeletePlayer not work

handlers.DeleteGuestPlayer = function (args, context) {
    var message = "PlayFabId " + args.GuestPlayerId;
    log.debug(message);
    
    var request =  
    { 
        "PlayFabId":args.GuestPlayerId 
    };
    
    var response = server.DeletePlayer(request);
    log.debug("Deleted player with result: " + response);
    
    return response;
};



  "ExecutionTimeSeconds": 0.0238399,
    "MemoryConsumedBytes": 14120,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0,
    "Error": {
        "Error": "CloudScriptAPIRequestError",
        "Message": "The script called a PlayFab API, which returned an error. See the Error logs for details.",
        "StackTrace": "Error\n    at Object.server_request (Script:180:24)\n    at Object.server.DeletePlayer (Script:507:69)\n    at handlers.DeleteGuestPlayer (D5DFC-main.js:591:27)\n    at Object.invokeFunction (Script:116:33)"
    }

How to delete Player by CloudScript ?
Player Data
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

·
Sarah Zhang avatar image
Sarah Zhang answered

This error means the PlayFab API you called in this function returned an error, you can check the error messages in the response’s Logs field to learn the specific API error or add try/catch in this function like this documentation said to handle the error. After test, we also found your CloudScript function works fine, this error may be caused by the invalid PlayFabIds, for example, duplicate deletion of one account would cause such error. You may need to check the client code.

Besides, please note that the Server.DeletePlayer should be called by someone who has the high administrator permission. Using the PlayFabId parameter passed from the client directly is unsafe. It means once the players know anyone’s player Id, they can delete any account. We would suggest you modify it to prevent the potential security problems. You need to perform the complete validation for the guest player Id uploaded by the client to ensure the current player has the right to delete this guest account.

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.