question

Victor Nedelea avatar image
Victor Nedelea asked

How to merge Dedicated Server with PlayFab Services?

I followed some tutorials about using the PlayFab API in Unity and I've got some Leaderboards set up. But how can I still use the PlayFab services like Leaderboards/Player Details while still using a Unity Build based on Mirror as a Dedicated Server?

For example, this is the code to submit a Score to Leaderboard:

public void SendLeaderboard(int score)
{
    var request = new UpdatePlayerStatisticsRequest
    {
        Statistics = new System.Collections.Generic.List<StatisticUpdate>
        {
            new StatisticUpdate
            {
                StatisticName = "SpaceCount",
                Value = score
            }
        }
    };
    PlayFabClientAPI.UpdatePlayerStatistics(request, OnLeaderboardUpdate, OnError);
}

But I don't like the idea of having this code on the Client Build because no one stops Me(as a Client) to modify the build to:

new StatisticUpdate
{
    StatisticName = "SpaceCount",
    Value = (score*10000)
}

So, basically, I need to somehow merge the dedicated server build with the PlayFab Service. Is there a guide or some steps to work out a solution? Thanks.

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

·
Seth Du avatar image
Seth Du answered

We usually recommend denying all the statistic update API calls in the client to avoid abusive uses and cheating. Meanwhile in the server build, you can implement server API for players data update. When network connection is established between clients and server, the clients will continue to synchronize data to the server. Before the server update players’ data, it is necessary to have several verifications, checking the consistency and rationality of the data. We have an official Mirror sample for your reference -- MpsSamples/UnityMirror at master PlayFab/MpsSamples (github.com)

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.