private void OnSendMail(WorldSession session, PCSendMail packet) { character reciever = Characters.SingleOrDefault(c => c.name == packet.Reciever); var result = MailResponseResult.MAIL_OK; if (reciever == null) { result = MailResponseResult.MAIL_ERR_RECIPIENT_NOT_FOUND; } else if (reciever.name == session.Player.Name) { result = MailResponseResult.MAIL_ERR_CANNOT_SEND_TO_SELF; } else if (session.Player.Character.money < packet.Money + 30) { result = MailResponseResult.MAIL_ERR_NOT_ENOUGH_MONEY; } else if (Mails.Where(m => m.receiver == reciever.guid).ToArray().Length > 100) { result = MailResponseResult.MAIL_ERR_RECIPIENT_CAP_REACHED; } else if (GetFaction(reciever) != GetFaction(session.Player.Character)) { result = MailResponseResult.MAIL_ERR_NOT_YOUR_TEAM; } if (packet.ItemGUID > 0) { throw new NotImplementedException(); } session.SendPacket(new PSSendMailResult(0, MailResponseType.MAIL_SEND, result)); if (result == MailResponseResult.MAIL_OK) { session.Player.Character.money -= (int)(packet.Money + 30); Mails.Add( new mail() { messageType = (byte)MailMessageType.MAIL_NORMAL, deliver_time = 0, expire_time = (int)GameUnits.DAY * 30, @checked = packet.Body != "" ? (byte)MailCheckMask.MAIL_CHECK_MASK_HAS_BODY : (byte)MailCheckMask.MAIL_CHECK_MASK_COPIED, cod = (int)packet.COD, has_items = 0, itemTextId = 0, money = (int)packet.Money, sender = session.Player.Character.guid, receiver = reciever.guid, subject = packet.Subject, stationery = (sbyte)MailStationery.MAIL_STATIONERY_DEFAULT, mailTemplateId = 0 }); } }
private void OnReturnMailToSender(WorldSession session, PCSendMail packet) { throw new NotImplementedException(); }