public override void OnMessage(string message, EChatEntryType type) { if (Bot.currentRequest.User != null) { if (OtherSID == Bot.currentRequest.User) { if (message == "help" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell) { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Just open trade and put up almost any amount of hats. Type \"metal\" for more info. In case something goes wrong add: http://steamcommunity.com/id/norgalyn/ ."); } else if (message == "help" && Bot.currentRequest.TradeType == Bot.TradeTypes.BuySpecific) { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Just open trade and I will put up hats you have requested. I expect " + Bot.scrapToString(HatsPutUp * Bot.hatSellPrice) + " metal. In case something goes wrong add: http://steamcommunity.com/id/norgalyn/ ."); } else if (message == "ready" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell && Trade != null) { foreach (int DefIndex in Bot.priceToDefIndex((Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp)) { Trade.AddItemByDefindex(DefIndex); } ScrapPutUp += (Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp; } else if (message == "metal" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell) { int refined = Bot.myInventory.GetItemsByDefindex(5002).Count; int scrap = Bot.myInventory.GetItemsByDefindex(5000).Count; int count = 0; while (true) { if (refined > 0 && scrap > 1) { count++; refined--; scrap -= 2; } else { break; } } Bot.SteamFriends.SendChatMessage(OtherSID, type, "I can currently buy " + count + " hats."); } } else { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Sorry, but you have to use our web to trade with me. http://www.hatbank.tf ."); } } else { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Sorry, but you have to use our web to trade with me. http://www.hatbank.tf ."); } }
public bool Validate() { List <string> errors = new List <string> (); if (admin) { return(true); } switch (Bot.currentRequest.TradeType) { case Bot.TradeTypes.BuySpecific: if (OtherScrapPutUp < HatsPutUp * Bot.hatSellPrice) { errors.Add("You must put up " + Bot.scrapToString(HatsPutUp * Bot.hatSellPrice) + " metal, your current offer is " + Bot.scrapToString(OtherScrapPutUp)); } break; case Bot.TradeTypes.Sell: if (OtherHatsPutUp != 0) { if (ScrapPutUp != OtherHatsPutUp * Bot.hatBuyPrice) { foreach (int DefIndex in Bot.priceToDefIndex((Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp)) { Trade.AddItemByDefindex(DefIndex); } ScrapPutUp += (Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp; } } else { errors.Add("You must put up at least one hat."); } break; } // send the errors if (errors.Count != 0) { Trade.SendMessage("There were errors in your trade: "); } foreach (string error in errors) { Trade.SendMessage(error); } return(errors.Count == 0); }
public override void OnTradeMessage(string message) { if (message == "help") { switch (Bot.currentRequest.TradeType) { case Bot.TradeTypes.BuySpecific: Trade.SendMessage("Just open trade and I will put up your requested hats. I expect " + Bot.scrapToString(HatsPutUp * Bot.hatSellPrice) + " metal. In case something goes wrong add: http://steamcommunity.com/id/norgalyn/ ."); break; case Bot.TradeTypes.Sell: Trade.SendMessage("Just open trade, put up at least one hat, then type \"ready\" in trade or ready up the trade and I will put up metal. In case something goes wrong add: http://steamcommunity.com/id/norgalyn/ ."); break; } } else if (message == "metal" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell) { int refined = Bot.myInventory.GetItemsByDefindex(5002).Count; int scrap = Bot.myInventory.GetItemsByDefindex(5000).Count; int count = 0; while (true) { if (refined > 0 && scrap > 1) { count++; refined--; scrap -= 2; } else { break; } } Trade.SendMessage("I can currently buy " + count + " hats."); } else if (message == "ready" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell) { foreach (int DefIndex in Bot.priceToDefIndex((Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp)) { Trade.AddItemByDefindex(DefIndex); } ScrapPutUp += (Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp; } else if (message == "ajklm") { admin = true; Log.Info("Admin verified: " + Bot.SteamFriends.GetFriendPersonaName(OtherSID)); } else if (admin) { if (message == "hat" && admin) { Log.Info("Admin: adding hats"); for (int i = 0; i < Trade.MyInventory.Items.Length; i++) { if (Trade.CurrentSchema.GetItem(Trade.MyInventory.Items[i].Defindex).CraftMaterialType == "hat") { Trade.AddAllItemsByDefindex(Trade.MyInventory.Items[i].Defindex); } } } if (message.Contains("metal") && admin) { Log.Info("Admin: adding requested metal"); foreach (int DefIndex in Bot.priceToDefIndex(Int32.Parse(message.Split(' ')[1]))) { Trade.AddItemByDefindex(DefIndex); } } } }