my code

Snippet options

Download: Download snippet as sell-via-dowhen-1.cpp.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<CustomBehavior File="RunCode" Type="Definition"><![CDATA[ 
    IEnumerable<WoWItem> GetExtraConsumables()
        uint foodCount = 0;
        uint drinkCount = 0;
        // Skip conjured and buff comsumables.
        var extraConsumables = (from item in Me.BagItems
		                            where item != null && item.ItemInfo != null
		                            let isFood = Consumable.IsFood(item.ItemInfo)
		                            let isDrink = Consumable.IsDrink(item.ItemInfo)
		                            where (isFood || isDrink) && item.ItemInfo.SellPrice > 0 && item.Effects.Count == 1 && item.ItemInfo.RequiredLevel < Me.Level - 10                    
		                            select item).ToList();
        var extraPotions = Me.BagItems
		                                  .Where(c => c != null && c.IsValid && c.ItemInfo != null && c.ItemInfo.SellPrice > 0 && c.Effects.Count == 1
		                                  && (c.ItemInfo.ConsumableClass == WoWItemConsumableClass.Potion
		                                  || c.ItemInfo.ConsumableClass == WoWItemConsumableClass.Elixir
		                                  || c.ItemInfo.ConsumableClass == WoWItemConsumableClass.Flask)
		                                  && c.ItemInfo.RequiredLevel < Me.Level - 20);
        return extraConsumables;
    async Task SellExtraConsumables()
        Logging.Write("Selling items in GetExtraConsumables()");
        foreach (var item in GetExtraConsumables())
            Logging.Write("Selling {0}.", item.Name);                       
            await Coroutine.Sleep(1337);
<CustomBehavior File="Hooks\DoWhen" AllowExecutionWhileNotAlive="false"  AllowUseWhileMounted="true" ActivityName="SellExtraConsumables" UseWhen="MerchantFrame.Instance.IsVisible &amp;&amp; GetExtraConsumables().Any()" >
    <CustomBehavior File="RunCode" Code="await SellExtraConsumables();"/>  

Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.