public void buylist(L2Player player, L2Citizen trader, short reply) { if (!_shops.ContainsKey(trader.Template.NpcId)) { player.sendMessage("you shop was not found"); player.sendActionFailed(); return; } ND_shop shop = _shops[trader.Template.NpcId]; GameServerNetworkPacket pk; if (!shop.lists.ContainsKey(reply)) { reply -= 2; // примерка if (!shop.lists.ContainsKey(reply)) { player.sendMessage("your shop id was just wrong " + reply); player.sendActionFailed(); return; } else { pk = new ShopPreviewList(player, shop.lists[reply], reply); } } else { player.sendPacket(new ExBuySellList_Buy(player, shop.lists[reply], 1.10, 1.0, reply)); player.sendPacket(new ExBuySellList_Sell(player)); } }
private void load() { _shops = new SortedList <int, ND_shop>(); Teleports = new NDTeleport(); ItemTable itable = ItemTable.getInstance(); { XElement xml = XElement.Parse(File.ReadAllText(@"scripts\buylists.xml")); foreach (var shops in xml.Elements("shops")) { foreach (var shopp in shops.Elements("shop")) { ND_shop shop = new ND_shop(); shop.id = int.Parse(shopp.Element("npc").Value); shop.mod = double.Parse(shopp.Element("mod").Value); foreach (var selllist in shopp.Elements("selllist")) { ND_shopList slist = new ND_shopList(); slist.id = short.Parse(selllist.Attribute("id").Value); string items = selllist.Element("item").Value; items = items.Replace("\n", "").Replace(" ", ""); foreach (string i in items.Split(',')) { ItemTemplate it = itable.getItem(Convert.ToInt32(i)); if (it != null) { slist.items.Add(new ND_shopItem(it)); } else { CLogger.error("NpcData: cant find item to trade " + i + " on npc " + shop.id); } } shop.lists.Add(slist.id, slist); } _shops.Add(shop.id, shop); } } } CLogger.info("NpcData: loaded " + _shops.Count + " merchants."); //CLogger.info("NpcData: loaded " + _mults.Count + " multisell lists."); }