Wondering if I could get some help trying to write some more flexible cloud script. I have a bunch of title KVPs that at startup I’d like to populate to each player’s data. Version A where I plug everything in manually works.
But I get errors trying the less verbose version B where I try to skip the temp variables and plug title data directly into player KVP.
I have a lot of these so ideally I’d be able to loop through and generate them on the fly. But bunch of errors with version C. Thoughts on ways I could use variables to generate KPS without plugging them in manually one by one? Thank you!
// VERSION A // works fine var allTitleData = server.GetTitleData({ }); var tempData00 = allTitleData.Data[“titleData00"]; var tempData01 = allTitleData.Data[“titleData01”]; var tempData01 = allTitleData.Data[“titleData02”]; var updateUserDataResult = server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Data: { playerData00: titleData00, playerData01: titleData01, playerData01: titleData02 } }); // VERSION B // errors var allTitleData = server.GetTitleData({ }); var updateUserDataResult = server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Data: { playerData00: allTitleData.Data[“titleData00"]; playerData01: allTitleData.Data[“titleData01”]; playerData01: allTitleData.Data[“titleData02”]; } }); // VERSION C // errors var allTitleData = server.GetTitleData({ }); var totalNumData = 10; var updateUserDataResult = server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Data: { // loop through and set all of our startup decks for(var i = 0; i < totalNumData; i++) { var twoDigitNum = i.ToString("D2"); var playerDataName = “playerData” + twoDigitNum; var titleDataName = “titleData” + twoDigitNum; playerDataName: titleDataName } } });