question

bruhalt9 avatar image
bruhalt9 asked

testing out ban but need help

so, i am using this famous ban script: (btw, using unity)

using UnityEngine; using PlayFab; public class trytogetbanreason : MonoBehaviour { public void OnLoginFailure(PlayFabError error) { if (error.Error == PlayFabErrorCode.AccountBanned) { foreach (var item in error.ErrorDetails) { Debug.Log("Reason : " + item.Key + "\t" + "Expires : " + item.Value[0]); } } } }

and i want it to show reason, and when it expires in hours not date, is it possible to make it so it displays as text and says something with the lines of "you have been banned for" + reason + "and ban expires in" + hours it may say it there but when i try that it will give me this error: Failed to log in: /Client/LoginWithCustomID: The IP making this request is currently banned

answes?

Player DatamultiplayerPlayer Inventory
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

·
Gosen Gao avatar image
Gosen Gao answered

I have done some tests, I put that code snippet in the error callback of login API, and it works. How does this code behave in your project? It doesn't print the expected text? Or is it reporting an error? You can share the full login code to us so we can have a look.

The error “Failed to log in: /Client/LoginWithCustomID: The IP making this request is currently banned” doesn’t seem to be generated by the code above. And according to the info, it is the expected behavior. As the account is banned, the login request will fail with an error, and the error details will contain the ban reason and expire time.

6 comments
10 |1200

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

bruhalt9 avatar image bruhalt9 commented ·

ill send you my login script + banning script but it does show the reason and date in debug log, i know how to make it so it works for text but unsure why it gives me the issue, here is the login + ban code5981-login-script.txt5980-ban-script.txt

0 Likes 0 ·
login-script.txt (2.7 KiB)
ban-script.txt (688 B)
Gosen Gao avatar image Gosen Gao bruhalt9 commented ·

I don’t find that code snippet in your login or ban script, put the code below in the OnError function could make it work.

 if (error.Error == PlayFabErrorCode.AccountBanned)
 {
     foreach (var item in error.ErrorDetails)
     {
         Debug.Log("Reason : " + item.Key + "\t" + "Expires : " + item.Value[0]);
     }
 }
0 Likes 0 ·
bruhalt9 avatar image bruhalt9 Gosen Gao commented ·

i will test this soon and reply if or if it does or doesnt work

0 Likes 0 ·
Show more comments

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.