Paultimate 2 Posted November 8, 2018 Share Posted November 8, 2018 So from a great plugin called Butler Im trying to add a bit more functionality to what is trashes. Id like to include a safelist by item ID. The below code is what I have so far. Obviously item.GetItemInfo.ItemID==12345 isnt valid, but I think its clear what Im trying to do. If itemID of 12345 is found on the safelist, then do not continue onto destruction. Even if I can get a clue as to how to fill in a single item here, I can create an array later to fill in other IDs. private void PulseDestroy() { if (ButlerSettings.CurrentSetting.DestroyGray) { foreach (WoWItem item in bagItems) { if (item.GetItemInfo.ItemRarity==0 || item.GetItemInfo.ItemRarity==1 && !item.GetItemInfo.ItemID==12345) { while (ObjectManager.Me.InCombat || ObjectManager.Me.IsDead) {Thread.Sleep(shortDelay);} List<int> BagAndSlot=Bag.GetItemContainerBagIdAndSlot(item.Entry); Logging.Write(ButlerPrefix+"destroying \""+item.GetItemInfo.ItemName+"\""); Lua.LuaDoString(string.Format("PickupContainerItem({0}, {1}); DeleteCursorItem()",(object) BagAndSlot[0],(object) BagAndSlot[1]),false); Thread.Sleep(shortDelay); } } } } Link to comment https://wrobot.eu/forums/topic/10364-include-safe-list-by-id-in-cs-foreach-iteration/ Share on other sites More sharing options...
reapler 154 Posted November 13, 2018 Share Posted November 13, 2018 (edited) Hello you can use a hashset for this purpose like this: private HashSet<int> safeList = new HashSet<int> { 12345, 12346, } private void ProtectItem(WoWItem item) { safeList.Add(item.GetItemInfo.ItemId); } private void ProtectItem(int itemId) { safeList.Add(itemId); } private void PulseDestroy() { if (ButlerSettings.CurrentSetting.DestroyGray) { foreach (WoWItem item in bagItems) { if ((item.GetItemInfo.ItemRarity==0 || item.GetItemInfo.ItemRarity==1) && !safeList.Contains(item.GetItemInfo.ItemId)) { while (ObjectManager.Me.InCombat || ObjectManager.Me.IsDead) { Thread.Sleep(shortDelay); } List<int> BagAndSlot=Bag.GetItemContainerBagIdAndSlot(item.Entry); Logging.Write(ButlerPrefix+"destroying \""+item.GetItemInfo.ItemName+"\""); Lua.LuaDoString(string.Format("PickupContainerItem({0}, {1}); DeleteCursorItem()", (object) BagAndSlot[0],(object) BagAndSlot[1]),false); Thread.Sleep(shortDelay); } } } } Edited November 13, 2018 by reapler Link to comment https://wrobot.eu/forums/topic/10364-include-safe-list-by-id-in-cs-foreach-iteration/#findComment-49278 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now