Beispiel #1
0
        public void loadXml()
        {
            XElement xml = XElement.Parse(File.ReadAllText(@"scripts\multisell.xml"));
            XElement ex  = xml.Element("list");

            foreach (var m in ex.Elements())
            {
                if (m.Name == "multisell")
                {
                    MultiSellList mlist = new MultiSellList();
                    mlist.id    = Convert.ToInt32(m.Attribute("id").Value);
                    mlist.dutyf = Convert.ToByte(m.Attribute("dutyf").Value);
                    mlist.save  = Convert.ToByte(m.Attribute("save").Value);
                    mlist.all   = Convert.ToByte(m.Attribute("all").Value);

                    foreach (var stp in m.Elements())
                    {
                        if (stp.Name == "entry")
                        {
                            MultiSellEntry entry = new MultiSellEntry();
                            foreach (var its in stp.Elements())
                            {
                                switch (its.Name.LocalName)
                                {
                                case "give":
                                {
                                    MultiSellItem item = new MultiSellItem();
                                    item.id    = Convert.ToInt32(its.Attribute("id").Value);
                                    item.count = Convert.ToInt64(its.Attribute("count").Value);
                                    if (item.id > 0)
                                    {
                                        item.template = ItemTable.getInstance().getItem(item.id);
                                        if (!item.template.isStackable())
                                        {
                                            entry.Stackable = 0;
                                        }
                                    }
                                    entry.give.Add(item);
                                }
                                break;

                                case "take":
                                {
                                    MultiSellItem item = new MultiSellItem();
                                    item.id    = Convert.ToInt32(its.Attribute("id").Value);
                                    item.count = Convert.ToInt64(its.Attribute("count").Value);
                                    if (item.id > 0)
                                    {
                                        item.template = ItemTable.getInstance().getItem(item.id);
                                    }
                                    entry.take.Add(item);
                                }
                                break;

                                case "duty":
                                    entry.dutyCount = Convert.ToInt64(its.Attribute("count").Value);
                                    break;
                                }
                            }

                            mlist.container.Add(entry);
                        }
                    }

                    lists.Add(mlist.id, mlist);
                }
            }

            CLogger.info("MultiSell: " + lists.Count + " lists");
        }
Beispiel #2
0
        public void showList(L2Player player, L2Citizen npc, int listId)
        {
            if (!lists.ContainsKey(listId))
            {
                player.sendMessage("Multsell list #" + listId + " was not found");
                player.sendActionFailed();
                return;
            }

            MultiSellList list = lists[listId];

            player.LastRequestedMultiSellId = listId;

            if (list.all == 1)
            {
                player.sendPacket(new MultiSellListEx(player, list));
                if (player.CustomMultiSellList != null)
                {
                    player.CustomMultiSellList = null;
                }
            }
            else
            {
                MultiSellList newlist = new MultiSellList();
                newlist.id = list.id;
                L2Item[] pitems = player.getAllWeaponArmorNonQuestItems();
                foreach (MultiSellEntry entry in list.container)
                {
                    MultiSellItem msitem = entry.take[0];

                    if (msitem.template == null)
                    {
                        continue;
                    }

                    foreach (L2Item item in pitems)
                    {
                        if (item._isEquipped == 1)
                        {
                            continue;
                        }

                        if (item.Template.ItemID == msitem.id)
                        {
                            MultiSellEntry edentry = new MultiSellEntry();
                            edentry.take.AddRange(entry.take);
                            edentry.give.AddRange(entry.give);

                            edentry.take[0].l2item = item;
                            edentry.give[0].l2item = item;

                            newlist.container.Add(edentry);
                        }
                    }
                }

                MultiSellListEx mlist = new MultiSellListEx(player, newlist);
                player.CustomMultiSellList = newlist;
                player.sendPacket(mlist);
            }
        }