Jump to content

Recommended Posts

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);
				}
			}
		}
	}

 

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 by reapler

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...