String() public méthode

public String ( int len ) : string
len int
Résultat string
Exemple #1
0
        void GuildMessage()
        {
            //Wrap our function inside a catcher
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read short int16 for title lenght
                short TitleL = Reader.Int16();
                //Read string for title
                string Title = Reader.String(TitleL);
                //Read short Message lenght
                short MessageL = Reader.Int16();
                //Read message
                string Message = Reader.String(MessageL);
                //Close reader
                Reader.Close();

                //Update database guild message title and message
                MsSQL.InsertData("UPDATE guild SET guild_news_t='" + Title + "',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;
                //Repeat for each member in our guild
                foreach (int member in Character.Network.Guild.Members)
                {
                    //Make sure the member is there
                    if (member != 0)
                    {
                        //Get detailed information from member main id
                        Systems characterinformation = GetPlayerid(member);
                        //Set the current member news title and message information
                        characterinformation.Character.Network.Guild.NewsMessage = Message;
                        characterinformation.Character.Network.Guild.NewsTitle = Title;
                        //Send packet to the member to update guild message.
                        characterinformation.client.Send(Packet.GuildUpdate(characterinformation.Character, 11, 0, 0, 0));
                    }
                }
            }
            //Catch any bad exception error
            catch (Exception ex)
            {
                //Write error to the console
                Console.WriteLine("Guild Message Error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Exemple #2
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Create Job Alias
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void MakeAlias()
 {
     try
     {
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         int id = Reader.Int32();
         byte type = Reader.Byte();
         short nLenght = Reader.Int16();
         string name = Reader.String(nLenght);
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         Console.WriteLine(name);
         MsSQL ms = new MsSQL("SELECT * FROM character_jobs WHERE job_alias='" + name + "'");
         int checkjob = ms.Count();
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         client.Send(Packet.MakeAlias(name, type));
         if (checkjob == 0)
         {
             client.Send(Packet.MakeAlias(name, type));
             MsSQL.UpdateData("UPDATE character_jobs SET job_alias='" + name + "' WHERE character_name='" + Character.Information.Name + "'");
         }
         else if (checkjob >= 0)
         {
             client.Send(Packet.MakeAliasError(name, type));
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Exemple #3
0
 /////////////////////////////////////////////////////////////////////////////////
 // Add new friend
 /////////////////////////////////////////////////////////////////////////////////
 void FriendAdd()
 {
     try
     {
         PacketReader reader = new PacketReader(PacketInformation.buffer);
         short namelenght = reader.Int16();
         string name = reader.String(namelenght);
         reader.Close();
         if (name == Character.Information.Name) return;
         Systems sys = GetPlayerName(name);
         if (sys != null)
         {
             sys.client.Send(Packet.FriendInviteTarget(sys.Character));
         }
         else
         {
             //Packet cannot find user
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Friend Add error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Exemple #4
0
 void GuildInvite()
 {
     //Wrap our code into a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read lenght of invited character name
         Int16 InvitedCharacterLEN = Reader.Int16();
         //Read invited character name
         string InvitedCharacter = Reader.String(InvitedCharacterLEN);
         //Close packet reader
         Reader.Close();
         //Get information for target
         Systems sys = GetPlayerName(InvitedCharacter);
         //Set targetid information
         Character.Network.TargetID = sys.Character.Information.UniqueID;
         //If player allready has a guild
         if (sys.Character.Network.Guild.Guildid != 0)
         {
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_MEMBER_OF_ANOTHER_GUILD));
             return;
         }
         //If player has to wait before the player can join another guild
         if (sys.Character.Information.JoinGuildWait)
         {
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILD_PENALTY));
             return;
         }
         //If the guild has max members
         if (Character.Network.Guild.TotalMembers >= Character.Network.Guild.MaxMembers)
         {
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_MEMBER_FULL));
         }
         //If the character doesnt have join rights
         if (!Character.Network.Guild.joinRight)
         {
             //This should not happen unless hack attempt, because button should be grayed out
             return;
         }
         //Set targetid to the invited player
         sys.Character.Network.TargetID = this.Character.Information.UniqueID;
         //Send guild request packet
         sys.client.Send(Packet.PartyRequest(5, this.Character.Information.UniqueID, 0));
         //Set bools active
         Character.State.GuildInvite = true;
         sys.Character.State.GuildInvite = true;
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Guild invite error {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
Exemple #5
0
 void CharacterJobPick(byte[] buff)
 {
     //Wrap our function inside a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(buff);
         //Skip first byte not used
         Reader.Skip(1);
         //Read name lenght
         short CharacterNameLEN = Reader.Int16();
         //Read character name
         string CharacterName = Reader.String(CharacterNameLEN);
         //Read job selection
         byte job = Reader.Byte();
         //Close packet reader
         Reader.Close();
         //Get row count from character to check if the current account and character match
         int NameCheck = MsSQL.GetRowsCount("SELECT * FROM character WHERE account='" + Player.AccountName + "'");
         //Get job information from database as integer
         int jobcheck = MsSQL.GetDataInt("SELECT jobtype FROM users WHERE id='" + Player.AccountName + "'", "jobtype");
         //If the name check is succesfull and account has no job set.
         if (jobcheck == 0 && NameCheck != 0)
         {
             //Write new job information to the database
             MsSQL.UpdateData("UPDATE users SET jobtype='" + job + "' WHERE id='" + Player.AccountName + "'");
         }
         //Send visual confirmation in packet
         PacketWriter writer = new PacketWriter();
         //Add opcode
         writer.Create(Systems.SERVER_CHARACTERSCREEN);
         //Write static byte 10
         writer.Byte(0x10);
         //Write succes byte 1
         writer.Byte(1);
         //Send bytes to client
         client.Send(writer.GetBytes());
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write error information to the console
         Console.WriteLine("Job selection error {0}", ex);
         //Write error to debug log file
         Systems.Debugger.Write(ex);
     }
 }
Exemple #6
0
 void GuildTitle()
 {
     //Wrap our function inside a catcher
     try
     {
         //Extra hack check
         if (Character.Network.Guild.Level < 4)
             return;
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read integer guild member selected
         int SelectedGuildMember = Reader.Int32();
         //Read short lenght of title for guild member
         short GuildMemberTitleLEN = Reader.Int16();
         //Read string guild member title
         string GuildMemberTitle = Reader.String(GuildMemberTitleLEN);
         //Close packet reader
         Reader.Close();
         //Get selected guild member information
         Systems playerinfo = GetPlayerMainid(SelectedGuildMember);
         //Make sure the character is still there
         if (playerinfo.Character != null)
         {
             //Update database set new title
             MsSQL.InsertData("UPDATE guild_members SET guild_grant='" + GuildMemberTitle + "' WHERE guild_member_id='" + playerinfo.Character.Information.CharacterID + "'");
             //Send new character guild title update to each player in spawn reach
             Send(Packet.GuildSetTitle(Character.Guild.GuildID, playerinfo.Character.Information.Name, GuildMemberTitle));
             //Send Final packet to client
             playerinfo.client.Send(Packet.GuildSetTitle2(Character.Guild.GuildID, SelectedGuildMember, GuildMemberTitle));
         }
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Guild Title Error: {0}", ex);
         //Write information to debug log
         Systems.Debugger.Write(ex);
     }
 }
Exemple #7
0
 void GuildCreate()
 {
     try
     {
         //Extra check if user is allready in guild.
         if (Character.Network.Guild.Guildid != 0) return;
         //If player has recently been in a guild
         if (Character.Information.JoinGuildWait)
         {
             //Need to sniff the retail packet (Tmp used guild war error).
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDWARERR_GUILD_CREATE_PENALTY));
             return;
         }
         //Create new packet reader for reading information
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //None needed integer
         int notneeded = Reader.Int32();
         //Get guild name lenght
         short GuildNameLen = Reader.Int16();
         //Get guild name
         string GuildName = Reader.String(GuildNameLen);
         //Close packet reader
         Reader.Close();
         //Remove bad characters from guildname
         GuildName = Removebadchars(GuildName);
         //Check length lower are 4 return
         if (GuildName.Length < 4)
         {
             //Send incorrect lenght
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_INVALID_GUILDNAME_LEN));
             return;
         }
         //Check if guild name is taken or not.
         int guildcheckname = MsSQL.GetRowsCount("SELECT * FROM guild WHERE guild_name='" + GuildName + "'");
         //If name excists
         if (guildcheckname == 1)
         {
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_GUILDERR_SAME_GUILDNAME_EXIST));
             return;
         }
         //If character level is to low
         if (Character.Information.Level < 20)
         {
             //Send packet level to low message
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_TOO_LOW_CREATOR_LEVEL));
             return;
         }
         //Set the gold requirements 500.000 retail info
         int goldrequired = 500000;
         //If gold is lower then price of creating a guild
         if (Character.Information.Gold < goldrequired)
         {
             //Send message not enough gold
             client.Send(Packet.IngameMessages(SERVER_GUILD, IngameMessages.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
             MsSQL.InsertData("INSERT INTO guild (guild_name, guild_level, guild_points, guild_news_t, guild_news_m, guild_members_t, guild_master_id) VALUES ('" + GuildName + "','1','0','" + "" + "','" + "" + "','1','" + Character.Information.CharacterID + "')");
             //Get guild id
             string guildid = MsSQL.GetData("SELECT id FROM guild WHERE guild_name='" + GuildName + "'", "id");
             int docount = Convert.ToInt32(guildid);
             //Insert member into database
             MsSQL.InsertData("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(true);
             //Private packet
             client.Send(Packet.Guild_Create(Character.Network.Guild));
             //Public spawn packet
             Send(Packet.SendGuildInfo2(this.Character));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Guild creation error: " + ex);
         Systems.Debugger.Write(ex);
     }
 }
Exemple #8
0
        public void RequestIcons()
        {
            PacketReader Reader = new PacketReader(PacketInformation.buffer);
            byte IconType = Reader.Byte();
            short IconHexLenght = Reader.Int16();
            string Icon = Reader.String(IconHexLenght);
            Reader.Close();
            //Need to figure out the string.. identification of the icon probably
            client.Send(Packet.IconSend(IconType, Icon));

            // Below is sniffed data
            /*
             * [S -> C][2114]
                01                                                Byte = Type icon (1 = Guild 2 = union).
                1C 01                                             Lenght of hex icon string

                // below is the hex string (Ascii) icon
                74 6D 28 73 81 2A 47 37 F6 13 99 62 8C 3F 4E 29   tm(s.*G7...b.?N)
                0F 04 CB 3D E6 5F FC 0B D6 07 03 DD 0D 72 9A 25   ...=._.......r.%
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                8A 88 BF CB 59 5A 8A 08 74 80 32 53 AA 1C 5E 86   ....YZ..t.2S..^.
                FE DC BA 98 76 54 32 10 0F 1E 2D 3C               ....vT2...-<....

                [C -> S][2114]
                02                                                ................
                0C 00                                             ................
                AE A5 BF 3C 23 65 0C 01 03 1E 27 3C               ...<#e....'<....
             */

            /*
            (Nukei)Discovered so far:
            client requests image by contacting 121.128.134.16 (gdmark.joymax.com) using HTTP protocol over port 15080
            like:
               http://gdmark.joymax.com:15080/SRO_CREST/A96_2132_1.crb (this files is saved in sro-client's RD folder as A96_2132.rd converted to BMP format)

            the returned header indicates, that the returned content is 256 Bytes in size (16 x 16 = 256).  the given type is "application".

            ToDo:
            1.	Why or when the client starts this request for images ?
            2.	Is the returned array of bytes 16x16 palette entries ?
            3.	if 2 is right, what palette is used ?

            Result:
            1. dont know :-P
            2. Yes, we get a paletted image in 16x16 size (without palette, without size, RAW pixel), so every byte is one pixel. pay attention that the Y coordinates are reversed, so the image is bottom up.
            3. discovered that it is the windows system palette !!

             * I dont know if the image really is transfered with 2114 packet !!!

            Tools used: PhotoShop, Wireshark, WinHex
             */
            /*Xsense:
             * Result:
             * 1. I believe send on guild name spawn by 1 byte indication active non active.
             * 1. Simple check would be a bool from database on creation of icon set to true,
             * 1. Deletion item / guild disband / union kick / leave would remove the bool information from db.
             * 2. Indexed color 8 bit setting. (Change extension to bmp / checked photoshop indications).
             * 3.
             * 4. RD should be cache folder, which server could check from registry path to see excisting icons.
             */

            /*
             (Rokky93) Discovered:

            I search a bit about CREST System of Joymax and found an interesting blog.So now i will tell you my results:

            1. Silkroad stores Guild Icons on a stand-alone FTP Server. You can find them in the Media.pk2/type.txt
            2. For example A96_2132_1.crb:
                A - type(Guild or Alliance)
                96- Server ID
                2132 - guild id
                1 - crest id

            When we want to convert it to bmp:
            1. Silkroad uses 16x16 pixel big 8bbp bitmaps with static color palette and no compression. The stored crests are 256B big.
            2. BMP Structure:
                header - static
                meta - static
                palette - static
                bitmap (crest file content) - dynamic

            When we want to send icons to Client
            1. We have to change the FTP Server in the Media.pk2
            2. We must send this packet to Client
                byte - type(alliance, guild) 00 or 01
                dword - guildid
                string - guildname
               dword - crestindex

               For example:
               type                 G
               serverId          187
               guildId             2929
               crestid             3

               Client makes this : G187_2929_3.crb and download them from server ( this is my  theory)

            GET /SRO_CREST/A239_282_3.crb HTTP/1.1
            Accept-Encoding: gzip, deflate
            User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
            Host: gdmark.joymax.com:15080
            Connection: Keep-Alive
            */
        }
Exemple #9
0
        void KickFromGuild()
        {
            //Wrap our function inside a catcher
            try
            {
                //Open a new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read short value lenght of name below
                short CharacterNameLen = Reader.Int16();
                //Read string charactername
                string CharacterName = Reader.String(CharacterNameLen);
                //Close packet reader
                Reader.Close();
                //Get player information
                Systems TargetCharacter = GetPlayerName(CharacterName);
                //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 != TargetCharacter.Character.Information.CharacterID)
                            {
                                guildmember.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
                            }
                        }
                    }
                }
                //Send update packet to the kicked player
                TargetCharacter.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
                //Send guild kick message packet to the kicked player
                PacketWriter Writer = new PacketWriter();
                //Add opcode
                Writer.Create(Systems.SERVER_GUILD_KICK);
                //Add static byte 1
                Writer.Byte(1);
                //Send packet to kicked member
                TargetCharacter.client.Send(Writer.GetBytes());
                //Send guildkick visual packet update to kicked player
                TargetCharacter.Send(Packet.GuildKick(TargetCharacter.Character.Information.UniqueID));
                //Remove the player from database
                MsSQL.UpdateData("DELETE from guild_members where guild_member_id='" + TargetCharacter.Character.Information.CharacterID + "'");
                //Update database
                Character.Network.Guild.TotalMembers -= 1;
                MsSQL.InsertData("UPDATE guild SET guild_members_t='" + Character.Network.Guild.TotalMembers + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
                TargetCharacter.CleanUp(TargetCharacter);

            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write information to the console
                Console.WriteLine("Guild Kick Error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Exemple #10
0
 void PrivateMessageSend()
 {
     try
     {
         //Create new packet reader for reading packet data
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read lenght of charactername we send the message to
         short ToCharacterLen = Reader.Int16();
         //Read the name of the character we send the message to
         string ToCharacter = Reader.String(ToCharacterLen);
         //Read lenght of message characters
         short MessageLen = Reader.Int16();
         //Read message
         string Message = Reader.String(MessageLen);
         //Close packet reader
         Reader.Close();
         //Create new mssql query for sending and checking
         MsSQL ms = new MsSQL("SELECT * FROM character WHERE name='" + ToCharacter + "'");
         //Check if the player exists
         int PlayerExists = ms.Count();
         //If the player exists
         if (PlayerExists > 0)
         {
             //First get details of the player we send the message to.
             Systems sys = GetPlayerName(ToCharacter);
             //Make sure we dont get a null error
             if (sys.Character != null)
             {
                 //Check how many messages the player has if inbox is full or not
                 int TargetMessageCount = MsSQL.GetRowsCount("SELECT * FROM message WHERE receiver='" + sys.Character.Information.CharacterID + "'");
                 //If less then 50 we continue
                 if (TargetMessageCount < 50)
                 {
                     //Set temp int to character data for new message order
                     sys.Character.Information.MessageCount = TargetMessageCount;
                     //Insert new message into the database
                     MsSQL.InsertData("INSERT INTO message (sender, receiver, message, status, time) VALUES ('" + Character.Information.Name + "','" + ToCharacter + "','" + Message + "','0','" + DateTime.Now + "')");
                     //Send packet message has been send to our client
                     client.Send(PrivateMessageRespond(2));
                     //Send packet to receiver information new message has arrived
                     sys.Send(Packet.FriendData(sys.Character.Information.UniqueID, 5, ToCharacter, Character, false));
                 }
                 //If inbox is full
                 else
                 {
                     //Send message to sender and receiver inbox full
                     client.Send(PrivateMessageRespond(3));
                     sys.client.Send(PrivateMessageRespond(3));
                 }
             }
         }
         //If player doesn't exist
         else
         {
             //Send packet message failed to send to our client.
             client.Send(PrivateMessageRespond(1));
         }
     }
     //Catch any bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Error sending messages : {0}" + ex);
         //Write info to the debug logger.
         Systems.Debugger.Write(ex);
     }
 }
Exemple #11
0
 ///////////////////////////////////////////////////////////////////////////
 // Rename grab pet
 ///////////////////////////////////////////////////////////////////////////
 void RenamePet()
 {
     try
     {
         //Start reading packet data
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Pet id
         int petid           = Reader.Int32();
         //Pet name lenght
         short petnamel      = Reader.Int16();
         //Pet name
         string petname      = Reader.String(petnamel);
         //Check availability for pet name.
         int nameavailable   = MsSQL.GetRowsCount("SELECT pet_name FROM pets WHERE pet_name='" + petname + "'");
         //If available (Row count is zero).
         if (nameavailable == 0)
         {
             //Create the query we will use
             MsSQL ms = new MsSQL("SELECT * FROM pets WHERE playerid='" + Character.Information.CharacterID + "' AND pet_unique='" + petid + "'");
             //Open our data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //While the reader is reading from database
                 while (reader.Read())
                 {
                     //First we check the lenght of the name.
                     if (petnamel < 3)
                     {
                         client.Send(Packet.IngameMessages(SERVER_PET_RENAME_MSG, IngameMessages.UIIT_MSG_COSPETERR_PETNAME_NOTPUT));
                     }
                     //Check if renamed allready. (Should not be needed just extra check)
                     if (Character.Grabpet.Details != null)
                     {
                         if (petid == Character.Grabpet.Details.UniqueID)
                         {
                             if (Character.Grabpet.Details.Petname == "No name")
                             {
                                 //Update name in database
                                 MsSQL.UpdateData("UPDATE pets SET pet_state='2',pet_name='" + petname + "' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'");
                                 //Send needed packets to update name (Official sends 2 times)...
                                 client.Send(Packet.PetSpawn(petid, 2, Character.Grabpet.Details));
                                 //Send to all currently in spawn range
                                 Send(Packet.PetSpawn(petid, 2, Character.Grabpet.Details));
                             }
                         }
                     }
                     //Check if renamed allready. (Should not be needed just extra check)
                     if (Character.Attackpet.Details != null)
                     {
                         if (petid == Character.Attackpet.Details.UniqueID)
                         {
                             if (Character.Attackpet.Details.Petname == "No name")
                             {
                                 //Update name in database
                                 MsSQL.UpdateData("UPDATE pets SET pet_state='2',pet_name='" + petname + "' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'");
                                 //Send needed packets to update name (Official sends 2 times)...
                                 client.Send(Packet.PetSpawn(petid, 2, Character.Attackpet.Details));
                                 //Send to all currently in spawn range
                                 Send(Packet.PetSpawn(petid, 2, Character.Attackpet.Details));
                             }
                         }
                     }
                 }
             }
         }
         //If name has been taken
         else
         {
             //Not sure if correct msg.
             client.Send(Packet.IngameMessages(SERVER_PET_RENAME_MSG, IngameMessages.UIIT_MSG_COSPETERR_PETNAME_NOTPUT));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Grab pet renaming error : " + ex);
     }
 }
Exemple #12
0
 // only for buffs now
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // GM Skill
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void GM_SKILL()
 {
     PacketReader reader = new PacketReader(PacketInformation.buffer);
     short ignore = reader.Int16();
     short skilllenght = reader.Int16();
     string skill = reader.String(skilllenght);
     Character.Action.UsingSkillID = Convert.ToInt32(skill);
     SkillBuff();
 }