Im trying to make it so that players can gift items to other players. It seems very simple, but it does not work no matter what I do. I keep getting a trade timeout error. Is it because my item has a lot of custom data in it?
I log the trade ids, and I know that the correct trade is being accepted and everything. But the trade is givining a timeout error anyway.
Anyway, here is my code:
//Gives the item to a friend and the trade id is stored in the shared group data for the friend public void GiveItemToFriend(string friendID, ItemInstance item, System.Action<string> onError, System.Action onResolution) { if(_friendStartedTradeIds.ContainsKey(friendID)) { onError("The player hasn't accepted the previous sword you gave him yet!"); return; } if(item.CustomData.ContainsKey("Player Gifted")) { onError("You can't regift a sword!"); return; } PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() {FunctionName = "TooManyItems", FunctionParameter = new {ID = friendID}}, (res) => { PlayFabUtiltyMethods.PrintExecuteScriptError(res); if(res.FunctionResult.ToString() == "True") { onError("Your friend already has too many items!"); } else { OpenTradeRequest open = new OpenTradeRequest() { OfferedInventoryInstanceIds = new List<string>() {item.ItemInstanceId}, AllowedPlayerIds = new List<string>{friendID} }; PlayFabClientAPI.OpenTrade(open, (oRes) => { Debug.Log("Trade id is: " + oRes.Trade.TradeId); UpdateGroupWithTradeID(oRes.Trade.TradeId, friendID, onResolution); }, (err) => { Debug.LogError(err.ErrorMessage); onError("Error: " + err.ErrorMessage); }); } }, (err) => { Debug.LogError(err.ErrorMessage); onError("Error: " + err.ErrorMessage); }); } //Copde to update the group trade id data void UpdateGroupWithTradeID(string tradeID, string friendID, System.Action OnDone) { UpdateSharedGroupDataRequest uSG = new UpdateSharedGroupDataRequest() { SharedGroupId = friendID, Data = new Dictionary<string, string>() { {LogInManager.PlayFabID + " Trade", tradeID}}, Permission = UserDataPermission.Public }; PlayFabClientAPI.UpdateSharedGroupData(uSG, (res) => {OnDone(); }, (error) => {Debug.LogError(error.ErrorMessage);}); } //Accept item from player (gives a timeout error) public void AcceptItemFromFriend(string friendID, System.Action onAccepted, System.Action<string> onError) { Debug.Log("Trade id: " + _friendStartedTradeIds[friendID]); AcceptTradeRequest accept = new AcceptTradeRequest() { OfferingPlayerId = friendID, TradeId = _friendStartedTradeIds[friendID] }; PlayFabClientAPI.AcceptTrade(accept, (res) => { ExecuteCloudScriptRequest tradeA = new ExecuteCloudScriptRequest() { FunctionName = "AcceptedSwordFromPlayer", FunctionParameter = new { FriendID = friendID, SwordID = res.Trade.AcceptedInventoryInstanceIds[0] } }; PlayFabClientAPI.ExecuteCloudScript(tradeA, (sRes) => { PlayFabUtiltyMethods.PrintExecuteScriptError(sRes); RemoveTradeIds(friendID, _friendStartedTradeIds[friendID]); onAccepted(); }, (error) => { Debug.LogError(error.ErrorMessage); onError(error.ErrorMessage); }); }, (err) => { Debug.LogError("Error: " + err.ErrorMessage); onError(err.ErrorMessage); }); }, () => { onError("You have too many swords right now! Sell some to accept this sword!"); }