public void CheckNewMail() { List <Mail> list = MapServer.charDB.GetMail(SearchType.Receiver, this.Char.name); if (list == null) { return; } uint count = 0; foreach (Mail i in list) { //if it's not read if (i.read == 0) { count++; } } if (count != 0) { Packets.Server.MailArrived p = new SagaMap.Packets.Server.MailArrived(); p.SetAmount(count); this.netIO.SendPacket(p, this.SessionID); } }
public void OnMailSend(SagaMap.Packets.Client.MailSend p) { Mail mail = new Mail(); Item item; Packets.Server.MailSendAnswer p2 = new SagaMap.Packets.Server.MailSendAnswer(); if (!MapServer.charDB.CharExists(0, p.GetName())) { p2.SetResult(SagaMap.Packets.Server.MailSendAnswer.Results.CHARACTER_NAME_NOT_EXIST); this.netIO.SendPacket(p2, this.SessionID); return; } uint fee = p.GetZeny(); mail.content = p.GetContent(); mail.date = DateTime.Now; mail.read = 0; mail.receiver = p.GetName(); mail.sender = this.Char.name; mail.topic = p.GetTopic(); mail.zeny = p.GetZeny(); if (p.Unknown() != 0) { item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, p.GetSlot()); if (item == null) { mail.valid = 7; } else { fee += 10; if (this.Char.zeny < fee) { p2.SetResult(SagaMap.Packets.Server.MailSendAnswer.Results.NOT_ENOUGH_ZENY); this.netIO.SendPacket(p2, this.SessionID); return; } mail.valid = 30; mail.creator = item.creatorName; mail.durability = item.durability; mail.item = (uint)item.id; mail.stack = item.stack; this.map.RemoveItemFromActorPC(this.Char, p.GetSlot(), item.id, item.stack, ITEM_UPDATE_REASON.SOLD); } } else { mail.valid = 7; } this.Char.zeny -= fee; this.SendZeny(); MapServer.charDB.NewMail(mail); MapClient receiver = MapClientManager.Instance.GetClient(p.GetName()); if (receiver != null) { Packets.Server.MailArrived p1 = new SagaMap.Packets.Server.MailArrived(); p1.SetAmount(1); receiver.netIO.SendPacket(p1, receiver.SessionID); } p2.SetResult(SagaMap.Packets.Server.MailSendAnswer.Results.OK); this.netIO.SendPacket(p2, this.SessionID); }