I want to change and evenutally create (if it doesn't exist) an item instance custom data. I didnt found much except for this: UpdateUserInventoryItemCustomData but since i'm quite new at using CloudScript I don't really know how to make a function that given and ItemInstanceId, the name of the parameter and its value is able to update it.
Here I have this function that tries to move an item to a different kind of inventory (Player inventory, vehicle inventory etc..)
public void MoveItemToInventory(string _itemInstanceId, InventoryId _inventoryId) { string playfabId = ""; GetAccountInfoRequest request1 = new GetAccountInfoRequest(); PlayFabClientAPI.GetAccountInfo(request1, result => { playfabId = result.AccountInfo.PlayFabId; }, OnError); var request = new ExecuteCloudScriptRequest { FunctionName = "UpdateItemInstanceCustomData", FunctionParameter = new { PlayFabId = playfabId, ItemInstance = _itemInstanceId, NewValue = ((int)_inventoryId).ToString(), ToUpgrade = "InventoryId" }, }; PlayFabClientAPI.ExecuteCloudScript(request, result => { Debug.LogError(result.FunctionResult); }, OnError); }
This should call this function on the Cloud similar to one I found in an old question
handlers.UpdateItemInstanceCustomData = function (args) { var itemInstance = args.ItemInstance; var newValue = args.NewValue; var playfabId = args.PlayFabId; var dataPayload = {}; var keyString = args.ToUpgrade //"SlotNumber"; dataPayload[keyString] = newValue; var itemCustomData = server.UpdateUserInventoryItemCustomData( { PlayFabId : playfabId, ItemInstanceId : itemInstance, Data : dataPayload }); return("Updated"); }
So far, I'm just getting Null as a result of the ExecuteCloudScript call and no updates