Esempio n. 1
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            bool       flag = packet.ReadBoolean();
            int        num  = 0;
            GamePlayer gamePlayer;

            if (flag)
            {
                num        = packet.ReadInt();
                gamePlayer = WorldMgr.GetPlayerById(num);
            }
            else
            {
                string nickName = packet.ReadString();
                gamePlayer = WorldMgr.GetClientByPlayerNickName(nickName);
            }
            PlayerInfo          playerInfo;
            List <ItemInfo>     list;
            List <ItemInfo>     list2;
            List <UserGemStone> list3;

            if (gamePlayer != null)
            {
                playerInfo = gamePlayer.PlayerCharacter;
                list       = gamePlayer.MainBag.GetItems(0, 31);
                list2      = gamePlayer.BeadBag.GetItems(0, 31);
                list3      = gamePlayer.GemStone;
            }
            else
            {
                using (PlayerBussiness playerBussiness = new PlayerBussiness())
                {
                    playerInfo = playerBussiness.GetUserSingleByUserID(num);
                    if (playerInfo == null)
                    {
                        return(0);
                    }
                    list            = playerBussiness.GetUserEuqip(num);
                    list2           = playerBussiness.GetUserBeadEuqip(num);
                    playerInfo.Texp = playerBussiness.GetUserTexpInfoSingle(num);
                    list3           = playerBussiness.GetSingleGemStones(num);
                }
            }
            if (playerInfo != null && list != null && list2 != null && list3 != null)
            {
                client.Player.Out.SendUserEquip(playerInfo, list, list3, list2);
            }
            return(0);
        }
Esempio n. 2
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            byte b  = packet.ReadByte();
            byte b2 = b;

            if (b2 <= 51)
            {
                if (b2 != 45)
                {
                    if (b2 == 51)
                    {
                        int    num = packet.ReadInt();
                        string msg = packet.ReadString();
                        packet.ReadBoolean();
                        GamePlayer playerById = WorldMgr.GetPlayerById(num);
                        if (playerById != null)
                        {
                            client.Player.Out.sendOneOnOneTalk(num, false, client.Player.PlayerCharacter.NickName, msg, client.Player.PlayerCharacter.ID);
                            playerById.Out.sendOneOnOneTalk(client.Player.PlayerCharacter.ID, false, client.Player.PlayerCharacter.NickName, msg, num);
                        }
                        else
                        {
                            client.Player.Out.SendMessage(eMessageType.Normal, "Người chơi không online!");
                        }
                    }
                }
            }
            else
            {
                switch (b2)
                {
                case 160:
                {
                    string text = packet.ReadString();
                    int    num2 = packet.ReadInt();
                    if (num2 < 0 || num2 > 1)
                    {
                        return(1);
                    }
                    using (PlayerBussiness playerBussiness = new PlayerBussiness())
                    {
                        GamePlayer clientByPlayerNickName = WorldMgr.GetClientByPlayerNickName(text);
                        PlayerInfo playerInfo;
                        if (clientByPlayerNickName != null)
                        {
                            playerInfo = clientByPlayerNickName.PlayerCharacter;
                        }
                        else
                        {
                            playerInfo = playerBussiness.GetUserSingleByNickName(text);
                        }
                        if (!string.IsNullOrEmpty(text) && playerInfo != null)
                        {
                            if (!client.Player.Friends.ContainsKey(playerInfo.ID) || client.Player.Friends[playerInfo.ID] != num2)
                            {
                                if (playerBussiness.AddFriends(new FriendInfo
                                    {
                                        FriendID = playerInfo.ID,
                                        IsExist = true,
                                        Remark = "",
                                        UserID = client.Player.PlayerCharacter.ID,
                                        Relation = num2
                                    }))
                                {
                                    client.Player.FriendsAdd(playerInfo.ID, num2);
                                    if (num2 != 1 && playerInfo.State != 0)
                                    {
                                        GSPacketIn gSPacketIn = new GSPacketIn(160, client.Player.PlayerCharacter.ID);
                                        gSPacketIn.WriteByte(166);
                                        gSPacketIn.WriteInt(playerInfo.ID);
                                        gSPacketIn.WriteString(client.Player.PlayerCharacter.NickName);
                                        gSPacketIn.WriteBoolean(false);
                                        if (clientByPlayerNickName != null)
                                        {
                                            clientByPlayerNickName.Out.SendTCP(gSPacketIn);
                                        }
                                        else
                                        {
                                            GameServer.Instance.LoginServer.SendPacket(gSPacketIn);
                                        }
                                    }
                                    client.Out.SendAddFriend(playerInfo, num2, true);
                                }
                            }
                            else
                            {
                                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("FriendAddHandler.Falied", new object[0]));
                            }
                        }
                        else
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("FriendAddHandler.Success", new object[0]));
                        }
                        return(1);
                    }
                    break;
                }

                case 161:
                    break;

                case 162:
                    goto IL_28F;

                case 163:
                    return(1);

                case 164:
                    Console.WriteLine("//SAME_CITY_FRIEND ");
                    return(1);

                case 165:
                {
                    int        num3        = packet.ReadInt();
                    GSPacketIn gSPacketIn2 = new GSPacketIn(160, client.Player.PlayerCharacter.ID);
                    gSPacketIn2.WriteByte(165);
                    gSPacketIn2.WriteInt(num3);
                    gSPacketIn2.WriteInt((int)client.Player.PlayerCharacter.typeVIP);
                    gSPacketIn2.WriteInt(client.Player.PlayerCharacter.VIPLevel);
                    gSPacketIn2.WriteBoolean(false);
                    GameServer.Instance.LoginServer.SendPacket(gSPacketIn2);
                    WorldMgr.ChangePlayerState(client.Player.PlayerCharacter.ID, num3, client.Player.PlayerCharacter.ConsortiaID);
                    return(1);
                }

                case 166:
                    Console.WriteLine("//FRIEND_RESPONSE ");
                    return(1);

                default:
                    if (b2 != 208)
                    {
                        return(1);
                    }
                    Console.WriteLine("//ADD_CUSTOM_FRIENDS ");
                    return(1);
                }
                int num4 = packet.ReadInt();
                using (PlayerBussiness playerBussiness2 = new PlayerBussiness())
                {
                    if (playerBussiness2.DeleteFriends(client.Player.PlayerCharacter.ID, num4))
                    {
                        client.Player.FriendsRemove(num4);
                        client.Out.SendFriendRemove(num4);
                    }
                    return(1);
                }
IL_28F:
                Console.WriteLine("//FRIEND_UPDATE ");
            }
            return(1);
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int             num                    = 0;
            int             num2                   = 0;
            int             offer                  = 0;
            int             num3                   = 0;
            int             medal                  = 0;
            StringBuilder   stringBuilder          = new StringBuilder();
            eMessageType    eMessageType           = eMessageType.Normal;
            string          translateId            = "UserPresentGoodsHandler.Success";
            string          str                    = packet.ReadString();
            string          nickName               = packet.ReadString();
            int             num4                   = packet.ReadInt();
            List <ItemInfo> list                   = new List <ItemInfo>();
            StringBuilder   stringBuilder2         = new StringBuilder();
            GamePlayer      clientByPlayerNickName = WorldMgr.GetClientByPlayerNickName(nickName);
            PlayerInfo      playerInfo;

            if (clientByPlayerNickName == null)
            {
                using (PlayerBussiness playerBussiness = new PlayerBussiness())
                {
                    playerInfo = playerBussiness.GetUserSingleByNickName(nickName);
                    goto IL_78;
                }
            }
            playerInfo = clientByPlayerNickName.PlayerCharacter;
IL_78:
            bool flag = false;

            for (int i = 0; i < num4; i++)
            {
                int    iD    = packet.ReadInt();
                int    num5  = packet.ReadInt();
                string text  = packet.ReadString();
                string text2 = packet.ReadString();
                packet.ReadInt();
                ShopItemInfo     shopItemInfoById = ShopMgr.GetShopItemInfoById(iD);
                ItemTemplateInfo goods            = ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID);
                ItemInfo         itemInfo         = ItemInfo.CreateFromTemplate(goods, 1, 102);
                if (shopItemInfoById.BuyType == 0)
                {
                    if (1 == num5)
                    {
                        itemInfo.ValidDate = shopItemInfoById.AUnit;
                    }
                    if (2 == num5)
                    {
                        itemInfo.ValidDate = shopItemInfoById.BUnit;
                    }
                    if (3 == num5)
                    {
                        itemInfo.ValidDate = shopItemInfoById.CUnit;
                    }
                }
                else
                {
                    if (1 == num5)
                    {
                        itemInfo.Count = shopItemInfoById.AUnit;
                    }
                    if (2 == num5)
                    {
                        itemInfo.Count = shopItemInfoById.BUnit;
                    }
                    if (3 == num5)
                    {
                        itemInfo.Count = shopItemInfoById.CUnit;
                    }
                }
                if (itemInfo != null || shopItemInfoById != null)
                {
                    itemInfo.Color = ((text == null) ? "" : text);
                    itemInfo.Skin  = ((text2 == null) ? "" : text2);
                    if (flag)
                    {
                        itemInfo.IsBinds = true;
                    }
                    else
                    {
                        itemInfo.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind);
                    }
                    stringBuilder2.Append(num5);
                    stringBuilder2.Append(",");
                    list.Add(itemInfo);
                    ItemInfo.SetItemType(shopItemInfoById, num5, ref num, ref num2, ref offer, ref num3, ref medal);
                }
            }
            if (list.Count == 0)
            {
                return(1);
            }
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(1);
            }
            if (num <= client.Player.PlayerCharacter.Gold && num2 <= client.Player.PlayerCharacter.Money && num3 <= client.Player.PlayerCharacter.GiftToken)
            {
                client.Player.RemoveMoney(num2);
                client.Player.RemoveGold(num);
                client.Player.RemoveGiftToken(num3);
                string        text3          = "";
                int           num6           = 0;
                MailInfo      mailInfo       = new MailInfo();
                StringBuilder stringBuilder3 = new StringBuilder();
                stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0]));
                for (int j = 0; j < list.Count; j++)
                {
                    text3 += ((text3 == "") ? list[j].TemplateID.ToString() : ("," + list[j].TemplateID.ToString()));
                    using (PlayerBussiness playerBussiness2 = new PlayerBussiness())
                    {
                        list[j].UserID = 0;
                        playerBussiness2.AddGoods(list[j]);
                        num6++;
                        stringBuilder3.Append(num6);
                        stringBuilder3.Append("、");
                        stringBuilder3.Append(list[j].Template.Name);
                        stringBuilder3.Append("x");
                        stringBuilder3.Append(list[j].Count);
                        stringBuilder3.Append(";");
                        switch (num6)
                        {
                        case 1:
                            mailInfo.Annex1     = list[j].ItemID.ToString();
                            mailInfo.Annex1Name = list[j].Template.Name;
                            break;

                        case 2:
                            mailInfo.Annex2     = list[j].ItemID.ToString();
                            mailInfo.Annex2Name = list[j].Template.Name;
                            break;

                        case 3:
                            mailInfo.Annex3     = list[j].ItemID.ToString();
                            mailInfo.Annex3Name = list[j].Template.Name;
                            break;

                        case 4:
                            mailInfo.Annex4     = list[j].ItemID.ToString();
                            mailInfo.Annex4Name = list[j].Template.Name;
                            break;

                        case 5:
                            mailInfo.Annex5     = list[j].ItemID.ToString();
                            mailInfo.Annex5Name = list[j].Template.Name;
                            break;
                        }
                        if (num6 == 5)
                        {
                            num6 = 0;
                            mailInfo.AnnexRemark = stringBuilder3.ToString();
                            stringBuilder3.Remove(0, stringBuilder3.Length);
                            stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0]));
                            mailInfo.Content    = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "] " + str;
                            mailInfo.Gold       = 0;
                            mailInfo.Money      = 0;
                            mailInfo.Receiver   = playerInfo.NickName;
                            mailInfo.ReceiverID = playerInfo.ID;
                            mailInfo.Sender     = client.Player.PlayerCharacter.NickName;
                            mailInfo.SenderID   = client.Player.PlayerCharacter.ID;
                            mailInfo.Title      = mailInfo.Content;
                            mailInfo.Type       = 8;
                            playerBussiness2.SendMail(mailInfo);
                            eMessageType = eMessageType.ERROR;
                            mailInfo.Revert();
                        }
                    }
                }
                if (num6 > 0)
                {
                    using (PlayerBussiness playerBussiness3 = new PlayerBussiness())
                    {
                        mailInfo.AnnexRemark = stringBuilder3.ToString();
                        mailInfo.Content     = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "] " + str;
                        mailInfo.Gold        = 0;
                        mailInfo.Money       = 0;
                        mailInfo.Receiver    = playerInfo.NickName;
                        mailInfo.ReceiverID  = playerInfo.ID;
                        mailInfo.Sender      = client.Player.PlayerCharacter.NickName;
                        mailInfo.SenderID    = client.Player.PlayerCharacter.ID;
                        mailInfo.Title       = mailInfo.Content;
                        mailInfo.Type        = 8;
                        playerBussiness3.SendMail(mailInfo);
                        eMessageType = eMessageType.ERROR;
                    }
                }
                if (eMessageType == eMessageType.ERROR && clientByPlayerNickName != null)
                {
                    clientByPlayerNickName.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver);
                }
                client.Player.OnPaid(num2, num, offer, num3, medal, stringBuilder.ToString());
                LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, num, num3, offer, medal, "牌子编号", text3, stringBuilder2.ToString());
            }
            else
            {
                if (num > client.Player.PlayerCharacter.Gold)
                {
                    translateId = "UserBuyItemHandler.NoGold";
                }
                if (num2 > client.Player.PlayerCharacter.Money)
                {
                    translateId = "UserBuyItemHandler.NoMoney";
                }
                if (num3 > client.Player.PlayerCharacter.GiftToken)
                {
                    translateId = "UserBuyItemHandler.GiftToken";
                }
                eMessageType = eMessageType.ERROR;
            }
            client.Out.SendMessage(eMessageType, LanguageMgr.GetTranslation(translateId, new object[0]));
            return(0);
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.Gold < 100)
            {
                return(1);
            }
            string       translateId = "UserSendMailHandler.Success";
            eMessageType type        = eMessageType.Normal;
            GSPacketIn   gSPacketIn  = new GSPacketIn(116, client.Player.PlayerCharacter.ID);
            ItemInfo     itemInfo    = null;
            string       text        = packet.ReadString().Trim();
            string       title       = packet.ReadString();
            string       content     = packet.ReadString();
            bool         flag        = packet.ReadBoolean();
            int          num         = packet.ReadInt();
            int          num2        = packet.ReadInt();
            eBageType    eBageType   = (eBageType)packet.ReadByte();
            int          num3        = packet.ReadInt();
            int          num4        = packet.ReadInt();

            if (text == client.Player.PlayerCharacter.NickName)
            {
                UserSendMailHandler.log.Error("Hack ingame: Username: "******" - NickName: " + client.Player.PlayerCharacter.NickName);
                return(0);
            }
            int num5 = 0;

            if ((num2 != 0 || num3 != -1) && client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                gSPacketIn.WriteBoolean(false);
                client.Out.SendTCP(gSPacketIn);
                return(1);
            }
            using (PlayerBussiness playerBussiness = new PlayerBussiness())
            {
                GamePlayer clientByPlayerNickName = WorldMgr.GetClientByPlayerNickName(text);
                PlayerInfo playerInfo;
                if (clientByPlayerNickName == null)
                {
                    playerInfo = playerBussiness.GetUserSingleByNickName(text);
                }
                else
                {
                    playerInfo = clientByPlayerNickName.PlayerCharacter;
                }
                if (playerInfo != null && !string.IsNullOrEmpty(text))
                {
                    if (playerInfo.NickName != client.Player.PlayerCharacter.NickName)
                    {
                        client.Player.SaveIntoDatabase();
                        MailInfo mailInfo = new MailInfo();
                        mailInfo.SenderID   = client.Player.PlayerCharacter.ID;
                        mailInfo.Sender     = client.Player.PlayerCharacter.NickName;
                        mailInfo.ReceiverID = playerInfo.ID;
                        mailInfo.Receiver   = playerInfo.NickName;
                        mailInfo.IsExist    = true;
                        mailInfo.Gold       = 0;
                        mailInfo.Money      = 0;
                        mailInfo.Title      = title;
                        mailInfo.Content    = content;
                        List <ItemInfo>  list          = new List <ItemInfo>();
                        List <eBageType> list2         = new List <eBageType>();
                        List <int>       list3         = new List <int>();
                        StringBuilder    stringBuilder = new StringBuilder();
                        stringBuilder.Append(LanguageMgr.GetTranslation("UserSendMailHandler.AnnexRemark", new object[0]));
                        int num6 = 0;
                        if (num3 != -1)
                        {
                            itemInfo = client.Player.GetItemAt(eBageType, num3);
                            if (itemInfo != null && !itemInfo.IsBinds)
                            {
                                if (itemInfo.Count < num4 || num4 < 0)
                                {
                                    client.Out.SendMessage(type, LanguageMgr.GetTranslation("Số lượng không có thực, thao tác thất bại!", new object[0]));
                                    int result = 0;
                                    return(result);
                                }
                                num5 = itemInfo.Count - num4;
                                mailInfo.Annex1Name = itemInfo.Template.Name;
                                mailInfo.Annex1     = itemInfo.ItemID.ToString();
                                list.Add(itemInfo);
                                list2.Add(eBageType);
                                list3.Add(num4);
                                num6++;
                                stringBuilder.Append(num6);
                                stringBuilder.Append("、");
                                stringBuilder.Append(mailInfo.Annex1Name);
                                stringBuilder.Append("x");
                                stringBuilder.Append(itemInfo.Count);
                                stringBuilder.Append(";");
                            }
                        }
                        if (flag)
                        {
                            if (num2 <= 0 || (string.IsNullOrEmpty(mailInfo.Annex1) && string.IsNullOrEmpty(mailInfo.Annex2) && string.IsNullOrEmpty(mailInfo.Annex3) && string.IsNullOrEmpty(mailInfo.Annex4)))
                            {
                                int result = 1;
                                return(result);
                            }
                            mailInfo.ValidDate = ((num == 1) ? 1 : 6);
                            mailInfo.Type      = 101;
                            if (num2 > 0)
                            {
                                mailInfo.Money = num2;
                                num6++;
                                stringBuilder.Append(num6);
                                stringBuilder.Append("、");
                                stringBuilder.Append(LanguageMgr.GetTranslation("UserSendMailHandler.PayMoney", new object[0]));
                                stringBuilder.Append(num2);
                                stringBuilder.Append(";");
                            }
                        }
                        else
                        {
                            mailInfo.Type = 1;
                            if (client.Player.PlayerCharacter.Money >= num2 && num2 > 0)
                            {
                                mailInfo.Money = num2;
                                client.Player.RemoveMoney(num2);
                                LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Send, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                                num6++;
                                stringBuilder.Append(num6);
                                stringBuilder.Append("、");
                                stringBuilder.Append(LanguageMgr.GetTranslation("UserSendMailHandler.Money", new object[0]));
                                stringBuilder.Append(num2);
                                stringBuilder.Append(";");
                            }
                        }
                        if (stringBuilder.Length > 1)
                        {
                            mailInfo.AnnexRemark = stringBuilder.ToString();
                        }
                        if (playerBussiness.SendMail(mailInfo))
                        {
                            client.Player.RemoveGold(100);
                            if (itemInfo != null)
                            {
                                itemInfo.UserID = 0;
                                client.Player.RemoveItem(itemInfo);
                                itemInfo.IsExist = true;
                                itemInfo.Count   = num4;
                                if (num5 > 0)
                                {
                                    client.Player.AddTemplate(itemInfo, eBageType, num5);
                                }
                            }
                        }
                        client.Player.SaveIntoDatabase();
                        gSPacketIn.WriteBoolean(true);
                        if (playerInfo.State != 0)
                        {
                            client.Player.Out.SendMailResponse(playerInfo.ID, eMailRespose.Receiver);
                        }
                        client.Player.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Send);
                    }
                    else
                    {
                        translateId = "UserSendMailHandler.Failed1";
                        gSPacketIn.WriteBoolean(false);
                    }
                }
                else
                {
                    type        = eMessageType.ERROR;
                    translateId = "UserSendMailHandler.Failed2";
                    gSPacketIn.WriteBoolean(false);
                }
            }
            client.Out.SendMessage(type, LanguageMgr.GetTranslation(translateId, new object[0]));
            client.Out.SendTCP(gSPacketIn);
            return(0);
        }
Esempio n. 5
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result;

            if (player.PlayerCharacter.Gold < 100)
            {
                result = 1;
            }
            else
            {
                string       msg  = "UserSendMailHandler.Success";
                eMessageType eMsg = eMessageType.Normal;
                GSPacketIn   pkg  = packet.Clone();
                pkg.ClearContext();
                string    nickName  = packet.ReadString().Trim();
                string    title     = packet.ReadString();
                string    content   = packet.ReadString();
                bool      isPay     = packet.ReadBoolean();
                int       validDate = packet.ReadInt();
                int       money     = packet.ReadInt();
                eBageType bag       = (eBageType)packet.ReadByte();
                int       place     = packet.ReadInt();
                eBageType bag2      = (eBageType)packet.ReadByte();
                int       place2    = packet.ReadInt();
                eBageType bag3      = (eBageType)packet.ReadByte();
                int       place3    = packet.ReadInt();
                eBageType bag4      = (eBageType)packet.ReadByte();
                int       place4    = packet.ReadInt();
                if ((money != 0 || place != -1 || place2 != -1 || place3 != -1 || place4 != -1) && player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                    pkg.WriteBoolean(false);
                    player.Out.SendTCP(pkg);
                    result = 1;
                }
                else
                {
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        GamePlayer otherp = WorldMgr.GetClientByPlayerNickName(nickName);
                        PlayerInfo user;
                        if (otherp == null)
                        {
                            user = db.GetUserSingleByNickName(nickName);
                        }
                        else
                        {
                            user = otherp.PlayerCharacter;
                        }
                        if (!string.IsNullOrEmpty(title))
                        {
                            if (user != null && !string.IsNullOrEmpty(nickName))
                            {
                                if (user.NickName != player.PlayerCharacter.NickName)
                                {
                                    player.SaveIntoDatabase();
                                    MailInfo message = new MailInfo();
                                    message.SenderID   = player.PlayerCharacter.ID;
                                    message.Sender     = player.PlayerCharacter.NickName;
                                    message.ReceiverID = user.ID;
                                    message.Receiver   = user.NickName;
                                    message.IsExist    = true;
                                    message.Gold       = 0;
                                    message.Money      = 0;
                                    message.Title      = title;
                                    message.Content    = content;
                                    List <ItemInfo>  items       = new List <ItemInfo>();
                                    List <eBageType> bagType     = new List <eBageType>();
                                    StringBuilder    annexRemark = new StringBuilder();
                                    annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.AnnexRemark", new object[0]));
                                    int index = 0;
                                    if (place != -1)
                                    {
                                        ItemInfo goods = player.GetItemAt(bag, place);
                                        if (goods != null && !goods.IsBinds)
                                        {
                                            message.Annex1Name = goods.Template.Name;
                                            message.Annex1     = goods.ItemID.ToString();
                                            items.Add(goods);
                                            bagType.Add(bag);
                                            index++;
                                            annexRemark.Append(index);
                                            annexRemark.Append("、");
                                            annexRemark.Append(message.Annex1Name);
                                            annexRemark.Append("x");
                                            annexRemark.Append(goods.Count);
                                            annexRemark.Append(";");
                                        }
                                    }
                                    if (place2 != -1)
                                    {
                                        ItemInfo goods = player.GetItemAt(bag2, place2);
                                        if (goods != null && !goods.IsBinds && !items.Contains(goods))
                                        {
                                            message.Annex2Name = goods.Template.Name;
                                            message.Annex2     = goods.ItemID.ToString();
                                            items.Add(goods);
                                            bagType.Add(bag2);
                                            index++;
                                            annexRemark.Append(index);
                                            annexRemark.Append("、");
                                            annexRemark.Append(message.Annex2Name);
                                            annexRemark.Append("x");
                                            annexRemark.Append(goods.Count);
                                            annexRemark.Append(";");
                                        }
                                    }
                                    if (place3 != -1)
                                    {
                                        ItemInfo goods = player.GetItemAt(bag3, place3);
                                        if (goods != null && !goods.IsBinds && !items.Contains(goods))
                                        {
                                            message.Annex3Name = goods.Template.Name;
                                            message.Annex3     = goods.ItemID.ToString();
                                            items.Add(goods);
                                            bagType.Add(bag3);
                                            index++;
                                            annexRemark.Append(index);
                                            annexRemark.Append("、");
                                            annexRemark.Append(message.Annex3Name);
                                            annexRemark.Append("x");
                                            annexRemark.Append(goods.Count);
                                            annexRemark.Append(";");
                                        }
                                    }
                                    if (place4 != -1)
                                    {
                                        ItemInfo goods = player.GetItemAt(bag4, place4);
                                        if (goods != null && !goods.IsBinds && !items.Contains(goods))
                                        {
                                            message.Annex4Name = goods.Template.Name;
                                            message.Annex4     = goods.ItemID.ToString();
                                            items.Add(goods);
                                            bagType.Add(bag4);
                                            index++;
                                            annexRemark.Append(index);
                                            annexRemark.Append("、");
                                            annexRemark.Append(message.Annex4Name);
                                            annexRemark.Append("x");
                                            annexRemark.Append(goods.Count);
                                            annexRemark.Append(";");
                                        }
                                    }
                                    if (isPay)
                                    {
                                        if (money <= 0 || (string.IsNullOrEmpty(message.Annex1) && string.IsNullOrEmpty(message.Annex2) && string.IsNullOrEmpty(message.Annex3) && string.IsNullOrEmpty(message.Annex4)))
                                        {
                                            result = 1;
                                            return(result);
                                        }
                                        message.ValidDate = ((validDate == 1) ? 1 : 6);
                                        message.Type      = 101;
                                        if (money > 0)
                                        {
                                            message.Money = money;
                                            index++;
                                            annexRemark.Append(index);
                                            annexRemark.Append("、");
                                            annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.PayMoney", new object[0]));
                                            annexRemark.Append(money);
                                            annexRemark.Append(";");
                                        }
                                    }
                                    else
                                    {
                                        message.Type = 1;
                                        if (player.PlayerCharacter.Money >= money && money > 0)
                                        {
                                            message.Money = money;
                                            player.RemoveMoney(money, LogMoneyType.Mail, LogMoneyType.Mail_Send);
                                            index++;
                                            annexRemark.Append(index);
                                            annexRemark.Append("、");
                                            annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.Money", new object[0]));
                                            annexRemark.Append(money);
                                            annexRemark.Append(";");
                                        }
                                    }
                                    if (annexRemark.Length > 1)
                                    {
                                        message.AnnexRemark = annexRemark.ToString();
                                    }
                                    if (db.SendMail(message))
                                    {
                                        player.RemoveGold(100);
                                        for (int i = 0; i < items.Count; i++)
                                        {
                                            player.TakeOutItem(items[i]);
                                        }
                                    }
                                    player.SaveIntoDatabase();
                                    pkg.WriteBoolean(true);
                                    if (user.State != 0)
                                    {
                                        player.Out.SendMailResponse(user.ID, eMailRespose.Receiver);
                                    }
                                    player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Send);
                                }
                                else
                                {
                                    msg = "UserSendMailHandler.Failed1";
                                    pkg.WriteBoolean(false);
                                }
                            }
                            else
                            {
                                eMsg = eMessageType.ERROR;
                                msg  = "UserSendMailHandler.Failed2";
                                pkg.WriteBoolean(false);
                            }
                        }
                        else
                        {
                            eMsg = eMessageType.ERROR;
                            msg  = "UserSendMailHandler.Failed3";
                            pkg.WriteBoolean(false);
                        }
                    }
                    player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0]));
                    player.Out.SendTCP(pkg);
                    result = 0;
                }
            }
            return(result);
        }
Esempio n. 6
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            string text    = packet.ReadString();
            int    num     = packet.ReadInt();
            int    num2    = 569;
            int    num3    = 569;
            int    num4    = 1707;
            int    num5    = 3000;
            string message = "Você acabo de ativar VIP";
            int    num6    = num;

            if (num6 != 30)
            {
                if (num6 != 90)
                {
                    if (num6 == 180)
                    {
                        num2 = num5;
                    }
                }
                else
                {
                    num2 = num4;
                }
            }
            else
            {
                num2 = num3;
            }
            GamePlayer clientByPlayerNickName = WorldMgr.GetClientByPlayerNickName(text);

            if (num2 <= client.Player.PlayerCharacter.Money)
            {
                DateTime now = DateTime.Now;
                using (PlayerBussiness playerBussiness = new PlayerBussiness())
                {
                    playerBussiness.VIPRenewal(text, num, ref now);
                    if (clientByPlayerNickName == null)
                    {
                        message = "Tiếp phí VIP cho " + text + " thàng công!";
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.NickName == text)
                        {
                            if (client.Player.PlayerCharacter.typeVIP == 0)
                            {
                                client.Player.OpenVIP(now);
                            }
                            else
                            {
                                client.Player.ContinousVIP(now);
                                message = "Renovação VIP bem sucedida!";
                            }
                            client.Out.SendOpenVIP(client.Player.PlayerCharacter);
                        }
                        else
                        {
                            string message2;
                            if (clientByPlayerNickName.PlayerCharacter.typeVIP == 0)
                            {
                                clientByPlayerNickName.OpenVIP(now);
                                message  = "Kích hoạt VIP cho " + text + " thàng công!";
                                message2 = client.Player.PlayerCharacter.NickName + ", tiếp phí VIP cho bạn thàng công!";
                            }
                            else
                            {
                                clientByPlayerNickName.ContinousVIP(now);
                                message  = "Gia hạn VIP cho " + text + " thàng công!";
                                message2 = client.Player.PlayerCharacter.NickName + ", gia hạn VIP cho bạn thàng công!";
                            }
                            clientByPlayerNickName.Out.SendOpenVIP(clientByPlayerNickName.PlayerCharacter);
                            clientByPlayerNickName.Out.SendMessage(eMessageType.Normal, message2);
                        }
                    }
                    client.Player.AddExpVip(num2);
                    client.Player.RemoveMoney(num2);
                    client.Out.SendMessage(eMessageType.Normal, message);
                    return(0);
                }
            }
            client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.Money", new object[0]));
            return(0);
        }
Esempio n. 7
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();
            string nickName = packet.ReadString();
            int    relation = packet.ReadInt();
            int    result;

            if (relation < 0 || relation > 1)
            {
                result = 1;
            }
            else
            {
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    GamePlayer other = WorldMgr.GetClientByPlayerNickName(nickName);
                    PlayerInfo user;
                    if (other != null)
                    {
                        user = other.PlayerCharacter;
                    }
                    else
                    {
                        user = db.GetUserSingleByNickName(nickName);
                    }
                    if (!string.IsNullOrEmpty(nickName) && user != null)
                    {
                        if (!player.Friends.ContainsKey(user.ID) || player.Friends[user.ID] != relation)
                        {
                            if (db.AddFriends(new FriendInfo
                            {
                                FriendID = user.ID,
                                IsExist = true,
                                Remark = "",
                                UserID = player.PlayerCharacter.ID,
                                Relation = relation
                            }))
                            {
                                player.FriendsAdd(user.ID, relation);
                                pkg.WriteInt(user.ID);
                                pkg.WriteString(user.NickName);
                                pkg.WriteBoolean(user.Sex);
                                pkg.WriteString(user.Style);
                                pkg.WriteString(user.Colors);
                                pkg.WriteString(user.Skin);
                                pkg.WriteInt((user.State == 1) ? 1 : 0);
                                pkg.WriteInt(user.Grade);
                                pkg.WriteInt(user.Hide);
                                pkg.WriteString(user.ConsortiaName);
                                pkg.WriteInt(user.Total);
                                pkg.WriteInt(user.Escape);
                                pkg.WriteInt(user.Win);
                                pkg.WriteInt(user.Offer);
                                pkg.WriteInt(user.Repute);
                                pkg.WriteInt(relation);
                                pkg.WriteString(user.UserName);
                                pkg.WriteInt(user.Nimbus);
                                pkg.WriteInt(user.FightPower);
                                pkg.WriteInt(user.AchievementPoint);
                                pkg.WriteString(user.Honor);
                                if (relation != 1 && user.State != 0)
                                {
                                    GSPacketIn response = new GSPacketIn(166, player.PlayerCharacter.ID);
                                    response.WriteInt(user.ID);
                                    response.WriteString(player.PlayerCharacter.NickName);
                                    if (other != null)
                                    {
                                        other.Out.SendTCP(response);
                                    }
                                    else
                                    {
                                        GameServer.Instance.LoginServer.SendPacket(response);
                                    }
                                }
                                player.Out.SendTCP(pkg);
                            }
                        }
                        else
                        {
                            player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("FriendAddHandler.Falied", new object[0]));
                        }
                    }
                    else
                    {
                        player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("FriendAddHandler.Success", new object[0]));
                    }
                }
                result = 0;
            }
            return(result);
        }