question

Hunor Rusznak avatar image
Hunor Rusznak asked

Way to reduce calls

Hey, I'm making a script that will create account info for new players. It first creates two characters for the new player and then gets the ID's of the newly created characters. After that, it adds some data to each character like levels and XP. When it is ran, there are too many API calls. Is there any way I can reduce that?

handlers.newPlayerData = function () {
    var survivorCharacterResponse
    var hunterCharaterResponse
function givePlayerCharacter(callback){
    var survivorsetdata = {
     "PlayFabId": currentPlayerId,
    "CharacterName": "Survivor1",
    "CharacterType": "Survivor"
    };
    var huntersetdata = {
        "PlayFabId": currentPlayerId,
    "CharacterName": "Hunter1",
    "CharacterType": "Hunter"
    };
    survivorCharacterResponse = server.GrantCharacterToUser(survivorsetdata);
    hunterCharaterResponse = server.GrantCharacterToUser(huntersetdata);
    callback(survivorCharacterResponse,hunterCharaterResponse);
};


function setBasicStats(survivorCharacterResponse,hunterCharaterResponse){
    var playerSurvivorCharacterID = survivorCharacterResponse["CharacterId"];
    var playerHunterCharacterID = hunterCharaterResponse["CharacterId"];
    JSON.stringify(playerSurvivorCharacterID);
    JSON.stringify(playerHunterCharacterID);
    var survivorBasicStats = {
      "CharacterId": playerSurvivorCharacterID,
      "PlayFabId": currentPlayerId,
      "Data": {
          "Level": "0",
          "XP": "0"
      },
      "Permission": "Public"
    };
        var hunterBasicStats = {
      "CharacterId": playerHunterCharacterID,
      "PlayFabId": currentPlayerId,
      "Data": {
          "Level": "0",
          "XP": "0",
          "Kills": "0"
      },
      "Permission": "Public"
    };
    server.UpdateCharacterData(survivorBasicStats);
    server.UpdateCharacterData(hunterBasicStats);
};


    givePlayerCharacter(setBasicStats);
};


apisCloudScript
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

·
Hunor Rusznak avatar image
Hunor Rusznak answered

Figured out how to do it. Just had to split it into two scripts.

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.