I want to Get the players ECount data (Which stores the player's money. Example: 0.00005) from the server. Then increment it by 0.00001 (or 1/100000). I have loosely followed the example code from the docs here.
However when I run my script on Unity, there are no changes taking effect. I am new to Javascript and not sure if I am doing anything wrong here on the CloudScript side.
How can I Get the player data and increment it using CloudScript?
My current Javascript implementation in CloudScript:
function reward(args) { var playerData = server.GetUserInternalData({ PlayFabId: currentPlayerId, Keys: ["ECount"] }); var newECount = Number(playerData.Data["ECount"].Value) + (1/100000); var updateUserDataResult = server.UpdateUserInternalData({ PlayFabId: currentPlayerId, Data: { "ECount": NewECount.toString() } }); }
My current C# implementation in Unity:
public void Reward() { PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest { FunctionName = "reward" }, result => { Debug.Log("CloudScript call successful"); GetData(); //This external function retrieves the player data from PlayFab }, error => { Debug.Log("CloudScript call failed"); Debug.Log(error.GenerateErrorReport()); }); }
*I am getting the successful result callback in Unity editor, thus the function is definitely being called from the Client side.