当前位置: 首页>>代码示例>>C#>>正文


C# PacketReader.String方法代码示例

本文整理汇总了C#中PacketReader.String方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.String方法的具体用法?C# PacketReader.String怎么用?C# PacketReader.String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PacketReader的用法示例。


在下文中一共展示了PacketReader.String方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: oPCode

 public static void oPCode(Decode decode)
 {
     try
     {
         Systems sys = (Systems)decode.Packet;
         sys.PacketInformation = decode;
         PacketReader Reader = new PacketReader(sys.PacketInformation.buffer);
         LogDebug.Show("Opcode: {0}", decode.opcode);
         Opcode opc = (Opcode)decode.opcode;
         switch (opc)
         {
             case Opcode._MSG_LOGIN:
                 {
                     string username_shift = Reader.String(32);
                     string password_md5 = Reader.String(32);
                     Reader.Skip(4);
                     string client_mac = Reader.String(32);
                     Reader.Skip(32);
                     uint unk3 = Reader.UInt32();
                     StringShift shift = new StringShift();
                     string username = shift.Parser(username_shift);
                     LogDebug.Show("username: {0}", username);
                     LogDebug.Show("password_md5: {0}", password_md5);
                     //LogDebug.Show("Mac: {0}", client_mac);
                     //LogDebug.Show("unk3: {0}", unk3);
                     int res = UserLogin(username, password_md5, client_mac);
                     if (res == 1)
                     {
                         sys.client.SendC(ServerListPacket(1));
                     }
                     else
                     {
                         sys.client.SendC(UserFail(0xF0));
                     }
                 }
                 break;
             default:
                 LogConsole.Show("Default Opcode: {0:X} - {1}", decode.opcode, opc);
                 //LogDebug.HexDump(sys.PacketInformation.buffer, 16, true);
                 break;
         }
     }
     catch (Exception)
     {
     }
 }
开发者ID:CarlosX,项目名称:TestProjects,代码行数:46,代码来源:Function_Select.cs

示例2: GuildTitle

        void GuildTitle()
        {
            //Wrap our function inside a catcher
            try
            {
                //Extra hack check
                if (Character.Network.Guild.Level < 4) return;
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                int Selecteduser = Reader.Int32();
                short TitleL = Reader.Int16();
                string Title = Reader.String(TitleL);
                Reader.Close();

                //Get character information
                Systems playerinfo = GetPlayerMainid(Selecteduser);
                //Make sure the user is still there
                if (playerinfo.Character != null)
                {
                    //Update database set new title
                    DB.query("UPDATE guild_members SET guild_grant='" + Title + "' WHERE guild_member_id='" + playerinfo.Character.Information.CharacterID + "'");

                    //Send title update to send list
                    Send(Packet.GuildSetTitle(Character.Guild.GuildID, playerinfo.Character.Information.Name, Title));

                    //Send Final packet to client
                    client.Send(Packet.GuildSetTitle2(Character.Guild.GuildID, Selecteduser, Title));
                }
                foreach (int member in Character.Network.Guild.Members)
                {
                    if (member != 0)
                    {
                        Systems getplayer = GetPlayerMainid(member);
                        if (getplayer != null)
                        {
                            getplayer.LoadPlayerGuildInfo(false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild Title Error: {0}", ex);
                Log.Exception(ex);
            }
        }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:46,代码来源:Guild.cs

示例3: GuildRemove

        void GuildRemove()
        {
            //Wrap our function inside a catcher
            try
            {
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                short UserL = Reader.Int16();
                string User = Reader.String(UserL);
                Reader.Close();

                //Define new count for database check

                //Get player information
                Systems sys = GetPlayerName(User);

                //Send required packets to network
                foreach (int member in Character.Network.Guild.Members)
                {
                    //Make sure member s not null
                    if (member != 0)
                    {
                        //Get information for the guildmember
                        Systems guildmember = GetPlayerMainid(member);
                        //Make sure the guildmember isnt null
                        if (guildmember != null)
                        {
                            //Make sure the kicked member does not receive the packet
                            if (guildmember.Character.Information.CharacterID != sys.Character.Information.CharacterID)
                            {
                                //Bool check single send packet
                                if (!guildmember.Character.Network.Guild.SingleSend)
                                {
                                    //Send update packet
                                    guildmember.client.Send(Packet.GuildUpdate(sys.Character, 7, 0, 0, 0));
                                    guildmember.Character.Network.Guild.SingleSend = true;

                                }
                            }
                        }
                    }
                }
                //Send update packet to the kicked player
                sys.client.Send(Packet.GuildUpdate(sys.Character, 7, 0, 0, 0));
                sys.client.Send(Packet.GuildKickMsg());
                sys.Send(Packet.GuildKick(sys.Character.Information.UniqueID));

                //Minus 1 count for new database info
                int getmembercount = Convert.ToInt32(DB.GetData("SELECT guild_members_t FROM guild WHERE guild_name='" + Character.Network.Guild.Name + "'", "guild_members_t"));
                int newmembercount = getmembercount - 1;

                //Update database
                DB.query("UPDATE guild SET guild_members_t='" + newmembercount + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");

                //Remove the player from database
                DB.query("DELETE from guild_members where guild_member_id='" + sys.Character.Information.CharacterID + "'");

                //Disable bool
                foreach (int member in Character.Network.Guild.Members)
                {
                    if (member != 0)
                    {
                        Systems guildmember = GetPlayerMainid(member);
                        if (guildmember != null)
                        {
                            guildmember.LoadPlayerGuildInfo(false);
                            guildmember.Character.Network.Guild.SingleSend = false;
                        }
                    }
                }

                //Final updates
                if (Character.Network.Guild.UniqueUnion != 0)
                {
                    Character.Network.Guild.UnionActive = false;
                    Character.Network.Guild.UnionMembers.Remove(Character.Information.CharacterID);
                }

                Character.Network.Guild.Members.Remove(sys.Character.Information.UniqueID);
                Character.Network.Guild.MembersClient.Remove(sys.client);

                sys.Character.Network.Guild.Guildid = 0;

            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild Kick Error: {0}", ex);
                Log.Exception(ex);
            }
        }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:90,代码来源:Guild.cs

示例4: GuildMessage

        void GuildMessage()
        {
            //Wrap our function inside a catcher
            try
            {
                //Start reading packet data
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                short TitleL = Reader.Int16();
                string Title = Reader.String(TitleL);
                short MessageL = Reader.Int16();
                string Message = Reader.String(MessageL);
                Reader.Close();

                //Update database guild message title
                DB.query("UPDATE guild SET guild_news_t='" + Title + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");

                //Update database guild message
                DB.query("UPDATE guild SET guild_news_m='" + Message + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
                //Set new message info to current member for sending packet update.
                Character.Network.Guild.NewsTitle = Title;
                Character.Network.Guild.NewsMessage = Message;
                //Send news update to all members currently online
                Character.Network.Guild.Send(Packet.GuildUpdate(Character, 11, 0, 0, 0));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild Message Error: {0}", ex);
                Log.Exception(ex);
            }
        }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:30,代码来源:Guild.cs

示例5: GuildInvite

 void GuildInvite()
 {
     //Wrap our code into a catcher
     try
     {
         //Open our packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         Int16 dLen = Reader.Int16();
         string invitename = Reader.String(dLen);
         Reader.Close();
         //Get information for target
         Systems sys = GetPlayerName(invitename);
         //Set targetid information
         Character.Network.TargetID = sys.Character.Information.UniqueID;
         //If player allready has a guild
         if (sys.Character.Network.Guild.Guildid != 0)
         {
             //Add message here
             return;
         }
         //Set targetid to the invited player
         sys.Character.Network.TargetID = Character.Information.UniqueID;
         //Send guild request packet
         sys.client.Send(Packet.P_Request(5, Character.Information.UniqueID, 0));
         //Set bools active
         Character.State.GuildInvite = true;
         sys.Character.State.GuildInvite = true;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Guild invite error {0}", ex);
         Log.Exception(ex);
     }
 }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:34,代码来源:Guild.cs

示例6: GuildCreate

        void GuildCreate()
        {
            try
            {
                //Extra check if user is allready in guild.
                if (Character.Network.Guild.Guildid != 0) return;

                //Read client packet ObjData.Manager.
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                int infoid = Reader.Int32();
                short guildname = Reader.Int16();
                string guildnameinfo = Reader.String(guildname);
                string charactername = Character.Information.Name;
                Reader.Close();
                //Will write global class for special chars later.
                if (guildnameinfo.Contains("[")) return;
                if (guildnameinfo.Contains("]")) return;
                if (guildnameinfo.Contains("(")) return;
                if (guildnameinfo.Contains(")")) return;
                if (guildnameinfo.Contains("@")) return;
                if (guildnameinfo.Contains("#")) return;
                if (guildnameinfo.Contains("$")) return;
                if (guildnameinfo.Contains("^")) return;
                if (guildnameinfo.Contains("&")) return;
                if (guildnameinfo.Contains("*")) return;
                if (guildnameinfo.Contains("+")) return;
                if (guildnameinfo.Contains("=")) return;
                if (guildnameinfo.Contains("~")) return;
                if (guildnameinfo.Contains("`")) return;
                //Check length lower are 4 return
                if (guildnameinfo.Length < 4) return;
                //Check if guild name is taken or not.
                int guildcheckname = DB.GetRowsCount("SELECT * FROM guild WHERE guild_name='" + guildnameinfo + "'");
                //If name excists
                if (guildcheckname == 1)
                {
                    //Need to sniff packet
                    return;
                }
                //Set the gold requirements 500.000 retail info
                int goldrequired = 500000;

                //If character level is to low
                if (Character.Information.Level < 20)
                {
                    client.Send(Packet.GuildCreateLow());
                    return;
                }

                //If gold is lower then price of creating a guild
                else if (Character.Information.Gold < goldrequired)
                {
                    client.Send(Packet.ErrorMsg(SERVER_GUILD, ErrorMsg.UIIT_MSG_GUILDERR_NOT_ENOUGH_GOLD));
                    return;
                }

                //All checks ok, continue creating new guild.
                else
                {
                    //Reduct the gold required from player gold
                    Character.Information.Gold -= goldrequired;

                    //Save player information
                    SavePlayerInfo();

                    //Insert guild into database
                    DB.query("INSERT INTO guild (guild_name, guild_level, guild_points, guild_news_t, guild_news_m, guild_members_t, guild_master_id) VALUES ('" + guildnameinfo + "','1','0','" + "" + "','" + "" + "','1','" + Character.Information.CharacterID + "')");

                    //Get guild id
                    string guildid = DB.GetData("SELECT id FROM guild WHERE guild_name='" + guildnameinfo + "'", "id");
                    int docount = Convert.ToInt32(guildid);

                    //Insert member into database
                    DB.query("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + docount + "','" + Character.Information.CharacterID + "','0','0','1','','1','1','1','1','1')");

                    //Load our new guild
                    LoadPlayerGuildInfo(false);

                    //Private packet
                    client.Send(Packet.Guild_Create(Character.Network.Guild));

                    //Public spawn packet
                    Send(Packet.SendGuildInfo2(Character));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:90,代码来源:Guild.cs


注:本文中的PacketReader.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。