Example #1
0
        public static byte[] AttackPetStats(pet_obj c, byte slot)
        {
            PacketWriter writer = new PacketWriter();

            writer.Create(Systems.SERVER_PET_INFORMATION);
            writer.DWord(c.UniqueID);
            writer.DWord(c.Model);
            writer.DWord(0x00000168); //stats
            writer.DWord(0x00000168); //stats
            writer.LWord(c.exp);      //Experience
            writer.Byte(c.Level);     //Level
            writer.Word(0);           //Angle
            writer.DWord(0x00000001); //1 = Attack icon enabled, 2 = disabled
            if (c.Petname != "No name")
            {
                writer.Text(c.Petname);                        //Petname
            }
            else
            {
                writer.Word(0);      //No name
            }
            writer.Byte(0);          //Static perhaps
            writer.DWord(c.OwnerID); //Owner
            writer.Byte(slot);
            return(writer.GetBytes());
        }
Example #2
0
        ///////////////////////////////////////////////////////////////////////////
        // Despawn Pet
        ///////////////////////////////////////////////////////////////////////////
        public static byte[] PetSpawn(int petid, byte type, pet_obj o)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_PLAYER_SPAWN_PET);   //Select Opcode
            Writer.DWord(petid);                              //Pet ID
            switch (type)
            {
            case 1:
                //Despawn pet
                Writer.Byte(1);
                break;

            case 2:
                //Rename pet respawn
                Writer.Byte(5);
                Writer.Text(o.Petname);
                break;

            case 3:
                //Attack pet respawn for exp info
                Writer.Byte(3);          //Static
                Writer.LWord(o.exp);     //New exp
                Writer.DWord(o.OwnerID); //Owner id
                break;
            }
            return(Writer.GetBytes());
        }
Example #3
0
        public static byte[] SendGuildInfo(guild guildGlobal)
        {
            PacketWriter Writer = new PacketWriter();

            /////////////////////////////////////////////////////////////////////////
            //Opcode information
            /////////////////////////////////////////////////////////////////////////
            Writer.Create(Systems.SERVER_GUILD_INFO_LOAD);
            /////////////////////////////////////////////////////////////////////////
            //Packet Structure
            /////////////////////////////////////////////////////////////////////////
            //Writer.Byte(1); // Guild update
            Writer.DWord(guildGlobal.Guildid);              // Unique Guild ID
            Writer.Text(guildGlobal.Name);                  // Guild Name
            Writer.Byte(guildGlobal.Level);                 // Guild level
            Writer.DWord(guildGlobal.PointsTotal);          // Guild GP
            Writer.Word(guildGlobal.NewsTitle.Length);      // Guild Message Title Lenght
            Writer.String(guildGlobal.NewsTitle);           // Guild Message Title
            Writer.Word(guildGlobal.NewsMessage.Length);    // Guild Message Lenght
            Writer.String(guildGlobal.NewsMessage);         // Guild Message
            Writer.DWord(0);                                // War on guild id
            Writer.Byte(0);                                 // War status?
            /////////////////////////////////////////////////////////////////////////
            // Write Guild Member information for each excisting member.
            /////////////////////////////////////////////////////////////////////////
            Guild_ListPlayersInfo(guildGlobal.MembersInfo, Writer);
            Writer.Byte(0);
            return(Writer.GetBytes());
        }
Example #4
0
        public static byte[] RankListsDonateHunter()
        {
            Systems.MsSQL ms        = new Systems.MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='2'");
            PacketWriter  Writer    = new PacketWriter();
            int           countinfo = ms.Count();
            int           i         = 0;

            Writer.Create(Systems.SERVER_RANK_LISTS);
            Writer.Byte(1);
            Writer.Byte(3);
            Writer.Byte(1);
            Writer.Byte(Convert.ToByte(countinfo));

            using (SqlDataReader reader = ms.Read())
            {
                for (i = 0; i < countinfo;)
                {
                    while (reader.Read())
                    {
                        byte   rank   = reader.GetByte(2);
                        string name   = reader.GetString(3);
                        byte   level  = reader.GetByte(4);
                        int    donate = reader.GetInt32(5);

                        Writer.Byte(rank);
                        Writer.Text(name);
                        Writer.Byte(level);
                        Writer.DWord(donate);
                        i++;
                    }
                }
                ms.Close();
            }
            return(Writer.GetBytes());
        }
Example #5
0
        public static byte[] IconSend(byte type, string icon)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ICON_SEND);
            Writer.Byte(type);
            Writer.Text(icon);
            return(Writer.GetBytes());
        }
Example #6
0
        public static byte[] AgentServer()
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_AGENTSERVER);
            Writer.Text("AgentServer");
            Writer.Bool(true);
            return(Writer.GetBytes());
        }
Example #7
0
        public static byte[] HonorRank(character c)
        {
            Systems.MsSQL ms        = new Systems.MsSQL("SELECT * FROM rank_honor");
            PacketWriter  Writer    = new PacketWriter();
            int           countinfo = ms.Count();

            Writer.Create(Systems.SERVER_HONOR_RANK);
            Writer.Byte(1);
            int i = 0;

            Writer.Byte(Convert.ToByte(countinfo));
            using (SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    byte   rankicon   = reader.GetByte(1);
                    string rankname   = reader.GetString(2);
                    byte   ranklevel  = reader.GetByte(3);
                    byte   ranklevelc = reader.GetByte(4);
                    int    graduatesc = reader.GetInt32(5);
                    int    rankposc   = reader.GetInt32(6);

                    Writer.DWord(i + 1);
                    Writer.Byte(rankicon);
                    Writer.Text(rankname);
                    Writer.Byte(ranklevel);
                    Writer.Byte(ranklevelc);
                    Writer.DWord(graduatesc);
                    //If player has no guild, we write a 0 word value
                    if (c.Network.Guild.Name == null)
                    {
                        Writer.Word(0);
                    }
                    //If player has a guild we write the guild name.
                    else
                    {
                        Writer.Text(c.Network.Guild.Name);
                    }
                    i++;
                }
                ms.Close();
            }
            return(Writer.GetBytes());
        }
Example #8
0
 void PrivateMessageOpen()
 {
     try
     {
         //Create new packet reader for reading packet information
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Create new packetwriter for writing our packet
         PacketWriter Writer = new PacketWriter();
         //Read selected message id from packet
         byte SelectedMessageID = Reader.Byte();
         //Close packet reader
         Reader.Close();
         //Create new mssql query for getting the messages
         Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM message WHERE receiver='" + Character.Information.Name + "' ORDER BY time DESC");
         //Create new integer for calculating what message must be selected.
         int Messageid = -1;
         //Create new sql data reader for reading column information
         using (SqlDataReader reader = ms.Read())
         {
             //While our sql data reader is reading
             while (reader.Read())
             {
                 //Read message content
                 string MessageContent = reader.GetString(3);
                 //Increase our message id integer
                 Messageid += 1;
                 //Check if the messageid equals to our selected message
                 if (Messageid == SelectedMessageID)
                 {
                     //Add opcode to packet
                     Writer.Create(Systems.SERVER_PM_OPEN);
                     //Write static byte
                     Writer.Byte(1);
                     //Write byte selected message id
                     Writer.Byte(SelectedMessageID);
                     //Write text message content
                     Writer.Text(MessageContent);
                     //Send packet to client
                     client.Send(Writer.GetBytes());
                     //Update message state to read in database
                     MsSQL.UpdateData("UPDATE message SET status='1' WHERE receiver='" + Character.Information.Name + "' AND message ='" + MessageContent + "'");
                 }
             }
         }
         //Close mssql
         ms.Close();
     }
     //If an error accures we catch it here
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Error PrivateMessages.cs : {0}" + ex);
         //Write information to the debug logger
         Systems.Debugger.Write(ex);
     }
 }
Example #9
0
        public static byte[] FriendInviteTarget(character c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_FRIEND_INVITE_SEND);
            Writer.DWord(c.Information.CharacterID);
            Writer.DWord(c.Information.UniqueID);
            Writer.Text(c.Information.Name);
            return(Writer.GetBytes());
        }
Example #10
0
        public static byte[] SendWebMall(int Myid)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ITEM_MALL_WEB);
            Writer.Byte(1);
            Writer.DWord(Myid);                        //Account ID for silk check
            Writer.Text("http://www.xfsgames.com.ar"); //url need to check
            return(Writer.GetBytes());
        }
Example #11
0
        public static byte[] MakeAliasError(string name, byte switchinfo)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_MAKE_ALIAS);
            Writer.Byte(2);
            Writer.Word(0);
            Writer.Byte(0);
            Writer.Text(name);
            return(Writer.GetBytes());
        }
Example #12
0
        public static byte[] FriendDecline(string name)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_FRIEND_INVITE);
            Writer.Byte(2);
            Writer.Word(0x640B);
            Writer.Byte(0);
            Writer.Word(0x000B);
            Writer.Text(name);
            return(Writer.GetBytes());
        }
Example #13
0
        public static byte[] FriendData(int target, byte type, string name, character c, bool state)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_FRIEND_DATA);
            switch (type)
            {
            case 2:
                //Friend invite accepted
                Writer.Byte(2);
                Writer.DWord(target);              //Id
                Writer.Text(c.Information.Name);   //Name
                Writer.DWord(c.Information.Model); //Model
                break;

            case 3:
                //Remove friend from own list
                Writer.Byte(3);
                Writer.DWord(target);
                break;

            case 4:
                //Fried online / offline update
                Writer.Byte(4);
                Writer.DWord(target);
                Writer.Byte(state);
                break;

            case 5:
                //Send private message..
                Writer.Byte(8);
                Writer.Text(name);
                Writer.DWord(0);
                Writer.DWord(0);    //time info
                break;
            }
            return(Writer.GetBytes());
        }
Example #14
0
        ///////////////////////////////////////////////////////////////////////////
        // Grab pet information packet
        ///////////////////////////////////////////////////////////////////////////
        public static byte[] Pet_Information_grab(pet_obj o, byte slot)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_PET_INFORMATION);
            try
            {
                //////////////////////////////////////////////////////////////////////////////////////
                // Grabpet structure
                //////////////////////////////////////////////////////////////////////////////////////
                Writer.DWord(o.UniqueID);                   //Unique ID
                Writer.DWord(o.Model);                      //Pet Model
                Writer.DWord(0x00006D);                     //Settings
                Writer.DWord(0x00006D);                     //Settings
                Writer.DWord(0x000047);                     //Settings 0x47 grab pet active 0 disabled
                if (o.Petname != "No name")                 //###############
                {
                    Writer.Text(o.Petname);                 // Name region
                }
                else                                        //
                {
                    Writer.Word(0);                         //###############
                }
                Writer.Byte(o.Slots);                       //Slots count inventory pet
                //////////////////////////////////////////////////////////////////////////////////////
                // Grabpet item inventory
                //////////////////////////////////////////////////////////////////////////////////////
                Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + o.OwnerID + "' AND pet_storage_id='" + o.UniqueID + "'");
                Writer.Byte(ms.Count());
                using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                {
                    while (reader.Read())
                    {
                        Item.AddItemPacket(Writer, reader.GetByte(5), reader.GetInt32(2), reader.GetByte(4), reader.GetInt16(6), reader.GetInt32(7), reader.GetInt32(0), reader.GetInt32(9), reader.GetInt32(30));
                    }
                }
                ms.Close();
                //////////////////////////////////////////////////////////////////////////////////////
                // Other
                //////////////////////////////////////////////////////////////////////////////////////
                Writer.DWord(o.OwnerID);                    //Character ID
                Writer.Byte(slot);                          //Slot location of the pet
                //////////////////////////////////////////////////////////////////////////////////////
            }
            catch (Exception ex)
            {
                Console.WriteLine("Pet load error: " + ex);
            }
            return(Writer.GetBytes());
        }
Example #15
0
        public static byte[] SendGuildInfo2(character c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_ONLINE);
            Writer.DWord(c.Information.UniqueID);               // Guildmaster ID
            Writer.DWord(c.Network.Guild.Guildid);              // Guild ID
            Writer.Text(c.Network.Guild.Name);
            if (c.Network.Guild.GrantName != "")
            {
                Writer.Text(c.Network.Guild.GrantName);         // Guildmaster grand name len
            }
            else
            {
                Writer.Word(0);
            }
            Writer.DWord(0);                                    // ?
            Writer.DWord(0);                                    // ?
            Writer.DWord(0);                                    // ? Amount of guilds in union ?
            Writer.Byte(1);                                     // ?
            Writer.Byte(1);
            return(Writer.GetBytes());
        }
Example #16
0
        public static byte[] MakeAlias(string name, byte switchinfo)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_MAKE_ALIAS);
            Writer.Byte(1);
            switch (switchinfo)
            {
            case 0:
                Writer.Byte(0);
                Writer.Text(name);
                break;

            case 1:
                Writer.Byte(1);
                Writer.Text(name);
                break;

            default:
                Console.WriteLine("Alias Case: " + switchinfo);
                break;
            }
            return(Writer.GetBytes());
        }
Example #17
0
        public static byte[] GuildSetOnline(guild c, int memberid)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_ONLINE);
            Writer.DWord(memberid);
            Writer.DWord(c.Guildid);
            Writer.Text(c.Name);
            Writer.Word(0);
            Writer.DWord(0);
            Writer.DWord(0);
            Writer.DWord(0);
            Writer.Byte(0);
            Writer.Byte(1);
            return(Writer.GetBytes());
        }
Example #18
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Chat Packet
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static byte[] ChatPacket(byte type, int id, string text, string name)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_CHAT);
            Writer.Byte(type);
            switch (type)
            {
            case 1:
                Writer.DWord(id);
                Writer.Text3(text);
                break;

            case 3:
                Writer.DWord(id);
                Writer.Text3(text);
                break;

            case 2:
                Writer.Text(name);
                Writer.Text3(text);
                break;

            case 4:
                Writer.Text(name);
                Writer.Text3(text);
                break;

            case 5:
                Writer.Text(name);
                Writer.Text3(text);
                break;

            case 6:
                Writer.Text(name);
                Writer.Text3(text);
                break;

            case 7:
                Writer.Text3(text);
                break;

            case 9:
                Writer.Text(name);
                Writer.Text3(text);
                break;

            case 11:
                Writer.Text(name);
                Writer.Text3(text);
                break;
            }
            return(Writer.GetBytes());
        }
Example #19
0
        void ListPartyMatching(List <party> pt)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_SEND_PARTYLIST);
            //Write static bytes
            Writer.Byte(1);
            Writer.Byte(4);
            Writer.Byte(0);
            //Write total count of partys
            Writer.Byte(pt.Count);
            //If party count higher is then zero
            if (pt.Count > 0)
            {
                //Repeat for each party in list of party's
                foreach (party currpt in pt)
                {
                    //Get player information using leaderid
                    Systems s = Systems.GetPlayer(currpt.LeaderID);
                    //Write party id
                    Writer.DWord(currpt.ptid);
                    //Write leader id
                    Writer.DWord(currpt.LeaderID);
                    //Write charactername
                    Writer.Text(s.Character.Information.Name);
                    //Write static byte 1
                    Writer.Byte(1);
                    //Write current party players count
                    Writer.Byte(currpt.Members.Count);
                    //Write party type
                    Writer.Byte(currpt.Type);
                    //Write party purpose
                    Writer.Byte(currpt.ptpurpose);
                    //Write min level required
                    Writer.Byte(currpt.minlevel);
                    //Write max level to join the party
                    Writer.Byte(currpt.maxlevel);
                    //Write party name
                    Writer.Text3(currpt.partyname);
                }
            }
            //Send bytes to the client
            client.Send(Writer.GetBytes());
        }
Example #20
0
        public static byte[] Unique_Data(byte type, int mobid, string name)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_UNIQUE_ANNOUNCE);
            Writer.Byte(type);
            switch (type)
            {
            case 5:
                Writer.Byte(0x0C);
                Writer.DWord(mobid);
                break;

            case 6:
                Writer.Byte(0x0C);
                Writer.DWord(mobid);
                Writer.Text(name);
                break;
            }


            return(Writer.GetBytes());
        }
Example #21
0
        public static byte[] Party_DataMember(party p)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_PARTYMEMBER_DATA);
            //Write static byte
            Writer.Byte(0xFF);
            //Write party id
            Writer.DWord(p.ptid);
            //Write leader id
            Writer.DWord(p.LeaderID);
            //Write byte party type
            Writer.Byte(p.Type);
            //Write total amount of members in party
            Writer.Byte(p.Members.Count);
            //Repeat for each member in party -1
            for (byte b = 0; b <= p.Members.Count - 1; b++)
            {
                //Get player detail information
                Systems PartyMemberInfo = Systems.GetPlayer(p.Members[b]);
                //Calculate hp and mp
                int partyPercentMP = (int)Math.Round((decimal)(PartyMemberInfo.Character.Stat.SecondMP * 10) / PartyMemberInfo.Character.Stat.Mp) << 4;
                int partyPercentHP = (int)Math.Round((decimal)(PartyMemberInfo.Character.Stat.SecondHp * 10) / PartyMemberInfo.Character.Stat.Hp);
                //Set percent
                int partyPercent = partyPercentHP | partyPercentMP;
                //Write static byte
                Writer.Byte(0xff);
                //Write unique member id
                Writer.DWord(PartyMemberInfo.Character.Information.UniqueID);
                //Write character name
                Writer.Text(PartyMemberInfo.Character.Information.Name);
                //Write character model
                Writer.DWord(PartyMemberInfo.Character.Information.Model);
                //Write character level
                Writer.Byte(PartyMemberInfo.Character.Information.Level);
                //Write stat hp mp information
                Writer.Byte((byte)partyPercent);
                //Write x and y sector
                Writer.Byte(PartyMemberInfo.Character.Position.xSec);
                Writer.Byte(PartyMemberInfo.Character.Position.ySec);
                //Write x z y
                Writer.Word(Formule.packetx(PartyMemberInfo.Character.Position.x, PartyMemberInfo.Character.Position.xSec));
                Writer.Word(PartyMemberInfo.Character.Position.z);
                Writer.Word(Formule.packety(PartyMemberInfo.Character.Position.y, PartyMemberInfo.Character.Position.ySec));
                //Write double word 1
                Writer.Word(1);
                Writer.Word(1);
                //If player has a guild
                if (PartyMemberInfo.Character.Network.Guild.Name != null)
                {
                    //Write guild name
                    Writer.Text(PartyMemberInfo.Character.Network.Guild.Name);
                }
                //If player has no guild
                else
                {
                    //Write word 0 value
                    Writer.Word(0);
                }
                //Write static byte
                Writer.Byte(0);
                //Write dword
                Writer.DWord(0);
                Writer.DWord(0);
            }
            //Return all bytes for sending
            return(Writer.GetBytes());
        }
Example #22
0
        public static byte[] Party_Data(byte type, int id)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_PARTY_DATA);
            //Write type byte
            Writer.Byte(type);
            //Create switch for type given
            switch (type)
            {
            case 1:
                //Remove party state
                Writer.Byte(0x0b);
                Writer.Byte(0);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 2:
                //Formed party new member update
                Systems CharacterInformation = Systems.GetPlayer(id);
                //Write static byte
                Writer.Byte(0xFF);
                //Write unique character id
                Writer.DWord(CharacterInformation.Character.Information.UniqueID);
                //Write character name
                Writer.Text(CharacterInformation.Character.Information.Name);
                //Write character model
                Writer.DWord(CharacterInformation.Character.Information.Model);
                //Write character level
                Writer.Byte(CharacterInformation.Character.Information.Level);
                //Write static byte
                Writer.Byte(0xAA);
                //Write x and y sector
                Writer.Byte(CharacterInformation.Character.Position.xSec);
                Writer.Byte(CharacterInformation.Character.Position.ySec);
                //Write x z y
                Writer.Word(Formule.packetx(CharacterInformation.Character.Position.x, CharacterInformation.Character.Position.xSec));
                Writer.Word(CharacterInformation.Character.Position.z);
                Writer.Word(Formule.packety(CharacterInformation.Character.Position.y, CharacterInformation.Character.Position.ySec));
                //Write double word 1
                Writer.Word(1);
                Writer.Word(1);
                //If character is in a guild
                if (CharacterInformation.Character.Network.Guild.Name != null)
                {
                    //Write guild name
                    Writer.Text(CharacterInformation.Character.Network.Guild.Name);
                }
                //If character has no guild
                else
                {
                    //Write 0 word value
                    Writer.Word(0);
                }
                //Static byte
                Writer.Byte(0);
                //Permissions
                Writer.DWord(0);
                Writer.DWord(0);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 3:
                //Write character id
                Writer.DWord(id);
                //Write static byte 4
                Writer.Byte(4);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 6:
                //Update player location and stat
                CharacterInformation = Systems.GetPlayer(id);
                //Calculate hp and mp
                int partyPercentMP = (int)Math.Round((decimal)(CharacterInformation.Character.Stat.SecondMP * 10) / CharacterInformation.Character.Stat.Mp) << 4;
                int partyPercentHP = (int)Math.Round((decimal)(CharacterInformation.Character.Stat.SecondHp * 10) / CharacterInformation.Character.Stat.Hp);
                //Set percent information
                int partyPercent = partyPercentHP | partyPercentMP;
                //Write character id
                Writer.DWord(id);
                //If character is moving
                if (CharacterInformation.Character.Position.Walking)
                {
                    //Write byte 20
                    Writer.Byte(0x20);
                    //Write location information
                    Writer.Byte(CharacterInformation.Character.Position.packetxSec);
                    Writer.Byte(CharacterInformation.Character.Position.packetySec);
                    Writer.Word(CharacterInformation.Character.Position.packetX);
                    Writer.Word(CharacterInformation.Character.Position.packetZ);
                    Writer.Word(CharacterInformation.Character.Position.packetY);
                    //Write double word 1
                    Writer.Word(1);
                    Writer.Word(1);
                }
                //If not walking
                else
                {
                    //Write static byte 4
                    Writer.Byte(4);
                    //Write hp mp information
                    Writer.Byte((byte)partyPercent);
                }
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 9:
                //New leader id
                Writer.DWord(id);
                //Return all bytes for sending
                return(Writer.GetBytes());
            }
            //Return all bytes for sending
            return(Writer.GetBytes());
        }
Example #23
0
        public static byte[] Load(character c)
        {

            PacketWriter Writer = new PacketWriter();
            Writer.Create(Systems.SERVER_PLAYERDATA);
            /////////////////////////////////////////////////////// Character basic info
            #region Basic info   
            Writer.DWord(c.Ids.GetLoginID);
            Writer.DWord(c.Information.Model);
            Writer.Byte(c.Information.Volume);
            Writer.Byte(c.Information.Level);
            Writer.Byte(c.Information.Level);
            Writer.LWord(c.Information.XP);
            Writer.DWord(c.Information.SpBar);
            Writer.LWord(c.Information.Gold);
            Writer.DWord(c.Information.SkillPoint);
            Writer.Word(c.Information.Attributes);
            Writer.Byte(c.Information.BerserkBar);
            Writer.DWord(0);
            Writer.DWord(c.Stat.SecondHp);
            Writer.DWord(c.Stat.SecondMP);
            Writer.Bool(c.Information.Level < 20 ? true : false);
            #endregion
            /////////////////////////////////////////////////////// Character Player Kill Info
            #region Pk information
            //Mssql perfection reading with multiple data adapters... while this one is open i can still read anything else from the database
            //With no speed reduction...
            Systems.MsSQL checkpk = new Systems.MsSQL("SELECT * FROM character WHERE name ='" + c.Information.Name + "'");
            using (System.Data.SqlClient.SqlDataReader getinfo = checkpk.Read())
            {
                while (getinfo.Read())
                {
                    byte dailypk = getinfo.GetByte(48);
                    byte pklevel = getinfo.GetByte(49);
                    byte murderlevel = getinfo.GetByte(50);

                    Writer.Byte(dailypk);
                    Writer.Word(pklevel);
                    Writer.DWord(murderlevel);
                    if (murderlevel != 0) c.Information.Murderer = true;
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Character Title
            #region Title
            Writer.Byte(c.Information.Title);
            #endregion
            /////////////////////////////////////////////////////// Character Pvpstate
            #region Pvp
            Writer.Byte(c.Information.Pvpstate);
            if (c.Information.Pvpstate > 0) 
                c.Information.PvP = true;
            #endregion
            /////////////////////////////////////////////////////// Character Items
            #region Item
            
            Writer.Byte(c.Information.Slots);

            Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "' AND slot >= '0' AND slot <= '" + c.Information.Slots + "' AND inavatar='0' AND storagetype='0'");
            Writer.Byte(ms.Count());
            using (System.Data.SqlClient.SqlDataReader msreader = ms.Read())
            {

                while (msreader.Read())
                {

                    short amount = msreader.GetInt16(6);

                    if (amount < 1) amount = 1;
                    Systems.MsSQL.InsertData("UPDATE char_items SET quantity='" + amount + "' WHERE owner='" + c.Information.CharacterID + "' AND itemid='" + msreader.GetInt32(2) + "' AND id='" + msreader.GetInt32(0) + "' AND storagetype='0'");

                    if (msreader.GetByte(5) == 6)
                        c.Information.Item.wID = Convert.ToInt32(msreader.GetInt32(2));
                    if (msreader.GetByte(5) == 7)
                    {
                        c.Information.Item.sID = msreader.GetInt32(2);
                        c.Information.Item.sAmount = msreader.GetInt16(6);
                    }
                    
                    Item.AddItemPacket(Writer, msreader.GetByte(5), msreader.GetInt32(2), msreader.GetByte(4), amount, msreader.GetInt32(7),msreader.GetInt32(0), msreader.GetInt32(9), msreader.GetInt32(30));
                }
            }
            ms.Close();

            //Avatar
            Writer.Byte(5);

            ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "' AND slot >= '0' AND slot <= '" + c.Information.Slots + "' AND inavatar='1' AND storagetype='0'");

            Writer.Byte(ms.Count());
            using (System.Data.SqlClient.SqlDataReader msreader = ms.Read())
            {
                while (msreader.Read())
                {
                    Item.AddItemPacket(Writer, msreader.GetByte(5), msreader.GetInt32(2), msreader.GetByte(4), msreader.GetInt16(6), msreader.GetInt32(7), msreader.GetInt32(0), msreader.GetInt32(9),msreader.GetInt32(30));
                }
            }
            ms.Close();

            Writer.Byte(0);

            // job mastery 
            Writer.Byte(0x0B);
            Writer.Byte(0);
            Writer.Byte(0);

            #endregion
            ///////////////////////////////////////////////////////  Mastery
            #region Mastery
            if (c.Information.Model <= 12000)
            {
                for (byte i = 1; i <= 8; i++)
                {
                    Writer.Byte(1);
                    Writer.DWord(c.Stat.Skill.Mastery[i]);
                    Writer.Byte(c.Stat.Skill.Mastery_Level[i]);
                }
            }
            else
            {
                if (c.Information.Model >= 14000)
                {
                    for (byte i = 1; i < 8; i++)
                    {
                        Writer.Byte(1);
                        Writer.DWord(c.Stat.Skill.Mastery[i]);
                        Writer.Byte(c.Stat.Skill.Mastery_Level[i]);
                    }
                }
            }
            #endregion
            /////////////////////////////////////////////////////// Skills
            #region Skill
            Writer.Byte(2);
            Writer.Byte(0);
                for (int i = 1; i <= c.Stat.Skill.AmountSkill; i++)
                {
                    Writer.Byte(1);
                    Writer.DWord(c.Stat.Skill.Skill[i]);
                    Writer.Byte(1);
                }
            Writer.Byte(2);
            #endregion
            /////////////////////////////////////////////////////// Quests
            #region Quest
            Writer.Word(1); // how many Quest ids completed/aborted
            Writer.DWord(1);// Quest id
            Writer.Byte(0);//number of Quests that are live
            #endregion
            Writer.Byte(0);//? for now
            /////////////////////////////////////////////////////// Talisman
            #region Talisman
            Writer.DWord(1);//new
            Writer.DWord(1);//new
            Writer.DWord(0);//? for now
            Writer.DWord(0x0C);//new
            #endregion
            /////////////////////////////////////////////////////// Position + id + speed
            #region Character id / Position / Speed
            Writer.DWord(c.Information.UniqueID);
            Writer.Byte(c.Position.xSec);
            Writer.Byte(c.Position.ySec);
            if (!File.FileLoad.CheckCave(c.Position.xSec, c.Position.ySec))
            {
                Writer.Float(Formule.packetx(c.Position.x, c.Position.xSec));
                Writer.Float(c.Position.z);
                Writer.Float(Formule.packety(c.Position.y, c.Position.ySec));
            }
            else
            {
                Writer.Float(Formule.cavepacketx(c.Position.x));// Added for cave Coords
                Writer.Float(c.Position.z);
                Writer.Float(Formule.cavepackety(c.Position.y));// Added for cave Coords

            }
            Writer.Word(0);							// Angle
            Writer.Byte(0);
            Writer.Byte(1);
            Writer.Byte(0);
            Writer.Word(0);							// Angle
            Writer.Word(0);
            Writer.Byte(0);
            Writer.Bool(false); //berserk

            Writer.Byte(0);//new ?

            Writer.Float(c.Speed.WalkSpeed);
            Writer.Float(c.Speed.RunSpeed);
            Writer.Float(c.Speed.BerserkSpeed);
            #endregion
            /////////////////////////////////////////////////////// Premium Tickets
            #region Premium ticket
            Writer.Byte(0); //ITEM_MALL_GOLD_TIME_SERVICE_TICKET_4W
            #endregion
            /////////////////////////////////////////////////////// GM Check + Name
            #region GM Check + Name
            Writer.Text(c.Information.Name);
            #endregion
            /////////////////////////////////////////////////////// Character jobs
            #region Character Job / hunter thief trader ( old job things )
                //Writer info with job name when on job
                /*if (c.Job.state == 1 && c.Job.Jobname != "0")
                {
                    Writer.Text(c.Job.Jobname);
                    Writer.Byte(3);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }
                //Write basic info noname
                if (c.Job.Jobname == "0")
                {
                    Writer.Word(0);
                    Writer.Byte(3);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }
                //Write no info
                else
                {
                    Writer.Word(0);
                    Writer.Byte(0);
                    Writer.Byte(1);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.DWord(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                    Writer.Byte(0);
                }*/
            #endregion
            #region New job system
            if (c.Job.state == 1)
            {
                Writer.Text(c.Job.Jobname);
                Writer.Byte(1);
                Writer.Byte(c.Job.level);//Level job
                Writer.Byte(c.Information.Level);//Level char
                Writer.Byte(1); // job level? myb
                Writer.LWord(0);// job exp probably y
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
            }
            else
            {

                Writer.Word(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(2); // job type
                Writer.Byte(1); // job level? myb
                Writer.LWord(0);// job exp probably y
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
                Writer.Byte(0);
            }

            #endregion
                /////////////////////////////////////////////////////// Pvp / Pk State
            #region Pvp / Pk State
            if (c.Information.Pvpstate == 1 || c.Information.Murderer)
            {
                Writer.Byte(0x22);
            }
            else if (c.Information.Pvpstate == 0 || !c.Information.Murderer)
            {
                Writer.Byte(0xFF);
            }
            #endregion
            /////////////////////////////////////////////////////// Guide Data 
            #region Guide Data this data stacks on itself so if guide id is 0400000000000000 and next guide is 0300000000000000 the data to send is 0700000000000000

            for (int i = 0; i < 8; ++i)//Main Guide Packet Info
            {
                Writer.Byte(c.Guideinfo.G1[i]);//Reads From Int Array
            }
            #endregion
            /////////////////////////////////////////////////////// Account / Gm Check
            #region Account ID + Gm Check
            Writer.DWord(c.Account.ID);
            Writer.Byte(0);//c.Information.GM
            #endregion
            /////////////////////////////////////////////////////// Quickbar + Autopotion
            #region Bar information
            Writer.Byte(7);
            PacketReader reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\quickbar\" + c.Information.Name + ".dat"));
            PlayerQuickBar(reader, Writer);
            reader = new PacketReader(System.IO.File.ReadAllBytes(Environment.CurrentDirectory + @"\player\info\autopot\" + c.Information.Name + ".dat"));
            PlayerAutoPot(reader, Writer);
            #endregion
            /////////////////////////////////////////////////////// Academy
            #region Academy
            Writer.Byte(0); // number of player in academy
            /* // if we have players there 
             Writer.Byte(1);
             Writer.Text("asd"); 
             */
            Writer.Byte(0);//added byte today for 1.310
            Writer.Byte(0);
            Writer.Word(1); 
            Writer.Word(1);
            Writer.Byte(0);
            Writer.Byte(1);
            #endregion
            return Writer.GetBytes();
        }
Example #24
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Character listening packet
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static byte[] CharacterListing(string name)
        {
            
            Systems.MsSQL ms    = new Systems.MsSQL("SELECT TOP 4 * FROM character WHERE account='" + name + "'");
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_CHARACTERSCREEN);      // Select opcode
            Writer.Byte(2);                                     // Static byte 2
            Writer.Byte(1);                                     // Static byte 1
            Writer.Byte(ms.Count());                            // Byte Character Count

            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    Writer.DWord(reader.GetInt32(3));           // DWord Skin Model
                    Writer.Text(reader.GetString(2));           // String Name
 
                    Writer.Byte(reader.GetByte(4));             // Byte Skin Volume
                    Writer.Byte(reader.GetByte(5));             // Byte Level

                    Writer.LWord(reader.GetInt64(12));          // Long Experience

                    Writer.Word(reader.GetInt16(6));            // Word STR
                    Writer.Word(reader.GetInt16(7));            // Word INT
                    Writer.Word(reader.GetInt16(8));            // Attribute points
                    
                    Writer.DWord(reader.GetInt32(9));           // HP
                    Writer.DWord(reader.GetInt32(10));          // MP

                    TimeSpan ts = Convert.ToDateTime(reader.GetDateTime(43)) - DateTime.Now;
                    double time = ts.TotalMinutes;

                    if (Math.Round(time) > 0)
                    {
                        Writer.Byte(1);
                        Writer.DWord(Math.Round(time));
                    }
                    else
                    {
                        Writer.Byte(0);
                    }

                    if (Math.Round(time) < 0 && DateTime.Now != reader.GetDateTime(43))
                    {
                        Systems.MsSQL.UpdateData("UPDATE character SET deleted='1' Where id='" + reader.GetInt32(0) + "'");
                    }

                    Writer.Word(0);
                    Writer.Byte(0);

                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 8, 0,false);
                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 5, 1,false);
                }
                //Jobtype information
                int jobinfo = Systems.MsSQL.GetDataInt("SELECT * FROM users WHERE id='"+ name +"'", "jobtype");
                Writer.Byte(Convert.ToByte(jobinfo));
            }
            ms.Close();

            return Writer.GetBytes();
        }
Example #25
0
        //Listening main uses a single packet only so we write our packet here
        public static byte[] CharacterListing(player p)
        {
            //Create new sql query to get all characters except fully deleted
            Systems.MsSQL ms = new Systems.MsSQL("SELECT TOP 4 * FROM character WHERE account='" + p.AccountName + "' AND deleted='0' OR account='" + p.AccountName + "' AND deleted ='1'");
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_CHARACTERSCREEN);      // Select opcode
            Writer.Byte(2);                                     // Static byte 2
            Writer.Byte(1);                                     // Static byte 1
            Writer.Byte(ms.Count());                            // Byte Character Count
            //Create new sql data reader
            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                //While the reader is reading data from the database
                while (reader.Read())
                {
                    Writer.DWord(reader.GetInt32(3));           // DWord Skin Model
                    Writer.Text(reader.GetString(2));           // String Name
                    Writer.Byte(reader.GetByte(4));             // Byte Skin Volume
                    Writer.Byte(reader.GetByte(5));             // Byte Level
                    Writer.LWord(reader.GetInt64(12));          // Long Experience
                    Writer.Word(reader.GetInt16(6));            // Word STR
                    Writer.Word(reader.GetInt16(7));            // Word INT
                    Writer.Word(reader.GetInt16(8));            // Attribute points
                    Writer.DWord(reader.GetInt32(9));           // HP
                    Writer.DWord(reader.GetInt32(10));          // MP
                    //Set defnition for current time
                    DateTime CurrentTime = DateTime.Now;
                    //Subtract the current time with deletion time information
                    TimeSpan TIMESPAN = reader.GetDateTime(43) - DateTime.Now;
                    //If the character has been deleted but still sitting
                    if (reader.GetByte(42) == 1)
                    {
                        //Write state byte 1 for sitting
                        Writer.Byte(1);
                        //Display deletion time reamining
                        Writer.DWord((double)TIMESPAN.TotalMinutes);
                        //If time has expired delete the character
                        if (TIMESPAN.TotalMinutes <= 0)
                        {
                            //Note: There are more ways like full delete but if someone got deleted by someone else's action
                            //It will be easy to recover the character by changing the deletion byte in the database
                            //0 = Not deleted , 1 = Deletion in progress, 2 = Deleted

                            //Set deletion state so it wont be listed again.
                            Systems.MsSQL.UpdateData("UPDATE character SET deleted='2' Where id='" + reader.GetInt32(0) + "'");
                        }
                    }
                    //If not deleted
                    else
                    {
                        //State byte = 0 Standing
                        Writer.Byte(0);
                    }
                    //Static
                    Writer.Word(0);
                    Writer.Byte(0);
                    //Get normal equipped items upto slot 8 not in avatar slots
                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 8, 0, false);
                    //Get avatar type items
                    Function.Items.PrivateItemPacket(Writer, reader.GetInt32(0), 5, 1, false);
                }
                //Jobtype information
                int jobinfo = Systems.MsSQL.GetDataInt("SELECT * FROM users WHERE id='" + p.AccountName + "'", "jobtype");
                Writer.Byte(Convert.ToByte(jobinfo));
            }
            ms.Close();
            //Return all bytes to the client
            return(Writer.GetBytes());
        }
Example #26
0
        public static byte[] GuildUpdate(character c, byte type, int memberid, int permissions, int donatedgp)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_UPDATE);
            switch (type)
            {
            case 1:
                //Invited user to guild
                Writer.Byte(2);
                Writer.DWord(c.Information.CharacterID);
                Writer.Text(c.Information.Name);
                Writer.Byte(0x0A);     //Check
                Writer.Byte(c.Information.Level);
                Writer.DWord(0);       //Permissions below
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.Word(0);
                Writer.DWord(c.Information.Model);     //Character Model For Icon In Guild
                Writer.Byte(0);
                Writer.Byte(c.Position.xSec);
                Writer.Byte(c.Position.ySec);
                Writer.DWord(0);
                Writer.DWord(0);
                Writer.Byte(1);
                break;

            case 2:
                //Disband guild
                Writer.Byte(1);
                break;

            case 3:
                //Transfer Leadership
                Writer.Byte(0x16);
                Writer.Byte(2);
                Writer.Byte(0x54);
                Writer.DWord(memberid);
                Writer.Byte(0);
                Writer.DWord(0xFFFFFFFF);
                Writer.Byte(1);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(0x0A);
                Writer.DWord(0);
                Writer.Byte(0);
                break;

            case 4:
                //Change permissions
                Writer.Byte(0x16);
                Writer.Byte(1);
                Writer.Byte(0x10);
                Writer.DWord(c.Information.CharacterID);
                Writer.DWord(permissions);
                break;

            case 5:
                //Guild upgrade
                Writer.Byte(5);
                Writer.Byte(0x0C);    //Members allowed? 12
                Writer.Byte(c.Network.Guild.Level);
                Writer.DWord(c.Network.Guild.PointsTotal);
                break;

            //Invite user online
            case 6:
                //Static byte 6
                Writer.Byte(6);
                //Write member id
                Writer.DWord(c.Information.CharacterID);
                //Static byte 2
                Writer.Byte(2);
                //Online byte (If online byte = 0, If offline byte = 1).
                Writer.Byte(Convert.ToBoolean(c.Information.Online) ? 0 : 1);
                break;

            case 7:
                //User online / offline
                Writer.Byte(3);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(2);
                break;

            case 8:
                //Update player level
                Writer.Byte(6);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(1);
                Writer.Byte(c.Information.Level);
                break;

            case 9:
                //Update gp information guild
                Writer.Byte(6);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(8);
                Writer.DWord(c.Network.Guild.DonateGP);
                break;

            case 10:
                //Update user location
                Writer.Byte(6);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(0x80);    //need to check
                Writer.Byte(c.Position.xSec);
                Writer.Byte(c.Position.ySec);
                break;

            case 11:
                //Guild message update
                Writer.Byte(0x05);
                Writer.Byte(0x10);
                Writer.Text(c.Network.Guild.NewsTitle);
                Writer.Text(c.Network.Guild.NewsMessage);
                break;

            case 12:
                //Leave guild
                Writer.Byte(3);
                Writer.DWord(c.Information.CharacterID);
                Writer.Byte(1);
                break;

            case 13:
                //Donated gp #1
                Writer.Byte(5);
                Writer.Byte(8);
                Writer.DWord(donatedgp);
                break;

            case 14:
                //Union invite send
                Writer.Byte(c.Network.Guild.TotalMembers);
                Writer.DWord(c.Network.Guild.Guildid);
                Writer.Text(c.Network.Guild.Name);
                Writer.Byte(c.Network.Guild.Level);
                Writer.Text(c.Information.Name);
                Writer.DWord(c.Information.Model);
                Writer.Byte(0x11);    //??
                break;
            }
            return(Writer.GetBytes());
        }
Example #27
0
 void PrivateMessage()
 {
     //Wrap our code inside a try / catch to catch bad errors
     try
     {
         //Create a new mssql query to get information from messages table
         Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM message WHERE receiver='" + Character.Information.Name + "' ORDER BY time DESC");
         //Set integer definition for count rows
         int count = ms.Count();
         //If we have more then zero messages
         if (count > 0)
         {
             //Tmp test for desc / asc
             int Tempdate = 0;
             //Create a new packet writer
             PacketWriter Writer = new PacketWriter();
             //Add the opcode for messages
             Writer.Create(Systems.SERVER_PM_MESSAGE);
             //Write static 1 byte
             Writer.Byte(1);
             //Write total messages count
             Writer.Byte(Convert.ToByte(count));
             //Create new sql data reader for reading colums.
             using (SqlDataReader reader = ms.Read())
             {
                 //While our reader is reading information
                 while (reader.Read())
                 {
                     //Set definition for pm sender
                     string MessageFrom = reader.GetString(1);
                     //Set definition for pm receiver
                     string MessageTo = reader.GetString(2);
                     //Set definition for message
                     string MessageContent = reader.GetString(3);
                     //Set byte definition for status (Read unread) 0 = unread, 1 = read
                     byte pmstatus = reader.GetByte(4);
                     //Get date time when message have been send
                     DateTime MessageDate = Convert.ToDateTime(reader.GetDateTime(5));
                     //Write text message sender
                     Writer.Text(MessageFrom);
                     //Write time
                     //DateTime Time = reader.GetDateTime(5);
                     //Time = Time..ToString();
                     Writer.DWord(0);
                     //Write date
                     Writer.DWord(Tempdate += 1);
                     //Write byte status 0 = unread , 1 = read
                     Writer.Byte(pmstatus);
                 }
                 //Send bytes to client
                 client.Send(Writer.GetBytes());
             }
         }
         //Close mssql query
         ms.Close();
     }
     //If any error accures
     catch (Exception ex)
     {
         Console.WriteLine("Error reading private messages: {0}", ex);
         //Write the information to the debug file.
         Systems.Debugger.Write(ex);
     }
 }
Example #28
0
        public static byte[] UnionInfo(Systems c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_UNIONS);
            Writer.DWord(c.Character.Information.CharacterID);                // Union owner id
            Writer.DWord(7);                                                  // ??Need to check
            Writer.DWord(c.Character.Network.Guild.Guildid);                  // Union leader guild id
            Writer.Byte(c.Character.Network.Guild.Unions.Count);              // Count guilds in union
            //Get all guilds details
            foreach (int guild in c.Character.Network.Guild.Unions)
            {
                //Load other guild data
                Systems.MsSQL guild_data = new Systems.MsSQL("SELECT * FROM guild WHERE id='" + guild + "'");

                using (System.Data.SqlClient.SqlDataReader reader = guild_data.Read())
                {
                    while (reader.Read())
                    {
                        string Guildname        = reader.GetString(1);
                        byte   Guildlevel       = reader.GetByte(2);
                        byte   Guildmembercount = reader.GetByte(6);
                        int    Ownerid          = reader.GetInt32(9);

                        string Charname  = Systems.MsSQL.GetData("SELECT name FROM character WHERE id='" + Ownerid + "'", "name").ToString();
                        int    Charmodel = Convert.ToInt32(Systems.MsSQL.GetData("SELECT chartype FROM character WHERE id='" + Ownerid + "'", "chartype"));

                        Writer.DWord(guild);                        //Guild ID
                        Writer.Text(reader.GetString(1));           //Guildname
                        Writer.Byte(reader.GetByte(2));             //Guildlevel
                        Writer.Text(Charname);                      //Ownername
                        Writer.DWord(Charmodel);                    //Owner model
                        Writer.Byte(reader.GetByte(6));             //Guild member count

                        //Get guild details
                        Systems Guildmembers = Systems.GetGuildPlayer(guild);
                        //Add clients that are online to union list
                        //Null check
                        if (Guildmembers != null)
                        {
                            foreach (int member in Guildmembers.Character.Network.Guild.Members)
                            {
                                //make sure member isnt 0
                                if (member != 0)
                                {
                                    //Get player details
                                    Systems getmember = Systems.GetPlayerMainid(member);
                                    //Make sure that the player is there
                                    if (getmember != null)
                                    {
                                        //Add client to union list
                                        c.Character.Network.Guild.UnionMembers.Add(getmember.Character.Information.CharacterID);
                                        //Add to member
                                        if (c.Character.Information.CharacterID != getmember.Character.Information.CharacterID)
                                        {
                                            getmember.Character.Network.Guild.UnionMembers.Add(c.Character.Information.CharacterID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Writer.GetBytes());
        }