Exemple #1
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            AASInfo info = new AASInfo();

            info.UserID = client.Player.PlayerCharacter.ID;
            bool result = false;
            bool rlt    = false;

            bool isclosed = packet.ReadBoolean();

            if (isclosed)
            {
                info.Name     = "";
                info.IDNumber = "";
                info.State    = 0;
                result        = true;
            }
            else
            {
                info.Name     = packet.ReadString();
                info.IDNumber = packet.ReadString();
                result        = CheckIDNumber(info.IDNumber);
                if (info.IDNumber != "")
                {
                    client.Player.IsAASInfo = true;
                    //result = false;
                    int Age   = Convert.ToInt32(info.IDNumber.Substring(6, 4));
                    int month = Convert.ToInt32(info.IDNumber.Substring(10, 2));
                    if (DateTime.Now.Year.CompareTo(Age + 18) > 0 || (DateTime.Now.Year.CompareTo(Age + 18) == 0 && DateTime.Now.Month.CompareTo(month) >= 0))
                    {
                        client.Player.IsMinor = false;
                    }
                }
                if (info.Name != "" && result)
                {
                    info.State = 1;
                }
                else
                {
                    info.State = 0;
                }
            }

            if (result)
            {
                client.Out.SendAASState(false);
                //client.Out.SendAASControl(false, client.Player.IsAASInfo, client.Player.IsMinor);
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    rlt = db.AddAASInfo(info);
                    client.Out.SendAASInfoSet(rlt);
                }
            }

            if (rlt && (info.State == 1))
            {
                ItemTemplateInfo rewardItem = Bussiness.Managers.ItemMgr.FindItemTemplate(11019);
                if (rewardItem != null)
                {
                    ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, (int)ItemAddType.Other);
                    if (item != null)
                    {
                        item.IsBinds = true;
                        AbstractInventory bg = client.Player.GetItemInventory(item.Template);
                        if (bg.AddItem(item, bg.BeginSlot))
                        {
                            client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", item.Template.Name));
                        }
                        else
                        {
                            client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace"));
                        }
                    }
                }
            }
            return(0);
        }
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            AASInfo info = new AASInfo();

            info.UserID = player.PlayerCharacter.ID;
            bool rlt      = false;
            bool isclosed = packet.ReadBoolean();
            bool result;

            if (isclosed)
            {
                info.Name     = "";
                info.IDNumber = "";
                info.State    = 0;
                result        = true;
            }
            else
            {
                info.Name     = packet.ReadString();
                info.IDNumber = packet.ReadString();
                result        = this.CheckIDNumber(info.IDNumber);
                if (info.IDNumber != "")
                {
                    player.IsAASInfo = true;
                    int Age   = Convert.ToInt32(info.IDNumber.Substring(6, 4));
                    int month = Convert.ToInt32(info.IDNumber.Substring(10, 2));
                    if (DateTime.Now.Year.CompareTo(Age + 18) > 0 || (DateTime.Now.Year.CompareTo(Age + 18) == 0 && DateTime.Now.Month.CompareTo(month) >= 0))
                    {
                        player.IsMinor = false;
                    }
                }
                if (info.Name != "" && result)
                {
                    info.State = 1;
                }
                else
                {
                    info.State = 0;
                }
            }
            if (result)
            {
                player.Out.SendAASState(false);
                player.Out.SendAASControl(false, player.IsAASInfo, player.IsMinor);
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    rlt = db.AddAASInfo(info);
                }
            }
            else
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("AASInfoSetHandle.error", new object[0]));
            }
            if (rlt && info.State == 1)
            {
                ItemTemplateInfo rewardItem = ItemMgr.FindItemTemplate(11019);
                if (rewardItem != null)
                {
                    ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, 107);
                    if (item != null)
                    {
                        item.IsBinds = true;
                        AbstractInventory bg = player.GetItemInventory(item.Template);
                        if (bg.AddItem(item))
                        {
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", new object[]
                            {
                                item.Template.Name
                            }));
                        }
                        else
                        {
                            player.SendItemToMail(item, LanguageMgr.GetTranslation("ASSInfoSetHandle.Content", new object[]
                            {
                                item.Template.Name
                            }), LanguageMgr.GetTranslation("ASSInfoSetHandle.Title", new object[]
                            {
                                item.Template.Name
                            }), eMailType.Common);
                            player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace", new object[0]));
                        }
                    }
                }
            }
            return(0);
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            AASInfo aASInfo = new AASInfo();

            aASInfo.UserID = client.Player.PlayerCharacter.ID;
            bool flag  = false;
            bool flag2 = packet.ReadBoolean();
            bool flag3;

            if (flag2)
            {
                aASInfo.Name     = "";
                aASInfo.IDNumber = "";
                aASInfo.State    = 0;
                flag3            = true;
            }
            else
            {
                aASInfo.Name     = packet.ReadString();
                aASInfo.IDNumber = packet.ReadString();
                flag3            = this.CheckIDNumber(aASInfo.IDNumber);
                if (aASInfo.IDNumber != "")
                {
                    client.Player.IsAASInfo = true;
                    int num   = Convert.ToInt32(aASInfo.IDNumber.Substring(6, 4));
                    int value = Convert.ToInt32(aASInfo.IDNumber.Substring(10, 2));
                    if (DateTime.Now.Year.CompareTo(num + 18) > 0 || (DateTime.Now.Year.CompareTo(num + 18) == 0 && DateTime.Now.Month.CompareTo(value) >= 0))
                    {
                        client.Player.IsMinor = false;
                    }
                }
                if (aASInfo.Name != "" && flag3)
                {
                    aASInfo.State = 1;
                }
                else
                {
                    aASInfo.State = 0;
                }
            }
            if (flag3)
            {
                client.Out.SendAASState(false);
                using (ProduceBussiness produceBussiness = new ProduceBussiness())
                {
                    flag = produceBussiness.AddAASInfo(aASInfo);
                    client.Out.SendAASInfoSet(flag);
                }
            }
            if (flag && aASInfo.State == 1)
            {
                ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(11019);
                if (itemTemplateInfo != null)
                {
                    ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 107);
                    if (itemInfo != null)
                    {
                        itemInfo.IsBinds = true;
                        AbstractInventory itemInventory = client.Player.GetItemInventory(itemInfo.Template);
                        if (itemInventory.AddItem(itemInfo, itemInventory.BeginSlot))
                        {
                            client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", new object[]
                            {
                                itemInfo.Template.Name
                            }));
                        }
                        else
                        {
                            client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace", new object[0]));
                        }
                    }
                }
            }
            return(0);
        }