public InformHandler(Bot bot, string type) { this.bot = bot; switch (type) { case "ScrapbankUserHandler": this.botType = BotType.ScrapbankingBot; break; case "AdminUserHandler": this.botType = BotType.AdminBot; break; case "HatbankUserHandler": this.botType = BotType.HatbankingBot; break; case "KeybankHandler": this.botType = BotType.KeybankingBot; break; case "OneScrapUserHandler": default: this.botType = BotType.OneScrapBot; break; } this.schema = Schema.FetchSchema(bot.GetAPIKey()); }
//public void OnCraft(CraftResponceCallback responce) //{ // this.responce = responce; // CraftedItem = true; //} //private CraftResponceCallback Scrap(long item1, long item2) //{ // return Craft(ECraftingRecipie.SmeltClassWeapon, new long[] { item1, item2 }); //} //private CraftResponceCallback Craft(ECraftingRecipie recipie, long[] items) //{ // if (!InGame) // { // try // { // LaunchGame(); // Thread.Sleep(50); // while (!InGame) // { // Thread.Sleep(100); // } // } // catch (ThreadInterruptedException e) // { // bot.log.Error(e.StackTrace); // } // } // CraftedItem = false; // bot.SteamGameCoordinator.Craft(recipie, items); // Thread.Sleep(50); // while (!CraftedItem) // { // Thread.Sleep(100); // } // return responce; //} public void ScrapbankMethod() { if (bot.CurrentGame != 440) { LaunchGame(); Thread.Sleep(2000); } int loopcount = 0; Monitor.Enter(this.lck); while (loopcount < 1) { Inventory MyInventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey()); if (MyInventory == null) { bot.log.Error("Could not fetch own inventory via Steam API"); Monitor.PulseAll(this.lck); return; } List <ulong> scraps = new List <ulong>(); List <ulong> recs = new List <ulong>(); List <ulong> refs = new List <ulong>(); Dictionary <string, List <ulong> > weapons = new Dictionary <string, List <ulong> >(); //uShort = defindex ulong = id Schema schema = Schema.FetchSchema(bot.GetAPIKey()); #region Counting foreach (Inventory.Item item in MyInventory.Items) { Schema.Item schemaItem = schema.GetItem(item.Defindex); if (item.Defindex == 5000) { scraps.Add(item.Id); } else if (item.Defindex == 5001) { recs.Add(item.Id); } else if (item.Defindex == 5002) { refs.Add(item.Id); } else { if (schemaItem.CraftMaterialType == "weapon" && !item.IsNotCraftable && !item.IsNotTradeable) { if (!weapons.ContainsKey(schemaItem.UsableByClasses[0])) { weapons.Add(schemaItem.UsableByClasses[0], new List <ulong>()); } weapons[schemaItem.UsableByClasses[0]].Add(item.Id); } } } #endregion Counting #region Getting Craft Pairs List <string> Defindex = new List <string>(); List <CraftingPair> craftingpairs = new List <CraftingPair>(); ulong item1, item2; foreach (KeyValuePair <string, List <ulong> > pair in weapons) { item1 = 0; item2 = 0; Defindex.Clear(); foreach (ulong id in pair.Value) { Inventory.Item item = MyInventory.GetItem(id); Schema.Item schemaItem = schema.GetItem(item.Defindex); if (Defindex.Contains(schemaItem.ItemName) && !bot.dReserved.ContainsKey(item.Id)) { if (item1 == 0) { item1 = item.Id; } else if (item2 == 0) { item2 = item.Id; CraftingPair crPair = new CraftingPair(CraftingType.ScrapbankSmeltWeps); crPair.SetItem(item1); crPair.SetItem(item2); craftingpairs.Add(crPair); item1 = 0; item2 = 0; } } else { Defindex.Add(schemaItem.ItemName); } } } #endregion Getting Craft Pairs #region Crafting foreach (CraftingPair pair in craftingpairs) { Crafting.CraftItems(bot, pair.Item1, pair.Item2); Thread.Sleep(100); //CraftResponceCallback callback = Scrap((long)pair.Item1, (long)pair.Item2); //if (callback != null) //{ // foreach (long itemID in callback.GetItems()) // { // scraps.Add((ulong)itemID); // } // bot.log.Success("Item crafted into scrap!"); //} } while (refs.Count > 0) { Crafting.CraftItems(bot, refs[0]); Thread.Sleep(100); refs.RemoveAt(0); //CraftResponceCallback callback = Craft(ECraftingRecipie.Unknown, new long[] { (long)refs[0] }); //if (callback != null) //{ // refs.RemoveAt(0); // foreach (long itemID in callback.GetItems()) // { // recs.Add((ulong)itemID); // } // bot.log.Success("Refined smelted into reclaimed!"); //} } while (recs.Count > 0) { Crafting.CraftItems(bot, recs[0]); Thread.Sleep(100); recs.RemoveAt(0); //CraftResponceCallback callback = Craft(ECraftingRecipie.Unknown, new long[] { (long)recs[0] }); //if (callback != null) //{ // recs.RemoveAt(0); // foreach (long itemID in callback.GetItems()) // { // scraps.Add((ulong)itemID); // } // bot.log.Success("Reclaimed smelted into scrap!"); //} } #endregion Crafting loopcount++; } ExitGame(); Monitor.Exit(this.lck); bStarted = false; }
public void ScrapbankingMethod() { try { Thread.Sleep(5000); inventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey()); if (inventory == null) { inventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey()); if (inventory == null) { bStarted = false; return; } } foreach (Inventory.Item item in inventory.Items) { if (item.IsNotTradeable) { } else if (item.IsNotCraftable) { Blacklist += 0.5; } else if (item.Defindex == 5000) { ScrapMetal += 1; } else if (item.Defindex == 5001) { ReclaimedMetal += 1; } else if (item.Defindex == 5002) { RefinedMetal += 1; } else if (clsFunctions.WepBlackList.Contains(item.Defindex) || item.Quality != "6") { Blacklist += 0.5; } else if (schema.GetItem(item.Defindex).CraftMaterialType == "weapon") { Weapons += 0.5; } else { Unknown++; } } timeCounted = DateTime.Now; bCounted = true; BotTotal = ScrapMetal + (ReclaimedMetal * 3) + (RefinedMetal * 9) + Weapons + Blacklist; //if (BotTotal < clsFunctions.SCRAPBANK_INVENTORY_LEVEL) //{ // bot.SteamFriends.SendChatMessage(clsFunctions.BotsOwnerID, EChatEntryType.ChatMsg, "Problem! I have " + BotTotal + " when i should have " + clsFunctions.SCRAPBANK_INVENTORY_LEVEL + "!"); //} if (BotTotal > clsFunctions.SCRAPBANK_INVENTORY_LEVEL + 3) { bot.SteamFriends.SendChatMessage(clsFunctions.BotsOwnerID, EChatEntryType.ChatMsg, "Hey, I have extra items."); } if (Blacklist > 0) { bot.SteamFriends.SendChatMessage(clsFunctions.BotsOwnerID, EChatEntryType.ChatMsg, "Hey, I have " + (Blacklist / 0.5) + " blacklisted items."); } if (Unknown > 0) { bot.SteamFriends.SendChatMessage(clsFunctions.BotsOwnerID, EChatEntryType.ChatMsg, "Hey, I have " + Unknown + " unknown items."); } if (ReclaimedMetal > 0 || RefinedMetal > 0) { if (!bot.craftHandler.InGame && bot.CurrentTrade == null) { bot.craftHandler.Start(CraftingType.ScrapbankMetalToScrap); } //bot.SteamFriends.SendChatMessage(clsFunctions.BotsOwnerID, EChatEntryType.ChatMsg, "I have ref or rec!"); } else if (ScrapMetal < 20) //|| (QuarryRef > 0 || QuarryRec > 0)) { if (!bot.craftHandler.InGame && bot.CurrentTrade == null) { bot.craftHandler.Start(CraftingType.ScrapbankSmeltWeps); } } bStarted = false; } catch { bCounted = false; bStarted = false; } }