Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            TraderBot.SpamMsg[_c] = textBox1.Text;

            TraderBot.Selling[_c] = new List <ItemStruct>();
            TraderBot.Buying[_c]  = new List <ItemStruct>();

            foreach (ListViewItem lvi in listView1.Items)
            {
                ItemStruct tmp = new ItemStruct(lvi.SubItems[1].Text, Int32.Parse(lvi.Text));
                TraderBot.Selling[_c].Add(tmp);
            }

            foreach (ListViewItem lvi in listView2.Items)
            {
                if (lvi.SubItems.Count > 3)
                {
                    ItemStruct tmp = new ItemStruct(lvi.SubItems[1].Text, Int32.Parse(lvi.Text), lvi.SubItems[3].Text, Int32.Parse(lvi.SubItems[2].Text));
                    TraderBot.Buying[_c].Add(tmp);
                }
                else
                {
                    ItemStruct tmp = new ItemStruct(lvi.SubItems[1].Text, Int32.Parse(lvi.Text));
                    TraderBot.Buying[_c].Add(tmp);
                }
            }

            this.Close();

            _c.SendToClient(PluginUtils.CreateNotification(_c.ObjectId, "TraderBot Settings Saved!"));
        }
Esempio n. 2
0
        public void SelectItems()
        {
            int x = 0;
            // Check if they selected all the items we are buying and if they did 2x or 3x or 4x
            List <ItemStruct> tmpYList = MasterBuying.Select(itemb => new ItemStruct(itemb.Name, itemb.Qty, itemb.Alt, itemb.AltQty)).ToList();

            for (int j = 4; j < YourItems.Count; j++)
            {
                if (YourItems[j].selected)
                {
                    for (int i = 0; i < tmpYList.Count; i++)
                    {
                        if (tmpYList[i].Name == YourItems[j].GetName())
                        {
                            if (tmpYList[i].Qty > 0)
                            {
                                tmpYList[i].Qty--;
                            }
                            break;
                        }
                        else if (tmpYList[i].Alt == YourItems[j].GetName())
                        {
                            if (tmpYList[i].AltQty > 0)
                            {
                                tmpYList[i].AltQty--;
                            }
                            break;
                        }
                    }
                }
                bool all = true;
                for (int i = 0; i < tmpYList.Count; i++)
                {
                    if (tmpYList[i].Qty > 0)
                    {
                        if (tmpYList[i].AltQty == -1)
                        {
                            all = false;
                        }
                        else
                        {
                            if (tmpYList[i].AltQty > 0)
                            {
                                all = false;
                            }
                        }
                    }
                }
                if (all)
                {
                    x++;
                    for (int i = 0; i < tmpYList.Count; i++)
                    {
                        if (tmpYList[i].Qty == 0)
                        {
                            tmpYList[i] = new ItemStruct(MasterBuying[i].Name, MasterBuying[i].Qty, MasterBuying[i].Alt, tmpYList[i].AltQty);
                        }
                        else if (tmpYList[i].AltQty == 0)
                        {
                            tmpYList[i] = new ItemStruct(MasterBuying[i].Name, tmpYList[i].Qty, MasterBuying[i].Alt, MasterBuying[i].AltQty);
                        }
                    }
                    //tmpYList = MasterBuying.Select(itemb => new ItemStruct(itemb.Name, itemb.Qty, itemb.Alt, itemb.AltQty)).ToList();
                }
            }

            // Clear all the selected items from our list
            for (int j = 4; j < MyItems.Count; j++)
            {
                MyItems[j].selected = false;
            }

            // Select all the items we are trading
            List <ItemStruct> tmpMList = MasterSelling.Select(itemb => new ItemStruct(itemb.Name, itemb.Qty)).ToList();

            // Change the quantity to match the multiplier
            for (int i = 0; i < tmpMList.Count; i++)
            {
                tmpMList[i].Qty *= x;
            }

            for (int j = 4; j < MyItems.Count; j++)
            {
                if (!MyItems[j].selected)
                {
                    for (int i = 0; i < tmpMList.Count; i++)
                    {
                        if (tmpMList[i].Name == MyItems[j].GetName())
                        {
                            if (tmpMList[i].Qty > 0)
                            {
                                tmpMList[i].Qty--;
                                MyItems[j].selected = true;
                            }
                            break;
                        }
                    }
                }
            }



            bool[] offer = new bool[12];
            for (int i = 0; i < 12; i++)
            {
                if (MyItems[i].selected)
                {
                    offer[i] = true;
                }
                else
                {
                    offer[i] = false;
                }
            }

            //Console.WriteLine(_c.PlayerData.Name + " Sending ChangeTrade");
            // Send the change
            ChangeTradePacket ctp = (ChangeTradePacket)Packet.Create(PacketType.CHANGETRADE);

            ctp.Offers = offer;
            _c.SendToServer(ctp);
        }
Esempio n. 3
0
        public bool Good()
        {
            int x = 0;
            // Check if they selected all the items we are buying and if they did 2x or 3x or 4x
            List <ItemStruct> tmpYList = MasterBuying.Select(itemb => new ItemStruct(itemb.Name, itemb.Qty, itemb.Alt, itemb.AltQty)).ToList();

            foreach (var item in YourItems)
            {
                if (item.selected)
                {
                    for (int i = 0; i < tmpYList.Count; i++)
                    {
                        if (tmpYList[i].Name == item.GetName())
                        {
                            if (tmpYList[i].Qty > 0)
                            {
                                tmpYList[i].Qty--;
                            }
                            break;
                        }
                        else if (tmpYList[i].Alt == item.GetName())
                        {
                            if (tmpYList[i].AltQty > 0)
                            {
                                tmpYList[i].AltQty--;
                            }
                            break;
                        }
                    }
                }
                bool all = true;
                for (int i = 0; i < tmpYList.Count; i++)
                {
                    if (tmpYList[i].Qty > 0)
                    {
                        if (tmpYList[i].AltQty == -1)
                        {
                            all = false;
                        }
                        else
                        {
                            if (tmpYList[i].AltQty > 0)
                            {
                                all = false;
                            }
                        }
                    }
                }
                if (all)
                {
                    x++;
                    // Reset the Qty of whichever one just hit 0
                    for (int i = 0; i < tmpYList.Count; i++)
                    {
                        if (tmpYList[i].Qty == 0)
                        {
                            tmpYList[i] = new ItemStruct(MasterBuying[i].Name, MasterBuying[i].Qty, MasterBuying[i].Alt, tmpYList[i].AltQty);
                        }
                        else if (tmpYList[i].AltQty == 0)
                        {
                            tmpYList[i] = new ItemStruct(MasterBuying[i].Name, tmpYList[i].Qty, MasterBuying[i].Alt, MasterBuying[i].AltQty);
                        }
                    }
                    //tmpYList = MasterBuying.Select(itemb => new ItemStruct(itemb.Name, itemb.Qty, itemb.Alt, itemb.AltQty)).ToList();
                }
            }

            if (x == 0)
            {
                return(false);
            }


            bool changes = false;

            List <ItemStruct> tmpMList = MasterSelling.Select(itemb => new ItemStruct(itemb.Name, itemb.Qty)).ToList();

            // Change the quantity to match the multiplier
            for (int i = 0; i < tmpMList.Count; i++)
            {
                tmpMList[i].Qty *= x;
            }
            // Check if we selected the right number of items
            foreach (var item in MyItems)
            {
                if (item.selected)
                {
                    bool found = false;
                    for (int i = 0; i < tmpMList.Count; i++)
                    {
                        if (tmpMList[i].Name == item.GetName())
                        {
                            if (tmpMList[i].Qty > 0)
                            {
                                found = true;
                                tmpMList[i].Qty--;
                            }
                            break;
                        }
                    }
                    if (!found)
                    {
                        // This item shouldnt of been selected?
                        item.selected = false;
                        changes       = true;
                    }
                }
            }

            if (changes)
            {
                bool[] offer = new bool[12];
                for (int i = 0; i < 12; i++)
                {
                    if (MyItems[i].selected)
                    {
                        offer[i] = true;
                    }
                    else
                    {
                        offer[i] = false;
                    }
                }

                //Console.WriteLine(_c.PlayerData.Name + " Sending ChangeTrade");
                // Send the change
                ChangeTradePacket ctp = (ChangeTradePacket)Packet.Create(PacketType.CHANGETRADE);
                ctp.Offers = offer;
                _c.SendToServer(ctp);

                return(false);
            }

            return(true);
        }