question

MoonHeonYoung avatar image
MoonHeonYoung asked

ip ban players

var BanUsersRequest = {

"Bans" : [{

"PlayFabId" : currentPlayerId, "Reason" : args.reason}] };

server.BanUsers(BanUsersRequest);

Hi I am automatically banning the player with the above function:

(When cheating is found on the client)

When using this function, can IP also be banned??, just like Ban setting n the game manager?

In other words, when I run the Ban ServerApi, I don't know the client's ip address in the beginning.

so BanRequest.IPAddress is null (in above bracket)

i want to ban playerID and the player's recent ip address too.

(player's recent ip address that can only know in gamemanager)

What should I do?

Currently, after having Ban with server.BanUsers, i am manually applying the ip ban

in game manager

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

If you enable the [Store full user IP addresses] in the title settings, the player’s IP address would be contained in the login event -- player_logged_in. If you want to collect the IP addresses for banning players, you can store the IP address in the internal player data that can only be read and written by the server.

In your case, you can set a rule to use login events to trigger a CloudScript function to store the information. To learn more about PlayFab Rules, please check the document -- Actions& Rules quickstart - PlayFab | Microsoft Docs. The CloudScript function that triggered by events can access the events content by accessing the context parameter. Please check this document -- UsingCloudScript actions with PlayStream - PlayFab | Microsoft Docs to learn about how to retrieve the event’s field using CloudScript context. For example, the function could be something like this.

handlers.storeIPaddress = function (args, context) {

    var psEvent = context.playStreamEvent;
    var IPaddress = psEvent.IPV4Address;

    var request = {
        PlayFabId: currentPlayerId,
        Data: {
            "IPaddress": IPaddress
        }
    }
    var result = server.UpdateUserInternalData(request);

    return { result: result };
};

Then you can refer to this doc -- How to get internal player data - PlayFab | Microsoft Docs to get it in your server.

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.