public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem) { Bot.main.Invoke((Action)(() => { string itemValue = ""; string completeName = GetItemName(schemaItem, inventoryItem, out itemValue, false); ulong itemID = inventoryItem.Id; //string itemValue = Util.GetPrice(schemaItem.Defindex, schemaItem.ItemQuality, inventoryItem); double value = 0; if (itemValue.Contains("ref")) { string newValue = ShowTrade.ReplaceLastOccurrence(itemValue, "ref", ""); value = Convert.ToDouble(newValue); } else if (itemValue.Contains("key")) { string newValue = ShowTrade.ReplaceLastOccurrence(itemValue, "keys", ""); value = Convert.ToDouble(newValue); value = value * BackpackTF.KeyPrice; } else if (itemValue.Contains("bud")) { string newValue = ShowTrade.ReplaceLastOccurrence(itemValue, "buds", ""); value = Convert.ToDouble(newValue); value = value * BackpackTF.BudPrice; } ShowTrade.OtherTotalValue += value; if (ShowTrade.OtherTotalValue >= BackpackTF.BudPrice * 1.33) { double formatPrice = ShowTrade.OtherTotalValue / BackpackTF.BudPrice; string label = "Total Value: " + formatPrice.ToString("0.00") + " buds"; ShowTrade.UpdateLabel(label); } else if (ShowTrade.OtherTotalValue >= BackpackTF.KeyPrice) { double formatPrice = ShowTrade.OtherTotalValue / BackpackTF.KeyPrice; string label = "Total Value: " + formatPrice.ToString("0.00") + " keys"; ShowTrade.UpdateLabel(label); } else { double formatPrice = ShowTrade.OtherTotalValue; string label = "Total Value: " + formatPrice.ToString("0.00") + " ref"; ShowTrade.UpdateLabel(label); } ListOtherOfferings.Add(completeName, itemID, itemValue); ShowTrade.list_otherofferings.SetObjects(ListOtherOfferings.Get()); ShowTrade.itemsAdded++; if (ShowTrade.itemsAdded > 0) { ShowTrade.check_userready.Enabled = true; } string itemName = GetItemName(schemaItem, inventoryItem, out itemValue, false); ShowTrade.AppendText(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " added: ", itemName); ChatTab.AppendLog(OtherSID, "[Trade Chat] " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " added: " + itemName + "\r\n"); ShowTrade.ResetTradeStatus(); })); }
public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem) { Debug.WriteLine("New item added: ID: {0} | DefIndex: {1}", inventoryItem.Id, inventoryItem.Defindex); Bot.main.Invoke((Action)(() => { string itemValue = ""; string completeName = GetItemName(schemaItem, inventoryItem, out itemValue, false); ulong itemID = inventoryItem.Id; ListOtherOfferings.Add(completeName, itemID, itemValue, inventoryItem); ShowTrade.list_otherofferings.SetObjects(ListOtherOfferings.Get()); ShowTrade.itemsAdded++; if (ShowTrade.itemsAdded > 0) { ShowTrade.check_userready.Enabled = true; } string itemName = GetItemName(schemaItem, inventoryItem, out itemValue, false); ShowTrade.AppendText(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " added: ", itemName); var count = ListOtherOfferings.Get().Count(x => x.Item.Defindex == inventoryItem.Defindex); ShowTrade.AppendText(string.Format("Current count of {0}: {1}", schemaItem.ItemName, count)); ChatTab.AppendLog(OtherSID, "[Trade Chat] " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " added: " + itemName + "\r\n"); ShowTrade.ResetTradeStatus(); })); }