question

hunelgames avatar image
hunelgames asked

How do I protect important data in the game

Hi,

In my game the players have abilities(for example : Strong and luck)

I'm saving these ability values =>

        PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
        {
            FunctionName = "UpdatePlayerStats",
            FunctionParameter = new {Strong= PlayerStrong, Luck= PlayerLuck},
            GeneratePlayStreamEvent = true,
        }, OnCloudUpdateStats, OnErrorShared);

I get these values when I need them with "GetPlayerStatistics".

    public void GetPlayerStats()
    {
        PlayFabClientAPI.GetPlayerStatistics(new GetPlayerStatisticsRequest(),OnGetStats,error => Debug.LogError(error.GenerateErrorReport()));
    }
    public void OnGetStats(GetPlayerStatisticsResult result)
    {
        foreach (var eachStat in result.Statistics)
        {
            switch (eachStat.StatisticName)
            {
                case "Player Strong":
                    PlayerStrong= eachStat.Value;
                    break;
                case "Player Luck":
                    PlayerLuck= eachStat.Value;
                    break;
            }
        }
    }

Strong and luck value is very important to game.

For this reason, malicious people should not reach these values.

Can malicious people reach their strong or luck values?

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

·
Rick Chen avatar image
Rick Chen answered

In general, the statistic value of a player is safe. Malicious people without a secret key cannot update their statistic value. Unless you allow them by ticking [Allow client to post player statistics] in [Game Manager] -> [Title Settings] -> [API Features].

In your code snippet 1, you wrote a CloudScript allowing players to update their statistics. If you allow players to update their statistics, part of them could be malicious, this is fine.

Rather than preventing malicious people to update their statistics, you could prevent them from cheating such as putting exaggerated numbers into their statistics. You could check the values and add some cheat detection logic on your CloudScript. You may refer to this thread: Guidance for cheat prevention for advice of cheat prevention.

If you have further questions, please feel free to ask.

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.