public void Buylist(L2Player player, L2Npc trader, short reply) { if (!Shops.ContainsKey(trader.Template.NpcId)) { player.SendMessage("you shop was not found"); player.SendActionFailed(); return; } NDShop shop = Shops[trader.Template.NpcId]; GameserverPacket pk; if (!shop.Lists.ContainsKey(reply)) { reply -= 2; // примерка if (!shop.Lists.ContainsKey(reply)) { player.SendMessage($"your shop id was just wrong {reply}"); player.SendActionFailed(); } else { pk = new ShopPreviewList(player, shop.Lists[reply], reply); } } else { player.SendPacket(new ExBuySellListBuy(player, shop.Lists[reply], 1.10, 1.0, reply)); player.SendPacket(new ExBuySellListSell(player)); } }
private void Load() { Shops = new SortedList <int, NDShop>(); _teleports = new NDTeleport(); ItemTable itable = ItemTable.Instance; { XElement xml = XElement.Parse(File.ReadAllText(@"scripts\buylists.xml")); foreach (XElement shops in xml.Elements("shops")) { foreach (XElement shopp in shops.Elements("shop")) { NDShop shop = new NDShop(); XElement npcElement = shopp.Element("npc"); if (npcElement != null) { shop.Id = int.Parse(npcElement.Value); } XElement modElement = shopp.Element("mod"); if (modElement != null) { shop.Mod = double.Parse(modElement.Value); } foreach (XElement selllist in shopp.Elements("selllist")) { NdShopList slist = new NdShopList { Id = short.Parse(selllist.Attribute("id").Value) }; XElement itemElement = selllist.Element("item"); if (itemElement != null) { string items = itemElement.Value; items = items.Replace("\n", string.Empty).Replace(" ", string.Empty); foreach (string i in items.Split(',')) { ItemTemplate it = itable.GetItem(Convert.ToInt32(i)); if (it != null) { slist.Items.Add(new NDShopItem(it)); } else { Log.Error($"NpcData: cant find item to trade {i} on npc {shop.Id}"); } } } shop.Lists.Add(slist.Id, slist); } Shops.Add(shop.Id, shop); } } } Log.Info($"NpcData: loaded {Shops.Count} merchants."); //CLogger.info($"NpcData: loaded {_mults.Count} multisell lists."); }