public void OnMarketBuyItem(Packets.Client.MarketBuyItem p) { uint id = p.GetItemId(); MarketplaceItem item = MapServer.charDB.GetMarketItem(id); Packets.Server.MarketBuyItem p1 = new SagaMap.Packets.Server.MarketBuyItem(); if (item == null) { p1.SetResult(1); this.netIO.SendPacket(p1, this.SessionID); return; } if (this.Char.zeny < item.price) { p1.SetResult(1); this.netIO.SendPacket(p1, this.SessionID); return; } Mail mail = new Mail(); mail.content = "We are glad to inform you that your registered item at <Regenbogen> Market Place was bought by another Player" + ".\n Here is the money for the sold item.\n We are looking forward to see you at <Regenbogen> again!"; mail.date = DateTime.Now; mail.read = 0; mail.receiver = item.owner; mail.sender = "<Regenbogen>"; mail.topic = "Your item at <Regenbogen> was sold"; mail.zeny = item.price; mail.valid = 30; MapServer.charDB.NewMail(mail); MapServer.charDB.DeleteMarketItem(item); MapClient receiver = MapClientManager.Instance.GetClient(item.owner); if (receiver != null) { receiver.CheckNewMail(); } this.Char.zeny -= item.price; this.SendZeny(); mail = new Mail(); mail.content = "We are glad to inform you that you've successfully bought an item at <Regenbogen> Market Place from another Player" + ".\n Here is the bought item.\n We are looking forward to see you at <Regenbogen> again!"; mail.date = DateTime.Now; mail.read = 0; mail.receiver = this.Char.Name; mail.sender = "<Regenbogen>"; mail.topic = "You've bought an item at <Regenbogen>"; mail.valid = 30; mail.creator = ""; mail.durability = item.item.durability; mail.item = (uint)item.item.id; mail.stack = item.item.stack; MapServer.charDB.NewMail(mail); this.CheckNewMail(); p1.SetResult(0); this.netIO.SendPacket(p1, this.SessionID); }