First of all, I am a beginner. Its my first system ever written. Every 10 seconds it validates the value and updates the virtual currency if the value is in an acceptable range. In the unity console it says "null" after the call is completed. If i refresh the virtual currency tab of the player it's still 200, the initial value.
CloudScript:
handlers.Validate = function(args, context) {
if(args && args.hasOwnProperty("inputValue")) {
var currentValue = args.inputValue;
if(currentValue <= 300) {
server.AddUserVirtualCurrency({ PlayFabId: currentPlayerID, VirtualCurrency: CA, Amount: currentValue });
var inventory = server.GetUserInventory({ PlayFabId: currentPlayerId });
var finalValue = inventory.VirtualCurrency.CA;
return { value: finalValue }; }
else return { messageValue: "Cheater Detected!" };
}
}
Unity:
void ValidateValues() {
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() {
FunctionName = "Validate", FunctionParameter = new { inputValue = Stats.currentCAAmount }, GeneratePlayStreamEvent = true }, result => Debug.Log(result.FunctionResult), error => Debug.Log(error.GenerateErrorReport())
);}