Hi, I'm giving VC to a player based on vars like Catalogversion and itemId after another partner player consumes an item. This is the script that triggers the cloud server function and pass the args and is working fine.
private void ConsumeSuccess(ConsumeItemResult result) { //iteminstanceid = result.ItemInstanceId; Debug.Log("Starting Funcion on Server"); string clientid = PlayerPrefs.GetString("clientid"); string itemidmerchant = PlayerPrefs.GetString("itemid"); string catalogversionmerchant = PlayerPrefs.GetString("catalogversion"); Debug.Log("Rewarding VC to: " + clientid + ". The item: " + itemidmerchant + ". From catalog: " + catalogversionmerchant); PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "SendVcToplayer", GeneratePlayStreamEvent = true, FunctionParameter = new { Clientidtrader = clientid, Itemidtrader = itemidmerchant, Catalogversion = catalogversionmerchant }, }, cloudResult => { Debug.Log("Server script working fine"); }, cloudError => { Debug.Log("Something went wrong with the server side"); }); }
This is the debug log from Xcode. I can see that all params are ok:
"Rewarding VC to: BA9*********84B6. The item: win200free. From catalog: Torrons"
This is the CloudScript that triggers the VC to be sent to the player.
handlers.SendVcToplayer = function (args, context){ var clientidtrader = args.Clientidtrader; var itemidtrader = args.Itemidtrader; var catalogversion = args.Catalogversion; if (args.Catalogversion == "Torrons" && args.Itemidtrader == "web200free") { server.AddUserVirtualCurrency ({ Amount: "200", PlayFabId: clientidtrader, VirtualCurrency: "IB" }); return {messageValue: "200IB Granted to Client"}; } server.AddUserVirtualCurrency ({ Amount: "50", PlayFabId: clientidtrader, VirtualCurrency: "IB" }); return{messageValue: "This is not rewardable"}; }
The problem is that the "if" statement doesn't understand what is the catalog version and itemid so the Cloudscrip isn't giving the "200" VC to the player, only the "50" (that is given to every player that consumes an item, as a reward.
I also tried using the var:
if (catalogversion == "Torrons" && itemidtrader == "web200free")
and doesn't work as well.
What I'm doing wrong here? is it java coding related in the CloudScript?
Thank you.