Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

TheSmokie

Boolen, string Dictionary array

Recommended Posts

I am trying to redo my PvPtools with adding custom states but i am having a little problem with buying item via string , boolen.

i am trying to use my settings bool to buy the item if the settings is true. but i am not understanding how to get it to buy the item while using a boolen. 

 

error : parameter 'number' of 'Vendor.BuyItem(string, int)', i understand i need a string + int amount but how do i get it to check before buying using boolen?

 

public static class AllianceGems
    {

        private static Dictionary<string, bool> Mains = new Dictionary<string, bool>
        {
            { "Majestic Zircon", true},
        };

        public static void BuyingGems()
        {
            foreach (var item in Mains)
            {
                Vendor.BuyItem(item);
            }
        }
    }

 

Share this post


Link to post
Share on other sites

Hi,

public static class AllianceGems
{

    private static Dictionary<string, bool> Mains = new Dictionary<string, bool>
    {
        { "Majestic Zircon", true},
    };

    public static void BuyingGems()
    {
        foreach (var item in Mains)
        {
            if (item.Value)
                Vendor.BuyItem(item.Key, 20);
        }
    }
}

If you want use list with ammount to buy:

using System;
using System.Collections.Generic;
using wManager.Wow.Helpers;

public static class AllianceGems
{
    private static List<System.Tuple<bool, string, int>> Mains = new List<System.Tuple<bool, string, int>>
    {
        //                       BuyOrNot, ItemName      , BuyNumber
        new Tuple<bool, string, int>(true, "Majestic Zircon", 20),
    };

    public static void BuyingGems()
    {
        foreach (var item in Mains)
        {
            if (item.Item1)
                Vendor.BuyItem(item.Item2, item.Item3);
        }
    }
}

Final code look like:

using System.Collections.Generic;
using robotManager.Helpful;
using wManager.Wow.Helpers;
using Buy = System.Tuple<bool, string, int>;

public static class AllianceGems
{
    private static List<Buy> Mains = new List<Buy>
    {
        //    Item1,    Item2         , Item3
        //    BuyOrNot, ItemName      , BuyNumber
        new Buy(true, "Majestic Zircon", 20),
    };

    public static void BuyingGems()
    {
        foreach (var item in Mains)
        {
            if (item.Item1)
            {
                var currentCount = ItemsManager.GetItemCountByNameLUA(item.Item2);
                if (currentCount < item.Item3)
                {
                    Logging.Write("Buy " + item.Item2);
                    Vendor.BuyItem(item.Item2, item.Item3 - currentCount);
                }
            }
        }
    }
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...