Jump to content

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

 

Link to comment
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);
                }
            }
        }
    }
}

 

Link to comment
Share on other sites

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...