So i am trying to change an character's item's custom data called Slot Number. I added a new server version with this function in it:
handlers.GetSlotNumber = function (args)
{
var charaId = args.CharaId;
var itemInstance = args.ItemInstance;
var slotNumber = args.SlotNumber;
var playfabId = args.playFabId;
var itemCustomData = server.UpdateUserInventoryItemCustomData(
{
CharacterId : charaId,
PlayFabId : playfabId,
ItemInstanceId : itemInstance,
Data : slotNumber
});
return("Updated");
}
In unity I am running this code and returning i to the item's variable. My question is when I do this I get an error.
int GetSlotNumber(int v)
{
int i = -1;
Dictionary<string, string> slotChange = new Dictionary<string, string>()
{
{"playFabId", player.playFabID},
{"CharaId", player.playerID},
{"ItemInstance", instanceId},
{"SlotNumber", v.ToString()}
};
RunCloudScriptRequest request = new RunCloudScriptRequest()
{
ActionId = "GetSlotNumber",
Params = new { data = slotChange }
};
PlayFabClientAPI.RunCloudScript(request,(
result) =>
{
Debug.Log("Success!");
i = v;
},
(error) =>
{
Debug.Log ("Error: " + error.Error);
Debug.Log ("Error Message: " + error.ErrorMessage);
});
return i;
}
This is the error message I am getting:
Error Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object