public override void OnTradeTimeout() { Bot.main.Invoke((Action)(() => { try { base.OnTradeClose(); } catch (Exception ex) { Bot.Print(ex); } foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages) { if ((SteamID)tab.Tag == OtherSID) { foreach (var item in tab.Controls) { Friends.chat.chatTab = (ChatTab)item; } } } Friends.chat.Invoke((Action)(() => { if (Friends.chat_opened) { Friends.chat.chatTab.TradeButtonMode(1); Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] The trade has closed.\r\n", false); } })); })); }
public override void OnTradeError(string error) { string name = Bot.SteamFriends.GetFriendPersonaName(OtherSID); Bot.main.Invoke((Action)(() => { try { base.OnTradeClose(); } catch (Exception ex) { Bot.Print(ex); } if (!Friends.chat_opened) { Friends.chat = new Chat(Bot); Friends.chat.AddChat(name, OtherSID); Friends.chat.Show(); Friends.chat_opened = true; Friends.chat.Flash(); Friends.chat.chatTab.TradeButtonMode(1); if (error.Contains("cancelled")) { Friends.chat.Invoke((Action)(() => { Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] The trade has been cancelled.\r\n", true); })); } else { Friends.chat.Invoke((Action)(() => { Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] Error: " + error + "\r\n", true); })); } } else { bool found = false; try { foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages) { if ((SteamID)tab.Tag == OtherSID) { foreach (var item in tab.Controls) { Friends.chat.chatTab = (ChatTab)item; } Friends.chat.ChatTabControl.SelectedTab = tab; Friends.chat.Show(); Friends.chat.Flash(); Friends.chat.chatTab.TradeButtonMode(1); if (error.Contains("cancelled")) { Friends.chat.Invoke((Action)(() => { Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] The trade has been cancelled.\r\n", true); })); } else { Friends.chat.Invoke((Action)(() => { Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] Error: " + error, true); })); } found = true; } } if (!found) { Friends.chat.AddChat(name, OtherSID); Friends.chat.Show(); Friends.chat.Flash(); Friends.chat.chatTab.TradeButtonMode(1); if (error.Contains("cancelled")) { Friends.chat.Invoke((Action)(() => { Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] The trade has been cancelled.\r\n", true); })); } else { Friends.chat.Invoke((Action)(() => { Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] Error: " + error + "\r\n", true); })); } } } catch (Exception ex) { Console.WriteLine(ex); } } })); }
public void TradeCountInventory() { Bot.main.Invoke((Action)(() => { ShowTrade = new ShowTrade(Bot, Bot.SteamFriends.GetFriendPersonaName(OtherSID)); ShowTrade.Show(); ShowTrade.Activate(); })); BackpackTF.CurrentSchema = BackpackTF.FetchSchema(); // Let's count our inventory Thread loadInventory = new Thread(() => { Console.WriteLine("Trade window opened."); Console.WriteLine("Loading all inventory items."); if (Bot.CurrentTrade == null) { return; } Inventory.Item[] inventory = Trade.MyInventory.Items; foreach (Inventory.Item item in inventory) { if (!item.IsNotTradeable) { var currentItem = Trade.CurrentSchema.GetItem(item.Defindex); string name = ""; string itemValue = ""; var type = Convert.ToInt32(item.Quality.ToString()); if (QualityToName(type) != "Unique") { name += QualityToName(type) + " "; } name += currentItem.ItemName; if (QualityToName(type) == "Unusual") { try { for (int count = 0; count < item.Attributes.Length; count++) { if (item.Attributes[count].Defindex == 134) { name += " (Effect: " + EffectToName(item.Attributes[count].FloatValue) + ")"; } } } catch (Exception) { } } if (currentItem.CraftMaterialType == "supply_crate") { for (int count = 0; count < item.Attributes.Length; count++) { name += " #" + (item.Attributes[count].FloatValue); if (item.Attributes[count].Defindex == 186) { name += " (Gifted)"; } } } name += " (Level " + item.Level + ")"; try { int size = item.Attributes.Length; for (int count = 0; count < size; count++) { if (item.Attributes[count].Defindex == 261) { string paint = ShowBackpack.PaintToName(item.Attributes[count].FloatValue); name += " (Painted: " + paint + ")"; } if (item.Attributes[count].Defindex == 186) { name += " (Gifted)"; } } } catch { // Item has no attributes... or something. } if (item.IsNotCraftable) { name += " (Uncraftable)"; } if (currentItem.Name == "Wrapped Gift") { // Untested! try { var containedItem = Trade.CurrentSchema.GetItem(item.ContainedItem.Defindex); var containedName = GetItemName(containedItem, item.ContainedItem, out itemValue); name += " (Contains: " + containedName + ")"; } catch (Exception ex) { Bot.Print(ex); // Guess this doesn't work :P. } } string price = Util.GetPrice(item.Defindex, currentItem.ItemQuality, item); ListInventory.Add(name, item.Id, currentItem.ImageURL, price); } } try { ShowTrade.loading = false; Bot.main.Invoke((Action)(() => ShowTrade.list_inventory.SetObjects(ListInventory.Get()))); } catch { } }); loadInventory.Start(); }