예제 #1
0
        public static byte[] Player_getExp(int id, long exp, long sp, short level)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_PLAYER_GET_EXP);
            Writer.DWord(id);
            Writer.LWord(exp);
            Writer.LWord(sp);
            Writer.Byte(0);
            if (level != 0)
            {
                Writer.Word(level);
            }
            return(Writer.GetBytes());
        }
예제 #2
0
        public static byte[] AlchemyResponse(bool isSuccess, Global.slotItem sItem, byte type, byte totalblue)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ALCHEMY);
            Writer.Byte(1);
            Writer.Byte(2);
            Writer.Bool(isSuccess);
            Writer.Byte(sItem.Slot);
            if (!isSuccess)
            {
                Writer.Byte(0);
            }
            Writer.DWord(0);
            Writer.DWord(sItem.ID);
            Writer.Byte(sItem.PlusValue);
            Writer.LWord(0);
            Writer.DWord(sItem.Durability);
            Writer.Byte(Data.ItemBlue[sItem.dbID].totalblue);
            for (int i = 0; i <= Data.ItemBlue[sItem.dbID].totalblue - 1; i++)
            {
                Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[sItem.dbID].blue[i]))).ID);
                Writer.DWord(Data.ItemBlue[sItem.dbID].blueamount[i]);
            }
            Writer.Word(1);
            Writer.Word(2);
            Writer.Word(3);

            return(Writer.GetBytes());
        }
예제 #3
0
        public static byte[] InfoUpdate(byte type, int obje, byte bT)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_INFO_UPDATE);
            Writer.Byte(type);
            switch (type)
            {
            case 1:
                Writer.LWord(obje);
                Writer.Byte(0);
                break;

            case 2:
                Writer.DWord(obje);
                Writer.Byte(0);
                break;

            case 4:
                Writer.Byte(bT);
                Writer.DWord(obje);
                break;

            default:
                break;
            }

            return(Writer.GetBytes());
        }
예제 #4
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());
        }
예제 #5
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());
        }
예제 #6
0
        public static byte[] OpenWarehouse(long t)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_OPEN_WAREHOUSE);
            Writer.LWord(t);
            return(Writer.GetBytes());
        }
예제 #7
0
        public static byte[] GuildStorageGold(character c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_STORAGE_GOLD);
            Writer.LWord(c.Network.Guild.StorageGold);
            return(Writer.GetBytes());
        }
예제 #8
0
        public static byte[] Exchange_Gold(long gold)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_EXCHANGE_GOLD);
            Writer.Byte(2);
            Writer.LWord(gold);
            return(Writer.GetBytes());
        }
예제 #9
0
        public static byte[] GuildGoldUpdate(long info, byte type)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ITEM_MOVE);
            Writer.Byte(1);
            Writer.Byte(type);
            Writer.LWord(info);
            return(Writer.GetBytes());
        }
예제 #10
0
        public static byte[] ItemExchange_Gold(long gold)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ITEM_MOVE);
            Writer.Byte(1);
            Writer.Byte(13);
            Writer.LWord(gold);
            return(Writer.GetBytes());
        }
예제 #11
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Update gold
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static byte[] UpdateGold(long gold)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_UPDATEGOLD);
            Writer.Byte(1);
            Writer.LWord(gold);
            Writer.Byte(0);
            return(Writer.GetBytes());
        }
예제 #12
0
        public static byte[] StallModifyItem(byte stallSlot, ulong price)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_STALL_ACTION);
            Writer.Byte(1);
            Writer.Byte(1);
            Writer.Byte(stallSlot);
            Writer.Word(1);
            Writer.LWord(price);
            Writer.Word(0);
            return(Writer.GetBytes());
        }
예제 #13
0
        public static byte[] Exchange_ItemPacket(int id, List <Global.slotItem> Exhange, bool mine)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_EXCHANGE_ITEM);
            Writer.DWord(id);
            Writer.Byte(Exhange.Count);

            for (byte i = 0; i < Exhange.Count; i++)
            {
                Systems.LoadBluesid(Exhange[i].dbID);
                if (mine)
                {
                    Writer.Byte(Exhange[i].Slot);
                }

                Writer.Byte(i);
                Writer.DWord(0);
                Writer.DWord(Exhange[i].ID);

                if (Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.ARMOR ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.GARMENT ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.GM ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.HEAVY ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.LIGHT ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.PROTECTOR ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.ROBE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EARRING ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.RING ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.NECKLACE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.BLADE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.BOW ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.SPEAR ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.SWORD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
                {
                    Writer.Byte(Exhange[i].PlusValue);
                    Writer.LWord(0);
                    Writer.DWord(Data.ItemBase[Exhange[i].ID].Defans.Durability);
                    if (Data.ItemBlue[Exhange[i].dbID].totalblue != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[Exhange[i].dbID].totalblue));
                        for (int a = 1; a <= Data.ItemBlue[Exhange[i].dbID].totalblue; a++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[Exhange[i].dbID].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[Exhange[i].dbID].blueamount[i]);
                        }
                    }

                    else
                    {
                        Writer.Byte(0);
                    }
                    Writer.Word(1);
                    Writer.Word(2);
                    Writer.Word(3);
                }
                else if (Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.STONES)
                {
                    Writer.Word(Exhange[i].Amount);
                    Writer.Byte(0);
                }
                else if (Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.MONSTERMASK)
                {
                    Writer.DWord(0);
                }
                else if (Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.ELIXIR)
                {
                    Writer.Word(1);
                }
                else if (Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.ARROW ||
                         Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.BOLT ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.HP_POTION ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.MP_POTION ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.VIGOR_POTION ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.SPEED_POTION ||
                         Data.ItemBase[Exhange[i].ID].Ticket == Global.item_database.Tickets.BEGINNER_HELPERS ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.ELIXIR ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.ALCHEMY_MATERIAL ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.EVENT ||
                         Data.ItemBase[Exhange[i].ID].Class_D == 3)
                {
                    Writer.Word(Exhange[i].Amount);
                }
            }
            return(Writer.GetBytes());
        }
예제 #14
0
        public static void StallItemPacket(List <stall.stallItem> ItemList, PacketWriter Writer)
        {
            for (byte i = 0; i < ItemList.Count; i++)
            {
                //Define item id
                int itemid = ItemList[i].Item.ID;
                //Temp disable mall type, todo : Enable PRE-Mall to sell in stalls.
                if (Data.ItemBase[itemid].Name.Contains("MALL"))
                {
                    return;
                }

                Systems.LoadBluesid(ItemList[i].Item.dbID);

                Writer.Byte(ItemList[i].stallSlot);
                Writer.DWord(0);
                Writer.DWord(itemid);

                //Define what types of item we are adding to the stall
                if (Data.ItemBase[itemid].Type == Global.item_database.ArmorType.ARMOR ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.GARMENT ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.GM ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.HEAVY ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.LIGHT ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.PROTECTOR ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.ROBE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EARRING ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.RING ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.NECKLACE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BLADE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BOW ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_AXE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_HARP ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.GLAVIE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.SPEAR ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.SWORD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_SHIELD)
                {
                    Writer.Byte(ItemList[i].Item.PlusValue);
                    Writer.LWord(0);
                    Writer.DWord(Data.ItemBase[ItemList[i].Item.ID].Defans.Durability);
                    if (Data.ItemBlue[ItemList[i].Item.dbID].totalblue != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[ItemList[i].Item.dbID].totalblue));
                        for (int a = 1; a <= Data.ItemBlue[ItemList[i].Item.dbID].totalblue; a++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[ItemList[i].Item.dbID].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[ItemList[i].Item.dbID].blueamount[i]);
                        }
                    }

                    else
                    {
                        Writer.Byte(0);
                    }
                    Writer.Word(1);
                    Writer.Word(2);
                    Writer.Word(3);
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.STONES)
                {
                    Writer.Word(ItemList[i].Item.Amount);
                    Writer.Byte(0);
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.MONSTERMASK)
                {
                    Writer.DWord(0);//Todo : Load monster mask monster model id here
                    return;
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.ELIXIR)
                {
                    Writer.Word(1);
                }
                else if (Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.ARROW ||
                         Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BOLT ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.HP_POTION ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.MP_POTION ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.VIGOR_POTION ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.SPEED_POTION ||
                         Data.ItemBase[itemid].Ticket == Global.item_database.Tickets.BEGINNER_HELPERS ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.ELIXIR ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.ALCHEMY_MATERIAL ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.EVENT ||
                         Data.ItemBase[itemid].Class_D == 3)
                {
                    Writer.Word(ItemList[i].Item.Amount);
                }
                Writer.Byte(ItemList[i].Item.Slot);
                Writer.Word(ItemList[i].Item.Amount);
                Writer.LWord(ItemList[i].price);
            }
            Writer.Byte(0xFF);
        }
예제 #15
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Inventory item movement
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static byte[] MoveItem(byte type, byte fromSlot, byte toSlot, short quantity, long gold, string action)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ITEM_MOVE);
            switch (action)
            {
            case "MOVE_INSIDE_INVENTORY":
                Writer.Byte(1);
                Writer.Byte(type);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                Writer.Word(quantity);
                Writer.Byte(0);
                break;

            case "MOVE_INSIDE_STORAGE":
                Writer.Bool(true);
                Writer.Byte(1);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                Writer.Word(quantity);
                break;

            case "MOVE_INSIDE_GUILD_STORAGE":
                Writer.Byte(1);
                Writer.Byte(0x1D);        //Type
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                Writer.Word(quantity);
                break;

            case "MOVE_TO_STORAGE":
                Writer.Byte(1);
                Writer.Byte(2);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_TO_GUILD_STORAGE":
                Writer.Byte(1);
                Writer.Byte(0x1E);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_FROM_STORAGE":
                Writer.Byte(1);
                Writer.Byte(3);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_FROM_GUILD_STORAGE":
                Writer.Byte(1);
                Writer.Byte(0x1F);
                Writer.Byte(fromSlot);
                Writer.Byte(toSlot);
                break;

            case "MOVE_WAREHOUSE_GOLD":
                Writer.Bool(true);
                Writer.Byte(type);
                Writer.LWord(gold);
                break;

            case "MOVE_GENDER_CHANGE":
                Writer.Byte(1);
                Writer.Byte(fromSlot);
                Writer.Byte(0x13);
                Writer.Byte(2);
                break;

            case "DELETE_ITEM":
                Writer.Byte(1);
                Writer.Byte(type);
                Writer.Byte(fromSlot);
                if (type == 0x0F)
                {
                    Writer.Byte(4);
                }
                break;

            case "DELETE_GOLD":
                Writer.Byte(1);
                Writer.Byte(type);
                Writer.LWord(gold);
                break;
            }
            return(Writer.GetBytes());
        }
예제 #16
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());
        }
예제 #17
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();
        }
예제 #18
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();
        }