I have a banned player who uses LoginWithIOSDevice to log in. But he can't log in because he is still banned. Is it possible to display the ban creation and expiration time to the player when he tries to log in with LoginWithIOSDeviceID or LoginWithPlayFab?
I have tried to call my CloudScript but the call is not executed because the player is still banned. In addition, I don't know how to check in CloudScript if the expiration time of an active ban is greater than the current time.
How can I get the ban creation and expiration time and show it to the player when he tries to log in?
Is it necessary to automatically log out the player after a ban is created?
Right now, I don't get the ban creation and expiration time in the log in result and my CloudScript is not executed when the player is banned:
Client code:
private void RegisterGuestPlayFabAccount() { PlayerDeviceId = ReturnMobileID(); var requestIOS = new LoginWithIOSDeviceIDRequest { DeviceId = PlayerDeviceId, CreateAccount = false }; var loginTask = PlayFabClientAPI.LoginWithIOSDeviceIDAsync(requestIOS); loginTask.ContinueWith(OnPlayFabRegisterGuestAccountComplete); } private void OnPlayFabRegisterGuestAccountComplete(Task<PlayFabResult<LoginResult>> task) { var newLabel = "Unknown failure"; if (task.Result.Result != null) { ... } if (task.Result.Error != null) { UserBans(); } } private async Task UserBans() { var result = await PlayFabClientAPI.ExecuteCloudScriptAsync(new ExecuteCloudScriptRequest() { FunctionName = "GetUserBans", GeneratePlayStreamEvent = true }); if (result.Error != null) Console.WriteLine(result.Error.Error.ToString()); else { if (result.Result.FunctionResult != null) Console.WriteLine(result.Result.FunctionResult); } }
CloudScript:
handlers.GetUserBans = function (args, context) { var result = GetUserBansFromCloudScript(currentPlayerId); var userbanned = ""; var currenttime = ""; if ((result != null) && (result.Error == null)) { result.BanData.forEach(element => { if ((element.Active == true) && (element.Expires >= currenttime)) return userbanned = element.Created.toString() + " " + element.Expires.toString() + " : " + element.Reason; else userbanned = "No active user bans found." }); } else userbanned = "Not possible to get user bans." return userbanned; } function GetUserBansFromCloudScript(PlayFabId) { var contentBodyTemp = { "PlayFabId": PlayFabId }; let url = "https://xxx.playfabapi.com/Admin/GetUserBans"; let method = "POST"; let contentBody = `{"PlayFabId": "${PlayFabId}"}`; let contentType = "application/json"; let headers = { "X-SecretKey": "..." }; let responseString = http.request(url, method, contentBody, contentType, headers); let responseJSONObj = JSON.parse(responseString); return (responseJSONObj); }