question

Ozan Yilmaz avatar image
Ozan Yilmaz asked

Can 2 rules cause conflict?

Hello everyone,

When a new player registers to our game, we want to adjust some things on the player's profile/data. I was wondering if 2 rules can cause a conflict?

These are the rules that I set:

- player_added_title. The purpose of this rule is that adding a statistic to the new player. So that I can track and remove fake accounts by using a segment. Here's the code:

    var initExperience = {
        "PlayFabId": currentPlayerId,
        "Statistics": [{ 
            "StatisticName": "Experience",
            "Value": 0
        }]
    };
    server.UpdatePlayerStatistics(initExperience);

- player_displayname_changed. The purpose of this rule is that checking if the player changed the display name once. If the player's experience statistic value doesn't exist or is equal to 0, that means the player is new and can change the display name. If not, then I ban the player. Here's the code:

    var getStatistic = {
        "PlayFabId": currentPlayerId,
        "StatisticNames": ["Experience"]
    };
    var getStatisticResult = server.GetPlayerStatistics(getStatistic);

    if(getStatisticResult.Statistics.length != 0 && getStatisticResult.Statistics[0].Value != 0) {
        // Ban player
    }

I have experienced before that starting times of rules (calling time) varies. We can't know when or which order the rules will be executed. In my code, one is updating a statistic and the other one is trying to read it. There's a possibility of running these 2 rules at the same time. My question is that can these rules cause a conflict in this order?

- Player logs in with Android device ID (since it's a new player, the API will create a new account)

- Player calls UpdateUserTitleDisplayName API to update their display name as soon as the account is created. (Basically, in the result callback of LoginWithAndroidDeviceID, the UpdateUserTitleDisplayName API is called).

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

·
Ivan Cai avatar image
Ivan Cai answered

To be safe, you can refer this thread to write the delay function yourself in the cloudscript function triggered by-player_displayname_changed. If in c#, you can directly use an IEnumerable on the callback of LoginWithAndroidDeviceID instead of a function and wait for seconds.

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.