Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

BcStorm - Leensters edition - Fixes Thread.

Status
Not open for further replies.
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
This thread can be used to post fixes to this emulator:
Please refrain from posting anything else.
If you want to say thank you for the fix then just click the like button or something.

Here is a fix for the Black screen when you attempt to enter a room that is not a group room.

In GameClientMessageHandler.cs find:

PHP:
else if (currentLoadingRoom.checkGroupRights(this.Session))

Replace that with:
PHP:
else if ((currentLoadingRoom.GroupId>0)&&(currentLoadingRoom.checkGroupRights(this.Session)))
 
Junior Spellweaver
Joined
Nov 21, 2011
Messages
158
Reaction score
43
Hi RageZone!

As most of you should know, I did state in a post, that I was going to get Leensters fix into parts for those who want to use it, but don't feel like they want to use his emulator.

This did take me 2-3 hours to get working, so I hope you all appreciate this:p:

Add:
Code:
using Database_Manager.Database;
Under:
Code:
using System.Threading.Tasks;

Add:
Code:
internal static string HotelLink;
Below:
Code:
internal static string LinkConfig;

GamesClientMessageHandler.cs
Code:
namespace Butterfly.Messages
{
    using Butterfly;
    using Butterfly.Core;
    using Butterfly.HabboHotel.Catalogs;
    using Butterfly.HabboHotel.GameClients;
    using Butterfly.HabboHotel.Games.SnowStorm;
    using Butterfly.HabboHotel.ChatMessageStorage;
    using Butterfly.HabboHotel.Habbo.Guilds;
    using Butterfly.HabboHotel.Habbo.SoundMachine;
    using Butterfly.HabboHotel.Habbo.Users;
    using Butterfly.HabboHotel.Items;
    using Butterfly.HabboHotel.Misc;
    using Butterfly.HabboHotel.Navigators;
    using Butterfly.HabboHotel.Pathfinding;
    using Butterfly.HabboHotel.Pets;
    using Butterfly.HabboHotel.Quests;
    using Butterfly.HabboHotel.RoomBots;
    using Butterfly.HabboHotel.Rooms;
    using Butterfly.HabboHotel.Rooms.Wired;
    using Butterfly.HabboHotel.Support;
    using Butterfly.HabboHotel.Users.Badges;
    using Butterfly.HabboHotel.Users.Messenger;
    using Butterfly.Messages.StaticMessageHandlers;
    using Database_Manager.Database;
    using Database_Manager.Database.Session_Details.Interfaces;

    using HabboEvents;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;

    internal class GameClientMessageHandler
    {
        internal Room CurrentLoadingRoom;
        private int FloodCount;
        private DateTime FloodTime;
        private ClientMessage Request;
        private ServerMessage Response;
        private GameClient Session;

        internal GameClientMessageHandler(GameClient Session)
        {
            this.Session = Session;
            this.Response = new ServerMessage();
        }

        public void AcceptMember()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                int num2 = this.Request.PopWiredInt32();
                Habbo habbo = ButterflyEnvironment.getHabboForId((uint)num2);
                if (habbo != null)
                {
                    Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                    guild.Petitions.Remove((int)habbo.Id);
                    string str = "";
                    foreach (int num3 in guild.Petitions)
                    {
                        str = str + num3 + ";";
                    }
                    if (guild.Petitions.Count > 1)
                    {
                        str = str.Substring(0, str.Length - 1);
                    }
                    guild.Members.Add((int)habbo.Id);
                    if (habbo.FavoriteGuild == 0)
                    {
                        habbo.FavoriteGuild = guild.Id;
                        if (habbo.CurrentRoomId > 0)
                        {
                            if (room == null)
                            {
                                return;
                            }
                            List<RoomUser> list = new List<RoomUser>(ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(habbo.CurrentRoomId).GetRoomUserManager().UserList.Values);
                            ServerMessage message = new ServerMessage(Outgoing.SendGroup);
                            message.AppendInt32(1);
                            message.AppendInt32(guild.Id);
                            message.AppendString(guild.Image);
                            habbo.GetClient().SendMessage(message);
                            ServerMessage message2 = new ServerMessage(Outgoing.SetRoomUser);
                            message2.AppendInt32(1);
                            foreach (RoomUser user in list)
                            {
                                if (user.HabboId == habbo.Id)
                                {
                                    user.Serialize(message2, false);
                                }
                            }
                            room.SendMessage(message2);
                        }
                    }
                    habbo.ImGuilds.Add(guild.Id);
                    guild.GuildRanks.Add((int)habbo.Id, 2);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET FavoriteGroup = '", habbo.FavoriteGuild, "' WHERE Id = '", habbo.Id, "'" }));
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_groups VALUES (NULL, '", habbo.Username, "','", habbo.Id, "','", guild.Id, "','", DateTime.Now.Day, " - ", DateTime.Now.Month, " -  ", DateTime.Now.Year, "', '2')" }));
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE groups SET Petitions = '", str, "' WHERE Id = '", guild.Id, "'" }));
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_stream VALUES (NULL, '", habbo.Id, "','", ButterflyEnvironment.LinkConfig, guild.Image, ".gif','10','", guild.Id, "','0','')" }));
                    }

                    ServerMessage message3 = new ServerMessage(Outgoing.AddNewMember);
                    message3.AppendInt32(guildId);
                    message3.AppendInt32(guild.GuildRanks[num2]);
                    message3.AppendInt32(habbo.Id);
                    message3.AppendString(habbo.Username);
                    message3.AppendString(habbo.Look);
                    message3.AppendString(string.Concat(new object[] { DateTime.Now.Month, " ", DateTime.Now.Day, ", ", DateTime.Now.Year }));
                    this.Session.SendMessage(message3);

                    ServerMessage message4 = new ServerMessage(Outgoing.UpdatePetitionsGuild);
                    message4.AppendInt32(1);
                    message4.AppendInt32(guild.Id);
                    message4.AppendInt32(3);
                    message4.AppendString(guild.Name);
                    this.Session.SendMessage(message4);
                    if (ButterflyEnvironment.GetGame().GetClientManager().GetClient(habbo.Id) != null)
                    {
                        habbo.GetClient().SendMessage(message4);
                    }
                    if ((ButterflyEnvironment.GetGame().GetClientManager().GetClient(habbo.Id) != null) && (room != null))
                    {
                        ServerMessage message5 = new ServerMessage(Outgoing.SetRoomUser);
                        message5.AppendInt32(1);
                        room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id).Serialize(message5, false);
                        room.SendMessage(message5);
                    }
                    ServerMessage message6 = new ServerMessage(Outgoing.SendHtmlColors);
                    message6.AppendInt32(this.Session.GetHabbo().ImGuilds.Count);
                    foreach (int num4 in this.Session.GetHabbo().ImGuilds)
                    {
                        MyGuild guild2 = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(num4);
                        message6.AppendInt32(guild2.Id);
                        message6.AppendString(guild2.Name);
                        message6.AppendString(guild2.Image);
                        message6.AppendString(guild2.HtmlColor1);
                        message6.AppendString(guild2.HtmlColor2);
                        message6.AppendBoolean(guild2.Id == this.Session.GetHabbo().FavoriteGuild);
                    }
                    this.Session.SendMessage(message6);
                    RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId);

                    ServerMessage message7 = new ServerMessage(Outgoing.SendAdvGroupInit);
                    message7.AppendInt32(guild.Id);
                    message7.AppendBoolean(true);
                    message7.AppendInt32(guild.Type);
                    message7.AppendString(guild.Name);
                    message7.AppendString(guild.Description);
                    message7.AppendString(guild.Image);
                    message7.AppendInt32(data.Id);
                    message7.AppendString(data.Name);
                    if (guild.Petitions.Contains((int)habbo.Id))
                    {
                        message7.AppendInt32(2);
                    }
                    else if (!habbo.ImGuilds.Contains(guild.Id))
                    {
                        message7.AppendInt32(0);
                    }
                    else if (habbo.ImGuilds.Contains(guild.Id))
                    {
                        message7.AppendInt32(1);
                    }
                    message7.AppendInt32(guild.Members.Count);
                    message7.AppendBoolean(false);
                    message7.AppendString(guild.DateCreated);

                    message7.AppendBoolean(habbo.Id == guild.OwnerId);

                    if (habbo.ImGuilds.Contains(guild.Id))
                    {
                        if (guild.GuildRanks[(int)habbo.Id] < 2)
                            message7.AppendBoolean(true);
                        else message7.AppendBoolean(false);
                    }
                    else message7.AppendBoolean(false);
                    message7.AppendString(guild.OwnerName);
                    message7.AppendBoolean(true);
                    message7.AppendBoolean(true);
                    message7.AppendInt32(guild.Members.Contains((int)habbo.Id) ? guild.Petitions.Count : 0);
                    habbo.GetClient().SendMessage(message7);
                }
            }
        }

        internal void AcceptRequest()
        {
            if (this.Session.GetHabbo().GetMessenger() != null)
            {
                int num = this.Request.PopWiredInt32();
                for (int i = 0; i < num; i++)
                {
                    uint senderID = this.Request.PopWiredUInt();
                    MessengerRequest request = this.Session.GetHabbo().GetMessenger().GetRequest(senderID);
                    if (request != null)
                    {
                        if (request.To != this.Session.GetHabbo().Id)
                        {
                            break;
                        }
                        if (!this.Session.GetHabbo().GetMessenger().FriendshipExists(request.To))
                        {
                            this.Session.GetHabbo().GetMessenger().CreateFriendship(request.From);
                            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_stream VALUES (NULL, '", this.Session.GetHabbo().Id, "', '','0','", request.From, "','0','')" }));
                                adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_stream VALUES (NULL, '", request.From, "', '','0','", this.Session.GetHabbo().Id, "','0','')" }));
                            }
                        }
                        this.Session.GetHabbo().GetMessenger().HandleRequest(senderID);
                    }
                }
            }
        }

        internal void AcceptTrade()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                Trade userTrade = room.GetUserTrade(this.Session.GetHabbo().Id);
                if (userTrade != null)
                {
                    userTrade.Accept(this.Session.GetHabbo().Id);
                }
            }
        }

        public void ActiveEndedQuest()
        {
            ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().ActiveEndQuest(this.Session);
        }

        internal void AddFavorite()
        {
            if (this.Session.GetHabbo() != null)
            {
                uint roomId = this.Request.PopWiredUInt();
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId);
                if ((((data == null) || (this.Session.GetHabbo().FavoriteRooms.Count >= 30)) || this.Session.GetHabbo().FavoriteRooms.Contains(roomId)) || (data.Type == "public"))
                {
                    this.GetResponse().Init(0x21);
                    this.GetResponse().AppendInt32(-9001);
                }
                else
                {
                    this.GetResponse().Init(Outgoing.FavsUpdate);
                    this.GetResponse().AppendInt32(roomId);
                    this.GetResponse().AppendBoolean(true);
                    this.SendResponse();
                    this.Session.GetHabbo().FavoriteRooms.Add(roomId);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_favorites (user_id,room_id) VALUES (", this.Session.GetHabbo().Id, ",", roomId, ")" }));
                    }
                }
            }
        }

        public void AddNewCdToJuke()
        {
            if (((this.Session != null) && (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().CurrentRoom != null))
            {
                Room currentRoom = this.Session.GetHabbo().CurrentRoom;
                if (currentRoom.CheckRights(this.Session, true))
                {
                    RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
                    if (roomMusicController.PlaylistSize < roomMusicController.PlaylistCapacity)
                    {
                        int num = this.Request.PopWiredInt32();
                        UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem((uint)num);
                        if ((item != null) && (item.GetBaseItem().InteractionType == InteractionType.musicdisc))
                        {
                            SongItem diskItem = new SongItem(item);
                            if (roomMusicController.AddDisk(diskItem) >= 0)
                            {
                                diskItem.SaveToDatabase((int)currentRoom.RoomId);
                                this.Session.GetHabbo().GetInventoryComponent().RemoveItem((uint)num, true);
                                this.Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList<SongInstance>()));
                            }
                        }
                    }
                }
            }
        }

        internal void AddSaddle()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && !room.IsPublic) && (room.AllowPets || room.CheckRights(this.Session, true)))
            {
                uint pId = this.Request.PopWiredUInt();
                RoomItem item = room.GetRoomItemHandler().GetItem(pId);
                if (item != null)
                {
                    uint petId = this.Request.PopWiredUInt();
                    RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                    if (((pet != null) && (pet.PetData != null)) && (pet.PetData.OwnerId == this.Session.GetHabbo().Id))
                    {
                        string str;
                        IQueryAdapter adapter;
                        room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                        if (item.GetBaseItem().Name.Contains("horse_hairdye"))
                        {
                            str = item.GetBaseItem().Name.Split(new char[] { '_' })[2];
                            int num3 = 0x30;
                            num3 += int.Parse(str);
                            pet.PetData.HairDye = num3;
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "UPDATE user_pets SET hairdye = '", pet.PetData.HairDye, "' WHERE id = ", pet.PetData.PetId }));
                            }
                        }
                        else
                        {
                            int num4;
                            if (item.GetBaseItem().Name.Contains("horse_dye"))
                            {
                                string s = item.GetBaseItem().Name.Split(new char[] { '_' })[2];
                                num4 = int.Parse(s);
                                int num5 = (2 + (num4 * 4)) - 4;
                                switch (num4)
                                {
                                    case 13:
                                        num5 = 0x3d;
                                        break;

                                    case 14:
                                        num5 = 0x41;
                                        break;

                                    case 15:
                                        num5 = 0x45;
                                        break;

                                    case 0x10:
                                        num5 = 0x49;
                                        break;
                                }
                                pet.PetData.Race = num5.ToString();
                                using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                {
                                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE user_pets SET race = '", pet.PetData.Race, "' WHERE id = ", pet.PetData.PetId }));
                                }
                            }
                            else if (item.GetBaseItem().Name.Contains("horse_hairstyle"))
                            {
                                str = item.GetBaseItem().Name.Split(new char[] { '_' })[2];
                                num4 = 100;
                                num4 += int.Parse(str);
                                pet.PetData.PetHair = num4;
                                using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                {
                                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE user_pets SET pethair = '", pet.PetData.PetHair, "' WHERE id = ", pet.PetData.PetId }));
                                }
                            }
                            else
                            {
                                string str3 = item.GetBaseItem().Name.Replace("horse_saddle", "");
                                //if (string.IsNullOrEmpty(str3)) str3 = "1";
                                pet.PetData.HaveSaddle = int.Parse(str3);
                                using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                {
                                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE user_pets SET have_saddle = '", str3, "' WHERE id = ", pet.PetData.PetId }));
                                }
                            }
                        }
                        ServerMessage message = new ServerMessage(Outgoing.SerializeMontura);
                        message.AppendInt32(pet.PetData.VirtualId);
                        message.AppendInt32(pet.PetData.PetId);
                        message.AppendInt32(pet.PetData.Type);
                        message.AppendInt32(int.Parse(pet.PetData.Race));
                        message.AppendString(pet.PetData.Color.ToLower());
                        if (pet.PetData.HaveSaddle == 2)
                        {
                            message.AppendInt32(1);
                            message.AppendInt32(3);
                            message.AppendInt32(4);
                            message.AppendInt32(10);
                            message.AppendInt32(0);
                            message.AppendInt32(2);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(3);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                        }
                        else if (pet.PetData.HaveSaddle == 1)
                        {
                            message.AppendInt32(1);
                            message.AppendInt32(3);
                            message.AppendInt32(2);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(3);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(4);
                            message.AppendInt32(9);
                            message.AppendInt32(0);
                        }
                        else
                        {
                            message.AppendInt32(1);
                            message.AppendInt32(2);
                            message.AppendInt32(2);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(3);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                        }
                        message.AppendBoolean(pet.PetData.HaveSaddle != 0);
                        message.AppendBoolean(pet.montandoBol);
                        room.SendMessage(message);
                    }
                }
            }
        }

        internal ServerMessage AddToNewGame(Butterfly.HabboHotel.Games.SnowStorm.SnowStorm War)
        {
            War.WarUsers.Add(this.Session.GetHabbo());
            this.Session.GetHabbo().SnowWar = War;
            ServerMessage message = new ServerMessage(Outgoing.AddToNewGame);
            message.AppendInt32(0);
            message.AppendString("SnowStorm level " + War.WarLevel);
            message.AppendInt32(0);
            message.AppendInt32(War.WarLevel);
            message.AppendInt32(2);
            message.AppendInt32(War.MaxUsers);
            message.AppendString(War.WarOwner.Username);
            message.AppendInt32(0x11);
            message.AppendInt32(War.WarUsers.Count);
            foreach (Habbo habbo in War.WarUsers)
            {
                message.AppendInt32(habbo.Id);
                message.AppendString(habbo.Username);
                message.AppendString(habbo.Look);
                message.AppendString(habbo.Gender.ToLower());
                message.AppendInt32(-1);
                message.AppendInt32(habbo.SnowLevel);
                message.AppendInt32(habbo.SnowPoints);
                message.AppendInt32(1);
            }
            message.AppendInt32(0);
            message.AppendInt32(120);
            return message;
        }

        internal void AnswerDoorbell()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session))
            {
                string username = this.Request.PopFixedString();
                bool flag = this.Request.PopWiredBoolean();
                GameClient clientByUsername = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(username);
                if (clientByUsername != null)
                {
                    if (flag)
                    {
                        clientByUsername.GetHabbo().LoadingChecksPassed = true;
                        clientByUsername.GetMessageHandler().Response.Init(Outgoing.ValidDoorBell);
                        clientByUsername.GetMessageHandler().Response.AppendString("");
                        clientByUsername.GetMessageHandler().SendResponse();
                    }
                    else
                    {
                        clientByUsername.GetMessageHandler().Response.Init(Outgoing.DoorBellNoPerson);
                        clientByUsername.GetMessageHandler().Response.AppendString("");
                        clientByUsername.GetMessageHandler().SendResponse();
                    }
                }
            }
        }

        internal void AnswerInfobusPoll()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            int num = this.Request.PopWiredInt32();
            int currentPollId = room.CurrentPollId;
            DataTable table = null;
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT * FROM infobus_answers WHERE question_id = '" + currentPollId + "'");
                table = adapter.getTable();
                adapter.setQuery(string.Concat(new object[] { "INSERT INTO `infobus_results` (`question_id`, `answer_id`) VALUES ('", currentPollId, "', '", table.Rows[num - 1]["id"], "')" }));
                adapter.insertQuery();
            }
        }

        internal void ApplyEffect()
        {
            this.Session.GetHabbo().GetAvatarEffectsInventoryComponent().ApplyEffect(this.Request.PopWiredInt32());
        }

        internal void ApplyRoomEffect()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(this.Request.PopWiredUInt());
                if (item != null)
                {
                    string s = "floor";
                    if (item.GetBaseItem().Name.ToLower().Contains("wallpaper"))
                    {
                        s = "wallpaper";
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("landscape"))
                    {
                        s = "landscape";
                    }
                    string str2 = s;
                    if (str2 != null)
                    {
                        if (!(str2 == "floor"))
                        {
                            if (str2 == "wallpaper")
                            {
                                room.Wallpaper = item.ExtraData;
                                room.RoomData.Wallpaper = item.ExtraData;
                            }
                            else if (str2 == "landscape")
                            {
                                room.Landscape = item.ExtraData;
                                room.RoomData.Landscape = item.ExtraData;
                            }
                        }
                        else
                        {
                            room.Floor = item.ExtraData;
                            room.RoomData.Floor = item.ExtraData;
                        }
                    }
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery(string.Concat(new object[] { "UPDATE rooms SET ", s, " = @extradata WHERE id = ", room.RoomId }));
                        adapter.addParameter("extradata", item.ExtraData);
                        adapter.runQuery();
                    }
                    this.Session.GetHabbo().GetInventoryComponent().RemoveItem(item.Id, false);
                    ServerMessage message = new ServerMessage(Outgoing.RoomDecoration);
                    message.AppendString(s);
                    message.AppendString(item.ExtraData);
                    room.SendMessage(message);
                }
            }
        }

        internal void BanUser()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                uint pId = this.Request.PopWiredUInt();
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(pId);
                if (((roomUserByHabbo != null) && !roomUserByHabbo.IsBot) && (!roomUserByHabbo.GetClient().GetHabbo().HasFuse("fuse_mod") && !roomUserByHabbo.GetClient().GetHabbo().HasFuse("fuse_no_kick")))
                {
                    room.AddBan(pId);
                    room.GetRoomUserManager().RemoveUserFromRoom(roomUserByHabbo.GetClient(), true, true);
                    this.Session.CurrentRoomUserID = -1;
                }
            }
        }

        public void BuyGroup()
        {
            if ((this.Session != null) && (this.Session.GetHabbo().Credits >= 10))
            {
                List<int> gStates = new List<int>();
                string name = this.Request.PopFixedString();
                string description = this.Request.PopFixedString();
                int roomid = this.Request.PopWiredInt32();
                int color = this.Request.PopWiredInt32();
                int num3 = this.Request.PopWiredInt32();
                this.Request.PopWiredInt32();
                int guildBase = this.Request.PopWiredInt32();
                int guildBaseColor = this.Request.PopWiredInt32();
                int num6 = this.Request.PopWiredInt32();

                for (int i = 0; i < (num6 * 3); i++)
                {
                    int item = this.Request.PopWiredInt32();
                    gStates.Add(item);
                }

                string image = ButterflyEnvironment.GetGame().GetGuilds().GenerateGuildImage(guildBase, guildBaseColor, gStates);
                string htmlColor = ButterflyEnvironment.GetGame().GetGuilds().GetHtmlColor(color);
                string str5 = ButterflyEnvironment.GetGame().GetGuilds().GetHtmlColor(num3);
                string datecreated = DateTime.Now.ToShortDateString();

                int id = (int)this.Session.GetHabbo().Id;

                string username = this.Session.GetHabbo().Username;

                List<int> members = new List<int> {
                    (int) this.Session.GetHabbo().Id
                };

                List<string> joindates = new List<string> {
                    DateTime.Now.Day + " - " + DateTime.Now.Month + " -  " + DateTime.Now.Year
                };

                Room room = ButterflyEnvironment.GetGame().GetRoomManager().LoadRoom((uint)roomid);

                if (room != null)
                {
                    MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().AddGuild(0, name, id, username, description, roomid, image, color, num3, guildBase, guildBaseColor, gStates, htmlColor, str5, datecreated, members, new List<int>(), 0, 0, joindates);

                    room.GroupId = guild.Id;
                    room.GenerateGuild(guild);
                    room.RoomData.GroupId = guild.Id;

                    this.Session.GetHabbo().ImGuilds.Add(guild.Id);
                    this.Session.GetHabbo().FavoriteGuild = guild.Id;

                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET FavoriteGroup = '", guild.Id, "' WHERE Id = '", guild.OwnerId, "'" }));
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_groups VALUES (NULL, '", this.Session.GetHabbo().Username, "','", this.Session.GetHabbo().Id, "','", guild.Id, "','", DateTime.Now.Day, " - ", DateTime.Now.Month, " -  ", DateTime.Now.Year, "', '0')" }));
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_stream VALUES (NULL, '", this.Session.GetHabbo().Id, "','", ButterflyEnvironment.LinkConfig, guild.Image, ".gif','10','", guild.Id, "','0','')" }));
                    }

                    ServerMessage message = new ServerMessage(Outgoing.SerializePurchaseInformation);

                    message.AppendInt32(0x1815);
                    message.AppendString("CREATE_GUILD");
                    message.AppendInt32(10);
                    message.AppendInt32(0);
                    message.AppendInt32(0);
                    message.AppendBoolean(true);
                    message.AppendInt32(0);
                    message.AppendInt32(2);
                    message.AppendBoolean(false);

                    this.Session.SendMessage(message);

                    Habbo habbo = this.Session.GetHabbo();
                    habbo.Credits -= 10;

                    this.Session.GetHabbo().UpdateCreditsBalance();

                    ServerMessage message2 = new ServerMessage(Outgoing.SendHtmlColors);
                    message2.AppendInt32(this.Session.GetHabbo().ImGuilds.Count);

                    foreach (int num10 in this.Session.GetHabbo().ImGuilds)
                    {
                        MyGuild guild2 = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(num10);
                        message2.AppendInt32(guild2.Id);
                        message2.AppendString(guild2.Name);
                        message2.AppendString(guild2.Image);
                        message2.AppendString(guild2.HtmlColor1);
                        message2.AppendString(guild2.HtmlColor2);
                        message2.AppendBoolean(guild2.Id == this.Session.GetHabbo().FavoriteGuild);
                    }

                    this.Session.SendMessage(message2);

                    if ((ButterflyEnvironment.GetGame().GetClientManager().GetClient(habbo.Id) != null) && (room != null))
                    {
                        ServerMessage message3 = new ServerMessage(Outgoing.SetRoomUser);
                        message3.AppendInt32(1);
                        room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id).Serialize(message3, false);

                        room.SendMessage(message3);
                    }

                    ServerMessage message4 = new ServerMessage(Outgoing.UpdateRoom);
                    message4.AppendInt32(guild.RoomId);
                    this.Session.SendMessage(message4);

                    ServerMessage message5 = new ServerMessage(Outgoing.ConfigureWallandFloor);
                    message5.AppendBoolean(room.Hidewall);
                    message5.AppendInt32(room.WallThickness);
                    message5.AppendInt32(room.FloorThickness);
                    this.Session.SendMessage(message5);

                    ServerMessage message6 = new ServerMessage(Outgoing.SendRoomAndGroup);
                    message6.AppendInt32(guild.RoomId);
                    message6.AppendInt32(guild.Id);
                    this.Session.SendMessage(message6);

                    ServerMessage message7 = new ServerMessage(Outgoing.RoomData);
                    message7.AppendBoolean(true);
                    message7.AppendInt32(guild.RoomId);
                    message7.AppendString(room.Name);
                    message7.AppendBoolean(true);
                    message7.AppendInt32(room.OwnerId);
                    message7.AppendString(room.Owner);
                    message7.AppendInt32(room.State);
                    message7.AppendInt32(room.UsersNow);
                    message7.AppendInt32(room.UsersMax);
                    message7.AppendString(room.Description);
                    message7.AppendInt32(0);
                    message7.AppendInt32((room.Category == 0x34) ? 2 : 0);
                    message7.AppendInt32(room.Score);
                    message7.AppendInt32(0);
                    message7.AppendInt32(room.Category);

                    if (room.GetRoomGuild() == null)
                    {
                        message7.AppendInt32(0);
                        message7.AppendInt32(0);
                    }
                    else
                    {
                        message7.AppendInt32(guild.Id);
                        message7.AppendString(guild.Name);
                        message7.AppendString(guild.Image);
                    }

                    message7.AppendString("");
                    message7.AppendInt32(room.TagCount);

                    foreach (string str8 in room.Tags.ToArray())
                    {
                        message7.AppendString(str8);
                    }

                    message7.AppendInt32(0);
                    message7.AppendInt32(0);
                    message7.AppendInt32(0);
                    message7.AppendBoolean(true);
                    message7.AppendBoolean(true);
                    message7.AppendInt32(0);
                    message7.AppendInt32(0);
                    message7.AppendBoolean(false);
                    message7.AppendBoolean(false);
                    message7.AppendBoolean(false);
                    message7.AppendInt32(0);
                    message7.AppendInt32(0);
                    message7.AppendInt32(0);

                    room.SendMessage(message7);
                }
            }
        }

        internal void CancelMountOnPet()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    uint petId = this.Request.PopWiredUInt();
                    RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                    if ((pet != null) && (pet.PetData != null))
                    {
                        roomUserByHabbo.montandoBol = false;
                        roomUserByHabbo.montandoID = 0;
                        pet.montandoBol = false;
                        pet.montandoID = 0;
                        roomUserByHabbo.MoveTo(roomUserByHabbo.X + 1, roomUserByHabbo.Y + 1);
                        roomUserByHabbo.ApplyEffect(-1);
                    }
                }
            }
        }

        internal void CanCreateRoom()
        {
            this.Response.Init(Outgoing.CanCreateRoom);
            this.Response.AppendInt32(0);
            this.Response.AppendInt32(0x1869f);
            this.SendResponse();
        }

        internal void CanGift()
        {
            uint itemId = this.Request.PopWiredUInt();
            if (ButterflyEnvironment.GetGame().GetCatalog().FindItem(itemId) == null)
            {
            }
        }

        internal void ChangeLook()
        {
            if (this.Session.GetHabbo().MutantPenalty)
            {
                this.Session.SendNotif("Because of a penalty or restriction on your account, you are not allowed to change your look.");
            }
            else
            {
                string gender = this.Request.PopFixedString().ToUpper();
                string look = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                if (AntiMutant.ValidateLook(look, gender))
                {
                    ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("CHANGE_FIGURE", this.Session);
                    this.Session.GetHabbo().Look = ButterflyEnvironment.FilterFigure(look);
                    this.Session.GetHabbo().Gender = gender.ToLower();
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery("UPDATE users SET look = @look, gender = @gender WHERE id = " + this.Session.GetHabbo().Id);
                        adapter.addParameter("look", look);
                        adapter.addParameter("gender", gender);
                        adapter.runQuery();
                    }
                    ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_AvatarLooks", 1);
                    this.Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateUserInformation);
                    this.Session.GetMessageHandler().GetResponse().AppendInt32(-1);
                    this.Session.GetMessageHandler().GetResponse().AppendString(this.Session.GetHabbo().Look);
                    this.Session.GetMessageHandler().GetResponse().AppendString(this.Session.GetHabbo().Gender.ToLower());
                    this.Session.GetMessageHandler().GetResponse().AppendString(this.Session.GetHabbo().Motto);
                    this.Session.GetMessageHandler().GetResponse().AppendInt32(this.Session.GetHabbo().AchievementPoints);
                    this.Session.GetMessageHandler().SendResponse();
                    if (this.Session.GetHabbo().InRoom)
                    {
                        Room currentRoom = this.Session.GetHabbo().CurrentRoom;
                        if (currentRoom != null)
                        {
                            RoomUser roomUserByHabbo = currentRoom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                            if (roomUserByHabbo != null)
                            {
                                ServerMessage message = new ServerMessage(Outgoing.UpdateUserInformation);
                                message.AppendInt32(roomUserByHabbo.VirtualId);
                                message.AppendString(this.Session.GetHabbo().Look);
                                message.AppendString(this.Session.GetHabbo().Gender.ToLower());
                                message.AppendString(this.Session.GetHabbo().Motto);
                                message.AppendInt32(this.Session.GetHabbo().AchievementPoints);
                                currentRoom.SendMessage(message);
                            }
                        }
                    }
                }
            }
        }

        internal void ChangeMotto()
        {
            string query = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
            if (query != this.Session.GetHabbo().Motto)
            {
                this.Session.GetHabbo().Motto = query;
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.setQuery("UPDATE users SET motto = @motto WHERE id = '" + this.Session.GetHabbo().Id + "'");
                    adapter.addParameter("motto", query);
                    adapter.runQuery();
                }
                ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("CHANGE_MOTTO", this.Session);
                if (this.Session.GetHabbo().InRoom)
                {
                    Room currentRoom = this.Session.GetHabbo().CurrentRoom;
                    if (currentRoom == null)
                    {
                        return;
                    }
                    RoomUser roomUserByHabbo = currentRoom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                    if (roomUserByHabbo == null)
                    {
                        return;
                    }
                    ServerMessage message = new ServerMessage(Outgoing.UpdateUserInformation);
                    message.AppendInt32(roomUserByHabbo.VirtualId);
                    message.AppendString(this.Session.GetHabbo().Look);
                    message.AppendString(this.Session.GetHabbo().Gender.ToLower());
                    message.AppendString(this.Session.GetHabbo().Motto);
                    message.AppendInt32(this.Session.GetHabbo().AchievementPoints);
                    currentRoom.SendMessage(message);
                }
                ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_Motto", 1);
            }
        }

        internal Butterfly.HabboHotel.Games.SnowStorm.SnowStorm CheckAGame()
        {
            foreach (Butterfly.HabboHotel.Games.SnowStorm.SnowStorm storm in ButterflyEnvironment.GetGame().GetStormWars().Wars.Values)
            {
                if ((storm.WarUsers.Count < 10) && (storm.WarStarted < 1))
                {
                    return storm;
                }
            }
            return null;
        }

        internal void CheckArenaStatic(ServerMessage Message, Butterfly.HabboHotel.Games.SnowStorm.SnowStorm War)
        {
            if (War.WarLevel == 9)
            {
                Message.AppendInt32((int)(20 + War.WarUsers.Count));
                Message.AppendInt32(3);
                Message.AppendInt32(0);
                Message.AppendInt32(0x6400);
                Message.AppendInt32(0xaf00);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0);
                Message.AppendInt32(3);
                Message.AppendInt32(1);
                Message.AppendInt32(0x1c20a);
                Message.AppendInt32(0x1770a);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(1);
                Message.AppendInt32(3);
                Message.AppendInt32(2);
                Message.AppendInt32(0x1c20a);
                Message.AppendInt32(0x11080);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(3);
                Message.AppendInt32(3);
                Message.AppendInt32(3);
                Message.AppendInt32(0x1130a);
                Message.AppendInt32(0x11f80);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(5);
                Message.AppendInt32(3);
                Message.AppendInt32(4);
                Message.AppendInt32(0x1c20a);
                Message.AppendInt32(0x15180);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(6);
                Message.AppendInt32(3);
                Message.AppendInt32(5);
                Message.AppendInt32(0xc800);
                Message.AppendInt32(0x11080);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(7);
                Message.AppendInt32(3);
                Message.AppendInt32(6);
                Message.AppendInt32(0x6400);
                Message.AppendInt32(0x16a80);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(10);
                Message.AppendInt32(3);
                Message.AppendInt32(7);
                Message.AppendInt32(0x1c20a);
                Message.AppendInt32(0xe100);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(14);
                Message.AppendInt32(3);
                Message.AppendInt32(8);
                Message.AppendInt32(0x1c20a);
                Message.AppendInt32(0x12c0a);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(15);
                Message.AppendInt32(3);
                Message.AppendInt32(9);
                Message.AppendInt32(0x15e0a);
                Message.AppendInt32(0x11080);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x10);
                Message.AppendInt32(3);
                Message.AppendInt32(10);
                Message.AppendInt32(0x6400);
                Message.AppendInt32(0xd480);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x11);
                Message.AppendInt32(3);
                Message.AppendInt32(11);
                Message.AppendInt32(0x1c20a);
                Message.AppendInt32(0xbb80);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x12);
                Message.AppendInt32(3);
                Message.AppendInt32(12);
                Message.AppendInt32(0x12c0a);
                Message.AppendInt32(0x11080);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(20);
                Message.AppendInt32(3);
                Message.AppendInt32(13);
                Message.AppendInt32(0x6400);
                Message.AppendInt32(0x11f80);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x15);
                Message.AppendInt32(3);
                Message.AppendInt32(14);
                Message.AppendInt32(0x1130a);
                Message.AppendInt32(0xbb80);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x18);
                Message.AppendInt32(3);
                Message.AppendInt32(15);
                Message.AppendInt32(0x6400);
                Message.AppendInt32(0x1450a);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x19);
                Message.AppendInt32(3);
                Message.AppendInt32(0x10);
                Message.AppendInt32(0x1130a);
                Message.AppendInt32(0x15180);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x1b);
                Message.AppendInt32(3);
                Message.AppendInt32(0x11);
                Message.AppendInt32(0x1130a);
                Message.AppendInt32(0xed80);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x1d);
                Message.AppendInt32(3);
                Message.AppendInt32(0x12);
                Message.AppendInt32(0x6400);
                Message.AppendInt32(0xfa00);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(30);
                Message.AppendInt32(3);
                Message.AppendInt32(0x13);
                Message.AppendInt32(0xfa00);
                Message.AppendInt32(0x11080);
                Message.AppendInt32(12);
                Message.AppendInt32(12);
                Message.AppendInt32(0x23);
            }
        }

        public void CheckNameToChange()
        {
            string userName = this.Request.PopFixedString();
            Habbo habbo = ButterflyEnvironment.getHabboForName(userName);
            ServerMessage message = new ServerMessage(Outgoing.CheckName);
            if (userName.Length < 4)
            {
                message.AppendInt32(2);
                message.AppendString(userName);
                message.AppendInt32(3);
                message.AppendString("Jefa" + userName);
                message.AppendString("Con" + userName);
                message.AppendString(userName + "Risa");
            }
            else if (habbo != null)
            {
                message.AppendInt32(5);
                message.AppendString(userName);
                message.AppendInt32(3);
                message.AppendString("Jefa" + userName);
                message.AppendString("Con" + userName);
                message.AppendString(userName + "Risa");
            }
            else
            {
                message.AppendInt32(0);
                message.AppendString(userName);
                message.AppendInt32(0);
            }
            this.Session.SendMessage(message);
        }

        internal void CheckPetName()
        {
            string petName = this.Request.PopFixedString();
            this.Session.GetMessageHandler().GetResponse().Init(Outgoing.CheckPetName);
            this.Session.GetMessageHandler().GetResponse().AppendInt32(Catalog.CheckPetName(petName) ? 0 : 2);
            this.Session.GetMessageHandler().GetResponse().AppendString(petName);
            this.Session.GetMessageHandler().SendResponse();
        }

        internal void CheckRelease()
        {
            //Console.WriteLine("Client connected.. " + this.Request.PopFixedString());
            this.Session.bannertimmer = DateTime.Now;
        }

        internal void ClearRoomLoading()
        {
            this.Session.GetHabbo().LoadingRoom = 0;
            this.Session.GetHabbo().LoadingChecksPassed = false;
        }

        internal void CommandsPet()
        {
            uint petId = this.Request.PopWiredUInt();
            RoomUser pet = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).GetRoomUserManager().GetPet(petId);
            if ((pet != null) && (pet.PetData != null))
            {
                this.GetResponse().Init(0x25d);
                this.GetResponse().AppendInt32(petId);
                int level = pet.PetData.Level;
                this.GetResponse().AppendInt32(0x12);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(1);
                this.GetResponse().AppendInt32(2);
                this.GetResponse().AppendInt32(3);
                this.GetResponse().AppendInt32(4);
                this.GetResponse().AppendInt32(0x11);
                this.GetResponse().AppendInt32(5);
                this.GetResponse().AppendInt32(6);
                this.GetResponse().AppendInt32(7);
                this.GetResponse().AppendInt32(8);
                this.GetResponse().AppendInt32(9);
                this.GetResponse().AppendInt32(10);
                this.GetResponse().AppendInt32(11);
                this.GetResponse().AppendInt32(12);
                this.GetResponse().AppendInt32(13);
                this.GetResponse().AppendInt32(14);
                this.GetResponse().AppendInt32(15);
                this.GetResponse().AppendInt32(0x10);
                int i = 0;
                while (level > i)
                {
                    i++;
                    this.GetResponse().AppendInt32(i);
                }
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(1);
                this.GetResponse().AppendInt32(2);
                this.SendResponse();
            }
        }

        internal void CompleteTrade()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                Trade userTrade = room.GetUserTrade(this.Session.GetHabbo().Id);
                if (userTrade != null)
                {
                    userTrade.CompleteTrade(this.Session.GetHabbo().Id);
                }
            }
        }

        internal void CreateRoom()
        {
            string name = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
            string model = this.Request.PopFixedString();
            RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().CreateRoom(this.Session, name, model);
            if (data != null)
            {
                this.Response.Init(Outgoing.OnCreateRoomInfo);
                this.Response.AppendInt32(data.Id);
                this.Response.AppendString(data.Name);
                this.SendResponse();
            }
        }

        internal void CreateStream()
        {
            string str = this.Request.PopFixedString();
        }

        internal void Dance()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    roomUserByHabbo.Unidle();
                    int i = this.Request.PopWiredInt32();
                    if (((i < 0) || (i > 4)) || (!this.Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip") && (i > 1)))
                    {
                        i = 0;
                    }
                    if ((i > 0) && (roomUserByHabbo.CarryItemID > 0))
                    {
                        roomUserByHabbo.CarryItem(0);
                    }
                    roomUserByHabbo.DanceId = i;
                    ServerMessage message = new ServerMessage(Outgoing.Dance);
                    message.AppendInt32(roomUserByHabbo.VirtualId);
                    message.AppendInt32(i);
                    room.SendMessage(message);
                    ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("DANCE", this.Session);
                }
            }
        }

        internal void Sit()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            int tries = 0;
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    roomUserByHabbo.Unidle();

                    if (!roomUserByHabbo.Statusses.ContainsKey("sit") && !roomUserByHabbo.Statusses.ContainsKey("lay"))
                    {
                        if ((roomUserByHabbo.RotBody % 2) == 0)
                        {
                            if (roomUserByHabbo == null)
                            {
                                return;
                            }

                            try
                            {
                                roomUserByHabbo.Statusses.Add("sit", "1.0");
                                roomUserByHabbo.Z -= 0.35;
                                roomUserByHabbo.acostadoBol = true;
                                roomUserByHabbo.UpdateNeeded = true;
                            }
                            catch { }

                            return;

                        }

                        else
                        {
                            if (tries <= 1)
                            {
                                roomUserByHabbo.RotBody--;
                                tries++;
                                Sit();
                            }
                            else
                            {
                                Session.SendNotif("You cannot sit diagonally, try it again please");
                                tries = 0;
                            }

                        }

                    }

                    else if (roomUserByHabbo.acostadoBol == true)
                    {

                        roomUserByHabbo.Z += 0.35;
                        roomUserByHabbo.Statusses.Remove("sit");
                        roomUserByHabbo.Statusses.Remove("1.0");
                        roomUserByHabbo.acostadoBol = false;
                        roomUserByHabbo.UpdateNeeded = true;

                    }
                }
            }
        }

        internal void DeclineRequest()
        {
            if (this.Session.GetHabbo().GetMessenger() != null)
            {
                int num = this.Request.PopWiredInt32();
                int num2 = this.Request.PopWiredInt32();
                if ((num == 0) && (num2 == 1))
                {
                    uint sender = this.Request.PopWiredUInt();
                    this.Session.GetHabbo().GetMessenger().HandleRequest(sender);
                }
                else
                {
                    this.Session.GetHabbo().GetMessenger().HandleAllRequests();
                }
            }
        }

        internal void DeletePendingCFH()
        {
            if (ButterflyEnvironment.GetGame().GetModerationTool().UsersHasPendingTicket(this.Session.GetHabbo().Id))
            {
                ButterflyEnvironment.GetGame().GetModerationTool().DeletePendingTicketForUser(this.Session.GetHabbo().Id);
                this.GetResponse().Init(320);
                this.SendResponse();
            }
        }

        internal void DeletePostit()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                if ((item != null) && (item.GetBaseItem().InteractionType == InteractionType.postit))
                {
                    room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                }
            }
        }

        internal void DeleteRoom()
        {
            Func<RoomData, bool> predicate = null;
            uint RoomId = this.Request.PopWiredUInt();
            if (((this.Session != null) && (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().UsersRooms != null))
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);
                if ((room != null) && ((room.Owner == this.Session.GetHabbo().Username) || (this.Session.GetHabbo().Rank > 6)))
                {
                    if (this.Session.GetHabbo().GetInventoryComponent() != null)
                    {
                        this.Session.GetHabbo().GetInventoryComponent().AddItemArray(room.GetRoomItemHandler().RemoveAllFurniture(this.Session));
                    }
                    RoomData roomData = room.RoomData;
                    ButterflyEnvironment.GetGame().GetRoomManager().UnloadRoom(room);
                    ButterflyEnvironment.GetGame().GetRoomManager().QueueVoteRemove(roomData);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery("DELETE FROM rooms WHERE id = " + RoomId);
                        adapter.runFastQuery("DELETE FROM user_favorites WHERE room_id = " + RoomId);
                        adapter.runFastQuery("DELETE items, items_extradata, items_rooms FROM items_rooms INNER JOIN items ON (items.item_id = items_rooms.item_id) LEFT JOIN items_extradata ON (items_extradata.item_id = items.item_id) WHERE items_rooms.room_id = " + RoomId);
                        adapter.runFastQuery("DELETE FROM room_rights WHERE room_id = " + RoomId);
                        adapter.runFastQuery("UPDATE users SET home_room = '0' WHERE home_room = " + RoomId);
                    }
                    if ((this.Session.GetHabbo().Rank > 5) && (this.Session.GetHabbo().Username != roomData.Owner))
                    {
                        ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(this.Session.GetHabbo().Username, roomData.Name, "Room deletion", string.Format("Deleted room ID {0}", roomData.Id));
                    }
                    if (predicate == null)
                    {
                        predicate = p => p.Id == RoomId;
                    }
                    RoomData item = this.Session.GetHabbo().UsersRooms.Where<RoomData>(predicate).SingleOrDefault<RoomData>();
                    if (item != null)
                    {
                        this.Session.GetHabbo().UsersRooms.Remove(item);
                    }
                }
            }
        }

        internal void Destroy()
        {
            this.Session = null;
        }

        public void EditAjustes()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                if (room != null)
                {
                    guild.Type = this.Request.PopWiredInt32();
                    guild.Petitions.Clear();
                    guild.RightsType = this.Request.PopWiredInt32();
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE groups SET Typee = '", guild.Type, "', RightsType = '", guild.RightsType, "', Petitions = '' WHERE Id = '", guild.Id, "'" }));
                    }
                    this.SaveSettingsPackets(guild, room);
                }
            }
        }

        public void EditColores()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                if (room != null)
                {
                    guild.CustomColor1 = this.Request.PopWiredInt32();
                    guild.CustomColor2 = this.Request.PopWiredInt32();
                    guild.HtmlColor1 = ButterflyEnvironment.GetGame().GetGuilds().GetHtmlColor(guild.CustomColor1);
                    guild.HtmlColor2 = ButterflyEnvironment.GetGame().GetGuilds().GetHtmlColor(guild.CustomColor2);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE groups SET CustomColor1 = '", guild.CustomColor1, "', CustomColor2 = '", guild.CustomColor2, "', HtmlColor1 = '", guild.HtmlColor1, "', HtmlColor2 = '", guild.HtmlColor2, "' WHERE Id = '", guild.Id, "'" }));
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE items SET group_data = '", guildId, ";", guild.HtmlColor1, ";", guild.HtmlColor2, "' WHERE group_data LIKE '", guildId, ";%'" }));
                    }
                    this.SaveSettingsPackets(guild, room);

                    //Session.SendNotif(guild.CustomColor1.ToString() + " " + guild.HtmlColor1.ToString() + guild.CustomColor2.ToString() + " " + guild.HtmlColor2.ToString());


                }
            }
        }

        public void EditGuild()
        {
            if (!this.Session.GetHabbo().ColorsSended)
            {
                this.OpenGuildPage();
                this.Session.GetHabbo().ColorsSended = true;
            }
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            ServerMessage message = new ServerMessage(Outgoing.SendGestionGroup);
            message.AppendInt32((int)(this.Session.GetHabbo().UsersRooms.Count - this.GetMyRoomsGuilds()));
            foreach (RoomData data in this.Session.GetHabbo().UsersRooms)
            {
                if (data.GroupId == 0)
                {
                    message.AppendInt32(data.Id);
                    message.AppendString(data.Name);
                    message.AppendBoolean(false);
                }
            }
            message.AppendBoolean(true);
            message.AppendInt32(guild.Id);
            message.AppendString(guild.Name);
            message.AppendString(guild.Description);
            message.AppendInt32(guild.RoomId);
            message.AppendInt32(guild.CustomColor1);
            message.AppendInt32(guild.CustomColor2);
            message.AppendInt32(guild.Type);
            message.AppendInt32(guild.RightsType);
            message.AppendBoolean(false);
            message.AppendString("");
            message.AppendInt32(5);
            message.AppendInt32(guild.GuildBase);
            message.AppendInt32(guild.GuildBaseColor);
            message.AppendInt32(4);
            message.AppendInt32(guild.GuildStates[0]);
            message.AppendInt32(guild.GuildStates[1]);
            message.AppendInt32(guild.GuildStates[2]);
            message.AppendInt32(guild.GuildStates[3]);
            message.AppendInt32(guild.GuildStates[4]);
            message.AppendInt32(guild.GuildStates[5]);
            message.AppendInt32(guild.GuildStates[6]);
            message.AppendInt32(guild.GuildStates[7]);
            message.AppendInt32(guild.GuildStates[8]);
            message.AppendInt32(guild.GuildStates[9]);
            message.AppendInt32(guild.GuildStates[10]);
            message.AppendInt32(guild.GuildStates[11]);
            message.AppendString(guild.Image);
            message.AppendInt32(guild.Members.Count);
            message.AppendInt32(guild.Petitions.Count);
            this.Session.SendMessage(message);
        }

        public void EditIdentidad()
        {
            int guildId = this.Request.PopWiredInt32();
            string str = this.Request.PopFixedString();
            string str2 = this.Request.PopFixedString();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                if (room != null)
                {
                    guild.Name = str;
                    guild.Description = str2;
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery(string.Concat(new object[] { "UPDATE groups SET Name = @groupname, Description = @groupdesc WHERE Id = '", guild.Id, "'" }));
                        adapter.addParameter("groupname", guild.Name);
                        adapter.addParameter("groupdesc", guild.Description);
                        adapter.runQuery();
                    }
                    this.SaveSettingsPackets(guild, room);
                }
            }
        }

        public void EditPlaca()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                if (room != null)
                {
                    this.Request.PopWiredInt32();
                    guild.GuildBase = this.Request.PopWiredInt32();
                    guild.GuildBaseColor = this.Request.PopWiredInt32();
                    this.Request.PopWiredInt32();
                    guild.GuildStates.Clear();
                    string str = "";
                    for (int i = 0; i < 12; i++)
                    {
                        int item = this.Request.PopWiredInt32();
                        guild.GuildStates.Add(item);
                        str = str + item + ";";
                    }
                    str = str.Substring(0, str.Length - 1);
                    guild.Image = ButterflyEnvironment.GetGame().GetGuilds().GenerateGuildImage(guild.GuildBase, guild.GuildBaseColor, guild.GuildStates);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE groups SET Image = '", guild.Image, "', GuildBase = '", guild.GuildBase, "', GuildBaseColor = '", guild.GuildBaseColor, "', GuildStates = '", str, "' WHERE Id = '", guild.Id, "'" }));
                    }
                    this.SaveSettingsPackets(guild, room);
                }
            }
        }

        internal void EnableEffect()
        {
            this.Session.GetHabbo().GetAvatarEffectsInventoryComponent().EnableEffect(this.Request.PopWiredInt32());
        }

        public void EndConfirmBuy()
        {
            int guildId = this.Request.PopWiredInt32();
            bool flag = this.Request.PopWiredBoolean();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId);
                if (data != null)
                {
                    ServerMessage message;
                    if (!flag)
                    {
                        try
                        {
                            message = new ServerMessage(Outgoing.SendAdvGroupInit);
                            message.AppendInt32(guild.Id);
                            message.AppendBoolean(true);
                            message.AppendInt32(guild.Type);
                            message.AppendString(guild.Name);
                            message.AppendString(guild.Description);
                            message.AppendString(guild.Image);
                            message.AppendInt32(data.Id);
                            message.AppendString(data.Name);
                            if (guild.Petitions.Contains((int)this.Session.GetHabbo().Id))
                            {
                                message.AppendInt32(2);
                            }
                            else if (!this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                message.AppendInt32(0);
                            }
                            else if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                message.AppendInt32(1);
                            }
                            message.AppendInt32(guild.Members.Count);
                            message.AppendBoolean(false);
                            message.AppendString(guild.DateCreated);

                            message.AppendBoolean(this.Session.GetHabbo().Id == guild.OwnerId);

                            if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                                    message.AppendBoolean(true);
                                else message.AppendBoolean(false);
                            }
                            else message.AppendBoolean(false);
                            message.AppendString(guild.OwnerName);
                            message.AppendBoolean(false);
                            message.AppendBoolean(false);
                            message.AppendInt32(guild.Petitions.Count);
                            this.Session.SendMessage(message);
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            message = new ServerMessage(Outgoing.SendAdvGroupInit);
                            message.AppendInt32(guild.Id);
                            message.AppendBoolean(false);
                            message.AppendInt32(guild.Type);
                            message.AppendString(guild.Name);
                            message.AppendString(guild.Description);
                            message.AppendString(guild.Image);
                            message.AppendInt32(data.Id);
                            message.AppendString(data.Name);
                            if (guild.Petitions.Contains((int)this.Session.GetHabbo().Id))
                            {
                                message.AppendInt32(2);
                            }
                            else if (!this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                message.AppendInt32(0);
                            }
                            else if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                message.AppendInt32(1);
                            }
                            message.AppendInt32(guild.Members.Count);
                            message.AppendBoolean(false);
                            message.AppendString(guild.DateCreated);

                            message.AppendBoolean(this.Session.GetHabbo().Id == guild.OwnerId);

                            if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                                    message.AppendBoolean(true);
                                else message.AppendBoolean(false);
                            }
                            else message.AppendBoolean(false);
                            message.AppendString(guild.OwnerName);
                            message.AppendBoolean(true);
                            message.AppendBoolean(true);
                            message.AppendInt32(guild.Members.Contains((int)this.Session.GetHabbo().Id) ? guild.Petitions.Count : 0);
                            this.Session.SendMessage(message);
                        }
                        catch { }
                    }
                }

            }

        }

        public void EndQuiz()
        {
            this.Session.GetHabbo().PassedQuiz = true;
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery("UPDATE users SET passed_quiz = '1' WHERE id = '" + this.Session.GetHabbo().Id + "'");
            }
            ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_SafetyQuizGraduate", 1);
            this.GetResponse().Init(Outgoing.EndTalentPractise);
            this.GetResponse().AppendString("citizenship");
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendString("A1 KUMIANKKA");
            this.GetResponse().AppendInt32(0);
            this.SendResponse();
            this.GetResponse().Init(Outgoing.Allowances);
            this.GetResponse().AppendInt32(7);
            this.GetResponse().AppendString("VOTE_IN_COMPETITIONS");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("TRADE");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("CITIZEN");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("SAFE_CHAT");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("FULL_CHAT");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("CALL_ON_HELPERS");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("USE_GUIDE_TOOL");
            this.GetResponse().AppendBoolean(false);
            this.GetResponse().AppendString("requirement.unfulfilled.helper_level_4");
            this.GetResponse().AppendString("JUDGE_CHAT_REVIEWS");
            this.GetResponse().AppendBoolean(false);
            this.GetResponse().AppendString("requirement.unfulfilled.helper_level_6");
            this.SendResponse();
        }

        public void EndQuizQuestions()
        {
            string str = this.Request.PopFixedString();
            int num = this.Request.PopWiredInt32();
            int num2 = this.Request.PopWiredInt32();
            int num3 = this.Request.PopWiredInt32();
            int num4 = this.Request.PopWiredInt32();
            int num5 = this.Request.PopWiredInt32();
            int num6 = this.Request.PopWiredInt32();
            List<int> list = new List<int>();
            if (num2 != 3)
            {
                list.Add(5);
            }
            if (num3 != 3)
            {
                list.Add(7);
            }
            if (num4 != 2)
            {
                list.Add(0);
            }
            if (num5 != 1)
            {
                list.Add(1);
            }
            if (num6 != 1)
            {
                list.Add(6);
            }
            ServerMessage message = new ServerMessage(Outgoing.CheckQuiz);
            message.AppendString("HabboWay1");
            message.AppendInt32(list.Count);
            foreach (int num7 in list)
            {
                message.AppendInt32(num7);
            }
            this.Session.SendMessage(message);
        }

        internal void EnterInfobus()
        {
            this.Response.Init(0x51);
            this.Response.AppendString(LanguageLocale.GetValue("user.enterinfobus"));
            this.SendResponse();
        }

        internal void EnterInquiredRoom()
        {
        }

        internal void enterOnRoom()
        {
            uint id = this.Request.PopWiredUInt();
            string password = this.Request.PopFixedString();
            this.PrepareRoomForUser(id, password);
        }

        public void ExitGuild()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                Habbo habbo = ButterflyEnvironment.getHabboForId((uint)this.Request.PopWiredInt32());
                if (habbo != null)
                {
                    guild.Members.Remove((int)habbo.Id);
                    if (habbo.FavoriteGuild == guild.Id)
                    {
                        habbo.FavoriteGuild = 0;
                        if (habbo.CurrentRoomId > 0)
                        {
                            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                            if (room == null)
                            {
                                return;
                            }
                            List<RoomUser> list = new List<RoomUser>(ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(habbo.CurrentRoomId).GetRoomUserManager().UserList.Values);
                            ServerMessage message = new ServerMessage(Outgoing.SendGroup);
                            message.AppendInt32(0);
                            habbo.GetClient().SendMessage(message);
                            ServerMessage message2 = new ServerMessage(Outgoing.SetRoomUser);
                            message2.AppendInt32(1);
                            foreach (RoomUser user in list)
                            {
                                if (user.HabboId == habbo.Id)
                                {
                                    user.Serialize(message2, false);
                                    user.RemoveStatus("flatctrl 1");
                                    user.AddStatus("flatctrl 0", "");
                                    user.UpdateNeeded = true;
                                }
                            }
                            room.SendMessage(message2);
                        }
                    }
                    habbo.ImGuilds.Remove(guild.Id);
                    guild.GuildRanks.Remove((int)habbo.Id);

                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET FavoriteGroup = '", habbo.FavoriteGuild, "' WHERE Id = '", habbo.Id, "'" }));
                        adapter.runFastQuery("DELETE FROM user_groups WHERE GroupId = '" + guildId + "' AND userid = " + habbo.Id);
                    }
                    if (habbo.Id != this.Session.GetHabbo().Id)
                        LoadMembersPetitions(0, guildId, 0, "");

                    else
                    {
                        RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId);
                        ServerMessage message;

                        message = new ServerMessage(Outgoing.SendAdvGroupInit);
                        message.AppendInt32(guild.Id);
                        message.AppendBoolean(true);
                        message.AppendInt32(guild.Type);
                        message.AppendString(guild.Name);
                        message.AppendString(guild.Description);
                        message.AppendString(guild.Image);
                        message.AppendInt32(data.Id);
                        message.AppendString(data.Name);
                        if (guild.Petitions.Contains((int)this.Session.GetHabbo().Id))
                        {
                            message.AppendInt32(2);
                        }
                        else if (!this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            message.AppendInt32(0);
                        }
                        else if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            message.AppendInt32(1);
                        }
                        message.AppendInt32(guild.Members.Count);
                        message.AppendBoolean(false);
                        message.AppendString(guild.DateCreated);
                        message.AppendBoolean(this.Session.GetHabbo().Id == guild.OwnerId);

                        if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                                message.AppendBoolean(true);
                            else message.AppendBoolean(false);
                        }
                        else message.AppendBoolean(false);
                        message.AppendString(guild.OwnerName);
                        message.AppendBoolean(true);
                        message.AppendBoolean(true);
                        message.AppendInt32(guild.Members.Contains((int)this.Session.GetHabbo().Id) ? guild.Petitions.Count : 0);
                        habbo.GetClient().SendMessage(message);

                    }

                }
            }
        }

        internal void ExtraVipWindow()
        {
            CatalogPage page = ButterflyEnvironment.GetGame().GetCatalog().GetPage(5);
            if ((((page != null) && page.Enabled) && (page.Visible && !page.ComingSoon)) && (page.MinRank <= this.Session.GetHabbo().Rank))
            {
                int i = this.Request.PopWiredInt32();
                if (page.Layout.Equals("club_buy"))
                {
                    ServerMessage message = new ServerMessage(Outgoing.ClubComposer);
                    message.AppendInt32(page.Items.Values.Count);
                    foreach (CatalogItem item in page.Items.Values)
                    {
                        item.SerializeClub(message, this.Session);
                    }
                    message.AppendInt32(i);
                    this.Session.SendMessage(message);
                }
            }
        }

        internal void FollowBuddy()
        {
            uint userID = this.Request.PopWiredUInt();
            GameClient clientByUserID = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(userID);
            if (((clientByUserID != null) && (clientByUserID.GetHabbo() != null)) && clientByUserID.GetHabbo().InRoom)
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(clientByUserID.GetHabbo().CurrentRoomId);
                Room room2 = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                if (room != null)
                {
                    uint roomId = room.RoomId;
                    if (ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId) != null)
                    {
                        this.GetResponse().Init(Outgoing.FollowBuddy);
                        this.GetResponse().AppendBoolean(room.IsPublic);
                        this.GetResponse().AppendInt32(clientByUserID.GetHabbo().CurrentRoomId);
                        this.SendResponse();
                        this.GetResponse().Init(Outgoing.RoomData);
                        this.GetResponse().AppendBoolean(false);
                        this.GetResponse().AppendInt32(room.RoomId);
                        this.GetResponse().AppendString(room.Name);
                        this.GetResponse().AppendBoolean(true);
                        this.GetResponse().AppendInt32(room.OwnerId);
                        this.GetResponse().AppendString(room.Owner);
                        this.GetResponse().AppendInt32(room.State);
                        this.GetResponse().AppendInt32(room.UsersNow);
                        this.GetResponse().AppendInt32(room.UsersMax);
                        this.GetResponse().AppendString(room.Description);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32((room.Category == 0x34) ? 2 : 0);
                        this.GetResponse().AppendInt32(room.Score);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32(room.Category);
                        if (room.GroupId == 0)
                        {
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(0);
                        }
                        else
                        {
                            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(room.GroupId);
                            this.GetResponse().AppendInt32(guild.Id);
                            this.GetResponse().AppendString(guild.Name);
                            this.GetResponse().AppendString(guild.Image);
                        }
                        this.GetResponse().AppendString("");
                        this.GetResponse().AppendInt32(room.TagCount);
                        foreach (string str in room.Tags)
                        {
                            this.GetResponse().AppendString(str);
                        }
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendBoolean(true);
                        this.GetResponse().AppendBoolean(true);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendBoolean(false);
                        this.GetResponse().AppendBoolean(false);
                        this.GetResponse().AppendBoolean(false);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32(0);
                        this.GetResponse().AppendInt32(0);
                        this.SendResponse();
                    }
                }
            }
        }

        internal void FriendsListUpdate()
        {
            if (this.Session.GetHabbo().GetMessenger() == null)
            {
            }
        }

        internal void GetAchievements()
        {
            ButterflyEnvironment.GetGame().GetAchievementManager().GetList(this.Session, this.Request);
        }

        internal void GetBadges()
        {
            this.Session.SendMessage(this.Session.GetHabbo().GetBadgeComponent().Serialize());
        }

        internal void GetBalance()
        {
            this.Session.GetHabbo().UpdateCreditsBalance();
            this.Session.GetHabbo().UpdateActivityPointsBalance(false);
        }

        internal void GetCataData1()
        {
            this.GetResponse().Init(Outgoing.ShopData1);
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(0x2710);
            this.GetResponse().AppendInt32(0x30);
            this.GetResponse().AppendInt32(7);
            this.SendResponse();
        }

        internal void BotsInventary()
        {
            this.GetResponse().Init(Outgoing.ShopData1);
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(0x2710);
            this.GetResponse().AppendInt32(0x30);
            this.GetResponse().AppendInt32(7);
            this.SendResponse();
        }

        internal void GetCataData2()
        {
            int num;
            this.GetResponse().Init(Outgoing.ShopData2);
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(10);
            for (num = 0xd2c; num < 0xd36; num++)
            {
                this.GetResponse().AppendInt32(num);
            }
            this.GetResponse().AppendInt32(7);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(2);
            this.GetResponse().AppendInt32(3);
            this.GetResponse().AppendInt32(4);
            this.GetResponse().AppendInt32(5);
            this.GetResponse().AppendInt32(6);
            this.GetResponse().AppendInt32(11);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(2);
            this.GetResponse().AppendInt32(3);
            this.GetResponse().AppendInt32(4);
            this.GetResponse().AppendInt32(5);
            this.GetResponse().AppendInt32(6);
            this.GetResponse().AppendInt32(7);
            this.GetResponse().AppendInt32(8);
            this.GetResponse().AppendInt32(9);
            this.GetResponse().AppendInt32(10);
            this.GetResponse().AppendInt32(7);
            for (num = 0xbb; num < 0xc2; num++)
            {
                this.GetResponse().AppendInt32(num);
            }
            this.SendResponse();
            this.GetResponse().Init(Outgoing.Offer);
            this.GetResponse().AppendInt32(100);
            this.GetResponse().AppendInt32(6);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(1);
            this.GetResponse().AppendInt32(2);
            this.GetResponse().AppendInt32(40);
            this.GetResponse().AppendInt32(0x63);
            this.SendResponse();
        }

        internal void GetCatalogIndex()
        {
            this.Session.SendMessage(ButterflyEnvironment.GetGame().GetCatalog().GetIndexMessageForRank(this.Session.GetHabbo().Rank));
        }

        internal void GetCatalogPage()
        {
            CatalogPage page = ButterflyEnvironment.GetGame().GetCatalog().GetPage(this.Request.PopWiredInt32());
            if ((((page != null) && page.Enabled) && (page.Visible && !page.ComingSoon)) && (page.MinRank <= this.Session.GetHabbo().Rank))
            {
                if (page.Caption == "Ecotron")
                {
                    this.Session.SendNotif("El Ecotr\x00f3n est\x00e1 fuera de servicio actualmente.");
                }
                else if (!(!page.ClubOnly || this.Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")))
                {
                    this.Session.SendNotif(LanguageLocale.GetValue("catalog.missingclubmembership"));
                }
                else
                {
                    if (page.Layout == "recycler")
                    {
                        this.Session.SendNotif("El ecotron no se encuentra disponible por el momento, \x00a1esp\x00e9ralo pronto!");
                    }
                    this.Session.SendMessage(page.GetMessage);
                }
            }
        }

        internal void GetEvents()
        {
            if (this.Session.GetHabbo() != null)
            {
                int category = int.Parse(this.Request.PopFixedString());
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeEventListing(category));
            }
        }

        internal void GetFavoriteRooms()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeFavoriteRooms(this.Session));
            }
        }

        internal void GetFlatCats()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeFlatCategories(this.Session));
            }
        }

        internal void GetFriendsRooms()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeNavigator(this.Session, -4));
            }
        }

        internal void GetGame()
        {
            int i = this.Request.PopWiredInt32();
            int num2 = this.Request.PopWiredInt32();
            if (this.Session.GetHabbo().CurrentRoomId > 0)
            {
                ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).GetRoomUserManager().RemoveUserFromRoom(this.Session, false, false);
            }
            ServerMessage message = new ServerMessage(Outgoing.GetRankInGame);
            message.AppendInt32(i);
            if (this.Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
            {
                message.AppendInt32(-1);
            }
            else
            {
                message.AppendInt32(3);
            }
            message.AppendInt32(0);
            this.Session.SendMessage(message);
        }

        internal void GetGames()
        {
            if ((this.Session.GetHabbo() != null) && ((this.Session.GetHabbo().InRoom && (this.Session.GetHabbo().CurrentRoomId > 0)) && (this.Session.CurrentRoomUserID > 0)))
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                if (room != null)
                {
                    room.GetRoomUserManager().RemoveUserFromRoom(this.Session, true, false);
                }
                this.Session.CurrentRoomUserID = -1;
                ServerMessage message = new ServerMessage(Outgoing.SendGroup);
                message.AppendInt32(0);
                this.Session.SendMessage(message);
            }

            this.GetResponse().Init(0x81f);
            this.GetResponse().AppendInt32(5);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendString("snowwar");
            this.GetResponse().AppendString("93d4f3");
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString(ButterflyEnvironment.HotelLink + "r63b/c_images/gamecenter_snowwar/");
            this.GetResponse().AppendInt32(3);
            this.GetResponse().AppendString("basejump");
            this.GetResponse().AppendString("68bbd2");
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString(ButterflyEnvironment.HotelLink + "r63b/c_images/gamecenter_basejump/");
            this.GetResponse().AppendInt32(4);
            this.GetResponse().AppendString("slotcar");
            this.GetResponse().AppendString("4a95df");
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString(ButterflyEnvironment.HotelLink + "r63b/c_images/gamecenter_slotcar/");
            this.GetResponse().AppendInt32(8);
            this.GetResponse().AppendString("Sulake_bestofturku");
            this.GetResponse().AppendString("0092b7");
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString(ButterflyEnvironment.HotelLink + "r63b/c_images/gamecenter_Sulake_bestofturku/");
            this.GetResponse().AppendInt32(9);
            this.GetResponse().AppendString("ChatRepublic_ssk");
            this.GetResponse().AppendString("fdc50d");
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString(ButterflyEnvironment.HotelLink + "r63b/c_images/gamecenter_ChatRepublic_ssk/");
            this.SendResponse();
        }

        internal void GetGuildFavorite()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                this.Session.GetHabbo().FavoriteGuild = guildId;
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET FavoriteGroup = '", guildId, "' WHERE Id = '", this.Session.GetHabbo().Id, "'" }));
                }
                ServerMessage message = new ServerMessage(Outgoing.UpdatePetitionsGuild);
                message.AppendInt32(0);
                message.AppendInt32(guild.Id);
                message.AppendInt32(2);
                message.AppendString(guild.Name);
                if (this.Session.GetHabbo().CurrentRoomId > 0)
                {
                    ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).SendMessage(message);
                }
                else
                {
                    this.Session.SendMessage(message);
                }
                ServerMessage message2 = new ServerMessage(Outgoing.SendGroup);
                message2.AppendInt32(1);
                message2.AppendInt32(guild.Id);
                message2.AppendString(guild.Image);
                if (this.Session.GetHabbo().CurrentRoomId > 0)
                {
                    ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).SendMessage(message2);
                }
                else
                {
                    this.Session.SendMessage(message2);
                }
                ServerMessage message3 = new ServerMessage(Outgoing.RemoveGuildFavorite);
                message3.AppendInt32((int)this.Session.GetHabbo().Id);
                this.Session.SendMessage(message3);
            }
        }

        internal void GetHelpCategories()
        {
            this.Session.SendMessage(ButterflyEnvironment.GetGame().GetHelpTool().SerializeIndex());
        }

        internal void GetHighRatedRooms()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeNavigator(this.Session, -2));
            }
        }

        internal void GetInventory()
        {
            QueuedServerMessage message = new QueuedServerMessage(this.Session.GetConnection());
            message.appendResponse(this.Session.GetHabbo().GetInventoryComponent().SerializeFloorItemInventory());
            message.appendResponse(this.Session.GetHabbo().GetInventoryComponent().SerializeWallItemInventory());
            message.sendResponse();
        }

        internal void GetMoodlight()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                if (room.MoodlightData == null)
                {
                    foreach (RoomItem item in room.GetRoomItemHandler().mWallItems.Values)
                    {
                        if (item.GetBaseItem().InteractionType == InteractionType.dimmer)
                        {
                            room.MoodlightData = new MoodlightData(item.Id);
                        }
                    }
                }
                if (room.MoodlightData != null)
                {
                    this.Response.Init(Outgoing.DimmerData);
                    this.Response.AppendInt32(room.MoodlightData.Presets.Count);
                    this.Response.AppendInt32(room.MoodlightData.CurrentPreset);
                    int i = 0;
                    foreach (MoodlightPreset preset in room.MoodlightData.Presets)
                    {
                        i++;
                        this.Response.AppendInt32(i);
                        this.Response.AppendInt32((int)(int.Parse(ButterflyEnvironment.BoolToEnum(preset.BackgroundOnly)) + 1));
                        this.Response.AppendString(preset.ColorCode);
                        this.Response.AppendInt32(preset.ColorIntensity);
                    }
                    this.SendResponse();
                }
            }
        }

        public void GetMusicData()
        {
            try
            {
                int num = this.Request.PopWiredInt32();
                List<SongData> songs = new List<SongData>();
                for (int i = 0; i < num; i++)
                {
                    SongData song = SongManager.GetSong(this.Request.PopWiredInt32());
                    if (song != null)
                    {
                        songs.Add(song);
                    }
                }
                this.Session.SendMessage(JukeboxDiscksComposer.Compose(songs));
                songs.Clear();
                songs = null;
            }
            catch
            {
            }
        }

        public int GetMyRoomsGuilds()
        {
            int num = 0;
            foreach (RoomData data in this.Session.GetHabbo().UsersRooms)
            {
                if (data.GroupId != 0)
                {
                    num++;
                }
            }
            return num;
        }

        internal void GetOwnRooms()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeNavigator(this.Session, -3));
            }
        }

        internal void GetPetInfo()
        {
            if ((this.Session.GetHabbo() != null) && (this.Session.GetHabbo().CurrentRoom != null))
            {
                RoomUser pet = this.Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetPet(this.Request.PopWiredUInt());
                if ((pet == null) || (pet.PetData == null))
                {
                    this.Session.SendNotif(LanguageLocale.GetValue("user.petinfoerror"));
                }
                else
                {
                    this.Session.SendMessage(pet.PetData.SerializeInfo());
                }
            }
        }

        internal void GetPetsInventory()
        {
            if (this.Session.GetHabbo().GetInventoryComponent() != null)
            {
                this.Session.SendMessage(this.Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
            }
        }

        internal int GetPetTrainNumber(int Level)
        {
            switch (Level)
            {
                case 0:
                    return 2;

                case 1:
                    return 4;

                case 2:
                    return 5;

                case 3:
                    return 6;

                case 4:
                    return 7;

                case 5:
                    return 8;

                case 6:
                    return 9;

                case 7:
                    return 10;

                case 8:
                    return 11;

                case 9:
                    return 12;

                case 10:
                    return 13;

                case 11:
                    return 13;

                case 12:
                    return 14;

                case 13:
                    return 14;

                case 14:
                    return 15;

                case 15:
                    return 15;

                case 0x10:
                    return 0x10;

                case 0x11:
                    return 0x10;

                case 0x12:
                    return 0x11;

                case 0x13:
                    return 0x11;

                case 20:
                    return 0x11;
            }
            return 0x11;
        }

        internal void GetPopularRooms()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeNavigator(this.Session, int.Parse(this.Request.PopFixedString())));
            }
        }

        internal void GetPopularTags()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializePopularRoomTags());
            }
        }

        internal void GetPubs()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializePublicRooms());
            }
        }

        internal void GetRecentRooms()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeRecentRooms(this.Session));
            }
        }

        internal void GetRecyclerRewards()
        {
            this.GetResponse().Init(0x1fa);
            this.GetResponse().AppendInt32(5);
            for (uint i = 5; i >= 1; i--)
            {
                List<EcotronReward> list;
                this.GetResponse().AppendInt32(i);
                if (i <= 1)
                {
                    this.GetResponse().AppendInt32(0);
                }
                else
                {
                    switch (i)
                    {
                        case 2:
                            this.GetResponse().AppendInt32(4);
                            goto Label_00C4;

                        case 3:
                            this.GetResponse().AppendInt32(40);
                            goto Label_00C4;

                        case 4:
                            this.GetResponse().AppendInt32(200);
                            break;
                    }
                    if (i == 4)
                    {
                        this.GetResponse().AppendInt32(200);
                    }
                    else if (i >= 5)
                    {
                        this.GetResponse().AppendInt32(0x7d0);
                    }
                }
            Label_00C4:
                list = ButterflyEnvironment.GetGame().GetCatalog().GetEcotronRewardsForLevel(i);
                this.GetResponse().AppendInt32(list.Count);
                foreach (EcotronReward reward in list)
                {
                    this.GetResponse().AppendString(reward.GetBaseItem().Type.ToString().ToLower());
                    this.GetResponse().AppendInt32(reward.DisplayId);
                }
            }
            this.SendResponse();
        }

        internal ServerMessage GetResponse()
        {
            return this.Response;
        }

        internal void GetRoomData2()
        {
            try
            {
                QueuedServerMessage message = new QueuedServerMessage(this.Session.GetConnection());
                if ((this.Session.GetHabbo().LoadingRoom > 0) && (this.CurrentLoadingRoom != null))
                {
                    RoomData roomData = this.CurrentLoadingRoom.RoomData;
                    if (roomData != null)
                    {
                        if (roomData.Model == null)
                        {
                            this.Session.SendNotif(LanguageLocale.GetValue("room.missingmodeldata"));
                            this.Session.SendMessage(new ServerMessage(Outgoing.OutOfRoom));
                            this.ClearRoomLoading();
                        }
                        else
                        {
                            message.appendResponse(this.CurrentLoadingRoom.GetGameMap().Model.GetHeightmap());
                            message.appendResponse(this.CurrentLoadingRoom.GetGameMap().Model.SerializeRelativeHeightmap());
                            message.sendResponse();
                        }
                    }

                }
            }
            catch (Exception exception)
            {
                Logging.LogException(string.Concat(new object[] { "Unable to load room ID [", this.Session.GetHabbo().LoadingRoom, "] ", exception.ToString() }));
                this.Session.SendNotif(LanguageLocale.GetValue("room.roomdataloaderror"));
            }
        }

        internal void GetRoomData3()
        {
            if (((this.Session.GetHabbo().LoadingRoom > 0) && this.Session.GetHabbo().LoadingChecksPassed) && (this.CurrentLoadingRoom != null))
            {
                if (!(((this.CurrentLoadingRoom.UsersNow + 1) <= this.CurrentLoadingRoom.UsersMax) || this.Session.GetHabbo().HasFuse("fuse_enter_full_rooms")))
                {
                    this.Session.SendNotif(LanguageLocale.GetValue("room.fullerror"));
                }
                else
                {
                    this.ClearRoomLoading();
                    QueuedServerMessage message = new QueuedServerMessage(this.Session.GetConnection());
                    if ((this.CurrentLoadingRoom.Type == "private") || (this.CurrentLoadingRoom.Type == "public"))
                    {
                        RoomItem[] source = this.CurrentLoadingRoom.GetRoomItemHandler().mFloorItems.Values.ToArray<RoomItem>();
                        RoomItem[] itemArray2 = this.CurrentLoadingRoom.GetRoomItemHandler().mWallItems.Values.ToArray<RoomItem>();
                        this.Response.Init(Outgoing.SerializeFloorItems);
                        if (source.Count<RoomItem>() > 0)
                        {
                            this.Response.AppendInt32(1);
                            this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId);
                            this.Response.AppendString(this.CurrentLoadingRoom.Owner);
                        }
                        else
                        {
                            this.Response.AppendInt32(0);
                        }
                        this.Response.AppendInt32(source.Length);
                        foreach (RoomItem item in source)
                        {
                            item.Serialize(this.Response, (int)item.placedBy);
                        }
                        message.appendResponse(this.GetResponse());
                        this.CurrentLoadingRoom.MovedThinksObH = true;
                        this.Response.Init(Outgoing.SerializeWallItems);
                        if (itemArray2.Count<RoomItem>() > 0)
                        {
                            this.Response.AppendInt32(1);
                            this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId);
                            this.Response.AppendString(this.CurrentLoadingRoom.Owner);
                        }
                        else
                        {
                            this.Response.AppendInt32(0);
                        }
                        this.Response.AppendInt32(itemArray2.Length);
                        foreach (RoomItem item in itemArray2)
                        {
                            item.Serialize(this.Response, (int)item.placedBy);
                        }
                        message.appendResponse(this.GetResponse());

                        Array.Clear(source, 0, source.Length);
                        Array.Clear(itemArray2, 0, itemArray2.Length);
                        source = null;
                        itemArray2 = null;
                    }
                    this.CurrentLoadingRoom.GetRoomUserManager().AddUserToRoom(this.Session, false);
                    message.sendResponse();
                }
            }
        }

        internal void GetRoomEditData()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                this.GetResponse().Init(Outgoing.RoomDataEdit);
                this.GetResponse().AppendInt32(room.RoomId);
                this.GetResponse().AppendString(room.Name);
                this.GetResponse().AppendString(room.Description);
                this.GetResponse().AppendInt32(room.State);
                this.GetResponse().AppendInt32(room.Category);
                this.GetResponse().AppendInt32(room.UsersMax);
                this.GetResponse().AppendInt32(((room.RoomData.Model.MapSizeX * room.RoomData.Model.MapSizeY) > 100) ? 50 : 0x19);
                this.GetResponse().AppendInt32(room.TagCount);
                foreach (string str in room.Tags.ToArray())
                {
                    this.GetResponse().AppendString(str);
                }
                this.GetResponse().AppendInt32(room.UsersWithRights.Count);
                this.GetResponse().AppendInt32(room.AllowPets ? 1 : 0);
                this.GetResponse().AppendInt32(room.AllowPetsEating ? 1 : 0);
                this.GetResponse().AppendInt32(room.AllowWalkthrough ? 1 : 0);
                this.GetResponse().AppendInt32(room.Hidewall ? 1 : 0);
                this.GetResponse().AppendInt32(room.WallThickness);
                this.GetResponse().AppendInt32(room.FloorThickness);
                this.SendResponse();
                if (room.UsersWithRights.Count > 0)
                {
                    this.GetResponse().Init(Outgoing.GetPowerList);
                    this.GetResponse().AppendInt32(room.RoomData.Id);
                    this.GetResponse().AppendInt32(room.UsersWithRights.Count);
                    foreach (uint num in room.UsersWithRights)
                    {
                        Habbo habbo = ButterflyEnvironment.getHabboForId(num);
                        this.GetResponse().AppendInt32(habbo.Id);
                        this.GetResponse().AppendString(habbo.Username);
                    }
                    this.SendResponse();
                }
            }
        }

        internal void GetRoomInfo()
        {
            if (this.Session.GetHabbo() != null)
            {
                uint roomId = this.Request.PopWiredUInt();
                bool flag = this.Request.PopWiredBoolean();
                bool flag2 = this.Request.PopWiredBoolean();
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId);
                if (data != null)
                {
                    this.GetResponse().Init(0x1c6);
                    this.GetResponse().AppendInt32(0);
                    data.Serialize(this.GetResponse(), false);
                    this.SendResponse();
                }
            }
        }

        internal void GetRoomsWithFriends()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeNavigator(this.Session, -5));
            }
        }

        internal void GetSubscriptionData()
        {
            this.GetResponse().Init(Outgoing.SerializeClub);
            this.GetResponse().AppendString("club_habbo");
            if (this.Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
            {
                double expireTime = this.Session.GetHabbo().GetSubscriptionManager().GetSubscription("habbo_vip").ExpireTime;
                double num2 = expireTime - ButterflyEnvironment.GetUnixTimestamp();
                int num3 = (int)Math.Ceiling((double)(num2 / 86400.0));
                int i = num3 / 0x1f;
                if (i >= 1)
                {
                    i--;
                }
                this.GetResponse().AppendInt32((int)(num3 - (i * 0x1f)));
                this.GetResponse().AppendInt32(2);
                this.GetResponse().AppendInt32(i);
                this.GetResponse().AppendInt32(1);
                this.GetResponse().AppendBoolean(true);
                this.GetResponse().AppendBoolean(true);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0x1ef);
            }
            else
            {
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendBoolean(false);
                this.GetResponse().AppendBoolean(true);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
            }
            this.SendResponse();
        }

        internal void GetTopicsInCategory()
        {
            uint categoryId = this.Request.PopWiredUInt();
            HelpCategory category = ButterflyEnvironment.GetGame().GetHelpTool().GetCategory(categoryId);
            if (category != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetHelpTool().SerializeCategory(category));
            }
        }

        internal void GetTrainerPanel()
        {
            uint petId = this.Request.PopWiredUInt();
            Pet pet = null;
            Room currentRoom = this.Session.GetHabbo().CurrentRoom;
            if ((currentRoom != null) && ((pet = currentRoom.GetRoomUserManager().GetPet(petId).PetData) != null))
            {
                int level = pet.Level;
                pet = null;
                this.GetResponse().Init(Outgoing.PetTrainPanel);
                this.GetResponse().AppendInt32(petId);
                this.GetResponse().AppendInt32(0x11);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(14);
                this.GetResponse().AppendInt32(0x2b);
                this.GetResponse().AppendInt32(0x2c);
                this.GetResponse().AppendInt32(2);
                this.GetResponse().AppendInt32(3);
                this.GetResponse().AppendInt32(6);
                this.GetResponse().AppendInt32(7);
                this.GetResponse().AppendInt32(10);
                this.GetResponse().AppendInt32(12);
                this.GetResponse().AppendInt32(11);
                this.GetResponse().AppendInt32(15);
                this.GetResponse().AppendInt32(0x10);
                this.GetResponse().AppendInt32(0x18);
                this.GetResponse().AppendInt32(0x19);
                this.GetResponse().AppendInt32(0x1a);
                this.GetResponse().AppendInt32(0x2d);
                int petTrainNumber = this.GetPetTrainNumber(level);
                this.GetResponse().AppendInt32(petTrainNumber);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(14);
                if (level > 0)
                {
                    this.GetResponse().AppendInt32(0x2b);
                    this.GetResponse().AppendInt32(0x2c);
                }
                if (level > 1)
                {
                    this.GetResponse().AppendInt32(2);
                }
                if (level > 2)
                {
                    this.GetResponse().AppendInt32(3);
                }
                if (level > 3)
                {
                    this.GetResponse().AppendInt32(6);
                }
                if (level > 4)
                {
                    this.GetResponse().AppendInt32(7);
                }
                if (level > 5)
                {
                    this.GetResponse().AppendInt32(10);
                }
                if (level > 6)
                {
                    this.GetResponse().AppendInt32(12);
                }
                if (level > 7)
                {
                    this.GetResponse().AppendInt32(11);
                }
                if (level > 8)
                {
                    this.GetResponse().AppendInt32(15);
                }
                if (level > 9)
                {
                    this.GetResponse().AppendInt32(0x10);
                }
                if (level > 12)
                {
                    this.GetResponse().AppendInt32(0x18);
                }
                if (level > 13)
                {
                    this.GetResponse().AppendInt32(0x19);
                }
                if (level > 15)
                {
                    this.GetResponse().AppendInt32(0x1a);
                }
                if (level > 0x11)
                {
                    this.GetResponse().AppendInt32(0x2d);
                }
                this.SendResponse();
            }
        }

        internal void GetUserBadges()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Request.PopWiredUInt());
                if (((roomUserByHabbo != null) && !roomUserByHabbo.IsBot) && (roomUserByHabbo.GetClient() != null))
                {
                    this.Response.Init(Outgoing.GetUserBadges);
                    this.Response.AppendInt32(roomUserByHabbo.GetClient().GetHabbo().Id);
                    this.Response.AppendInt32(roomUserByHabbo.GetClient().GetHabbo().GetBadgeComponent().EquippedCount);
                    foreach (Badge badge in roomUserByHabbo.GetClient().GetHabbo().GetBadgeComponent().BadgeList.Values)
                    {
                        if (badge.Slot > 0)
                        {
                            this.Response.AppendInt32(badge.Slot);
                            this.Response.AppendString(badge.Code);
                        }
                    }
                    this.Response.AppendInt32(10);
                    this.Response.AppendInt32(10);
                    this.Response.AppendInt32(10);

                    this.SendResponse();
                }
            }
        }

        internal void GetUserInfo()
        {
            this.GetResponse().Init(Outgoing.HabboInfomation);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().Id);
            this.GetResponse().AppendString(this.Session.GetHabbo().Username);
            this.GetResponse().AppendString(this.Session.GetHabbo().Look);
            this.GetResponse().AppendString(this.Session.GetHabbo().Gender.ToUpper());
            this.GetResponse().AppendString(this.Session.GetHabbo().Motto);
            this.GetResponse().AppendString(this.Session.GetHabbo().RealName);
            this.GetResponse().AppendBoolean(false);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().Respect);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().DailyRespectPoints);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().DailyPetRespectPoints);
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString(this.Session.GetHabbo().LastOnline);
            this.GetResponse().AppendBoolean(this.Session.GetHabbo().CanChangeName);
            this.GetResponse().AppendBoolean(false);
            this.SendResponse();
            this.GetResponse().Init(Outgoing.Allowances);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().PassedQuiz ? 7 : 5);
            this.GetResponse().AppendString("VOTE_IN_COMPETITIONS");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("TRADE");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("CITIZEN");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            if (this.Session.GetHabbo().PassedQuiz)
            {
                this.GetResponse().AppendString("SAFE_CHAT");
                this.GetResponse().AppendBoolean(true);
                this.GetResponse().AppendString("");
                this.GetResponse().AppendString("FULL_CHAT");
                this.GetResponse().AppendBoolean(true);
                this.GetResponse().AppendString("");
            }
            this.GetResponse().AppendString("CALL_ON_HELPERS");
            this.GetResponse().AppendBoolean(true);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("USE_GUIDE_TOOL");
            this.GetResponse().AppendBoolean(false);
            this.GetResponse().AppendString("requirement.unfulfilled.helper_level_4");
            this.GetResponse().AppendString("JUDGE_CHAT_REVIEWS");
            this.GetResponse().AppendBoolean(false);
            this.GetResponse().AppendString("requirement.unfulfilled.helper_level_6");
            this.SendResponse();
            this.GetResponse().Init(Outgoing.AchievementPoints);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().AchievementPoints);
            this.SendResponse();
            this.InitMessenger();
            this.SendAllowances();
        }

        internal void GetUserTags()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Request.PopWiredUInt());
                if ((roomUserByHabbo != null) && !roomUserByHabbo.IsBot)
                {
                    this.Response.Init(Outgoing.GetUserTags);
                    this.Response.AppendInt32(roomUserByHabbo.GetClient().GetHabbo().Id);
                    this.Response.AppendInt32(roomUserByHabbo.GetClient().GetHabbo().Tags.Count);
                    foreach (string str in roomUserByHabbo.GetClient().GetHabbo().Tags)
                    {
                        this.Response.AppendString(str);
                    }
                    this.SendResponse();
                }
            }
        }

        internal void GetWardrobe()
        {
            this.GetResponse().Init(Outgoing.WardrobeData);
            this.GetResponse().AppendInt32(this.Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip") ? 1 : 0);
            if (this.Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
            {
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.setQuery("SELECT slot_id, look, gender FROM user_wardrobe WHERE user_id = " + this.Session.GetHabbo().Id);
                    DataTable table = adapter.getTable();
                    if (table == null)
                    {
                        this.GetResponse().AppendInt32(0);
                    }
                    else
                    {
                        this.GetResponse().AppendInt32(table.Rows.Count);
                        foreach (DataRow row in table.Rows)
                        {
                            this.GetResponse().AppendInt32(Convert.ToUInt32(row["slot_id"]));
                            this.GetResponse().AppendString((string)row["look"]);
                            this.GetResponse().AppendString(row["gender"].ToString().ToUpper());
                        }
                    }
                }
                this.SendResponse();
            }
        }

        internal void GiveHanditem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    RoomUser user2 = room.GetRoomUserManager().GetRoomUserByHabbo(this.Request.PopWiredUInt());
                    if ((user2 != null) && ((roomUserByHabbo.CarryItemID > 0) && (roomUserByHabbo.CarryTimer > 0)))
                    {
                        user2.CarryItem(roomUserByHabbo.CarryItemID);
                        roomUserByHabbo.CarryItem(0);
                    }
                }
            }
        }

        internal void GiveRespect()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && (this.Session.GetHabbo().DailyRespectPoints > 0))
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Request.PopWiredUInt());
                if (((roomUserByHabbo != null) && (roomUserByHabbo.GetClient().GetHabbo().Id != this.Session.GetHabbo().Id)) && !roomUserByHabbo.IsBot)
                {
                    ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("GIVE_RESPECT", this.Session);
                    ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_RespectGiven", 1);
                    ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(roomUserByHabbo.GetClient(), "ACH_RespectEarned", 1);
                    Habbo habbo = this.Session.GetHabbo();
                    habbo.DailyRespectPoints--;
                    Habbo habbo2 = roomUserByHabbo.GetClient().GetHabbo();
                    habbo2.Respect++;
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery("UPDATE users SET respect = respect + 1 WHERE id = " + roomUserByHabbo.GetClient().GetHabbo().Id);
                        adapter.runFastQuery("UPDATE users SET daily_respect_points = daily_respect_points - 1 WHERE id = " + this.Session.GetHabbo().Id);
                    }
                    ServerMessage message = new ServerMessage(Outgoing.Action);
                    message.AppendInt32(room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id).VirtualId);
                    message.AppendInt32(7);
                    room.SendMessage(message);
                    ServerMessage message2 = new ServerMessage(Outgoing.GiveRespect);
                    message2.AppendInt32(roomUserByHabbo.GetClient().GetHabbo().Id);
                    message2.AppendInt32(roomUserByHabbo.GetClient().GetHabbo().Respect);
                    room.SendMessage(message2);
                }
            }
        }

        internal void GiveRights(uint uid = 0)
        {
            uint pId;

            if (uid == 0)
                pId = this.Request.PopWiredUInt();
            else
                pId = uid;

            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                Habbo habbo = ButterflyEnvironment.getHabboForId(pId);
                if ((((room != null) && room.CheckRights(this.Session, true)) && (habbo != null)))
                {
                    if (room.UsersWithRights.Contains(pId))
                    {
                        this.Session.SendNotif(LanguageLocale.GetValue("user.giverights.error"));
                    }
                    else
                    {
                        room.UsersWithRights.Add(pId);
                        try
                        {
                            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO room_rights (room_id,user_id) VALUES (", room.RoomId, ",", pId, ")" }));
                            }
                        }
                        catch
                        {
                        }
                        this.Response.Init(Outgoing.GivePowers);
                        this.Response.AppendInt32(room.RoomId);
                        this.Response.AppendInt32(pId);
                        this.Response.AppendString(habbo.Username);
                        this.SendResponse();

                        RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(pId);
                        if (roomUserByHabbo != null)
                        {
                            ServerMessage message = new ServerMessage(Outgoing.RoomRightsLevel);
                            message.AppendInt32(1);
                            roomUserByHabbo.GetClient().SendMessage(message);
                            roomUserByHabbo.RemoveStatus("flatctrl 0");
                            roomUserByHabbo.AddStatus("flatctrl 1", "");
                            roomUserByHabbo.UpdateNeeded = true;
                        }
                    }
                }
            }
        }

        internal void GoToHotelView()
        {
            try
            {
                if ((this.Session.GetHabbo() != null) && ((this.Session.GetHabbo().InRoom && (this.Session.GetHabbo().CurrentRoomId > 0)) && (this.Session.CurrentRoomUserID > 0)))
                {
                    Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                    if (room != null)
                    {
                        room.GetRoomUserManager().RemoveUserFromRoom(this.Session, true, false);
                    }
                    this.Session.CurrentRoomUserID = -1;
                }
            }
            catch
            {
            }
        }

        internal void HandlePurchase()
        {
            int pageId = this.Request.PopWiredInt32();
            uint itemId = this.Request.PopWiredUInt();
            string extraData = this.Request.PopFixedString();
            int priceAmount = this.Request.PopWiredInt32();
            ButterflyEnvironment.GetGame().GetCatalog().HandlePurchase(this.Session, pageId, itemId, extraData, priceAmount, false, "", "", 0, 0, 0, false);
        }

        internal void HandleRequest(ClientMessage request)
        {
            if (ButterflyEnvironment.diagPackets)
            {
                DateTime now = DateTime.Now;
                this.Request = request;
                StaticClientMessageHandler.HandlePacket(this, request);
                TimeSpan span = (TimeSpan)(DateTime.Now - now);
                if (span.TotalMilliseconds > ButterflyEnvironment.timeout)
                {
                    Console.WriteLine(string.Concat(new object[] { "Packet ", request.Id, " took ", span.Milliseconds, "ms to run. Packetdata: ", request.ToString() }));
                }
            }
            else
            {
                this.Request = request;
                StaticClientMessageHandler.HandlePacket(this, request);
            }
        }

        internal void IgnoreUser()
        {
            if (this.Session.GetHabbo().CurrentRoom != null)
            {
                string username = this.Request.PopFixedString();
                Habbo habbo = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(username).GetHabbo();
                if ((habbo != null) && !this.Session.GetHabbo().MutedUsers.Contains(habbo.Id))
                {
                    this.Session.GetHabbo().MutedUsers.Add(habbo.Id);
                    this.Response.Init(Outgoing.UpdateIgnoreStatus);
                    this.Response.AppendInt32(1);
                    this.Response.AppendString(username);
                    this.SendResponse();
                }
            }
        }

        internal void InitCrypto()
        {
            this.Session.TimePingedReceived = DateTime.Now;
            this.Response.Init(Outgoing.SendBannerMessageComposer);
            this.Response.AppendString("12f449917de4f94a8c48dbadd92b6276");
            this.Response.AppendBoolean(false);
            this.SendResponse();
        }

        internal void InitHelpTool()
        {
            this.Session.SendMessage(ButterflyEnvironment.GetGame().GetHelpTool().SerializeFrontpage());
        }

        internal void InitMessenger()
        {
            this.Session.GetHabbo().InitMessenger();
        }

        internal void InitSecretKey()
        {
            this.Session.TimePingedReceived = DateTime.Now;
            this.Response.Init(Outgoing.SecretKeyComposer);
            this.Response.AppendString("24231219992253632572058933470468103090824667747608911151318774416044820318109");
            this.SendResponse();
        }

        internal void InitStream()
        {
            int id = this.Request.PopWiredInt32();
            DataTable table = null;
            if (id <= 1)
            {
                id = (int)this.Session.GetHabbo().Id;
            }
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT * FROM user_stream WHERE UserId = '" + id + "' ORDER BY Id DESC LIMIT 13");
                table = adapter.getTable();
            }
            ServerMessage message = new ServerMessage(Outgoing.InitStream);
            message.AppendInt32((ButterflyEnvironment.HotelStreamMessage == "") ? (table.Rows.Count + 1) : (table.Rows.Count + 2));
            foreach (DataRow row in table.Rows)
            {
                Habbo habbo = ButterflyEnvironment.getHabboForId(Convert.ToUInt32(row["UserId"]));
                message.AppendInt32((int)row["Id"]);
                message.AppendInt32((int)row["Type"]);
                message.AppendString(habbo.Id.ToString());
                message.AppendString(habbo.Username);
                message.AppendString(habbo.Gender.ToLower());
                if (((int)row["Type"]) == 0)
                {
                    string im = ButterflyEnvironment.StreamLink + ButterflyEnvironment.GetGame().GetClientManager().GetLookById(Convert.ToUInt32(row["FriendId"])) + ".gif";
                    message.AppendString((string)im);
                }
                else
                {
                    message.AppendString((string)row["Image"]);
                }
                message.AppendInt32(10);
                message.AppendInt32(5);
                message.AppendInt32((int)row["Likes"]);
                message.AppendBoolean(true);
                message.AppendBoolean(true);
                message.AppendBoolean(false);
                if (((int)row["Type"]) == 0)
                {
                    Habbo habbo2 = ButterflyEnvironment.getHabboForId(Convert.ToUInt32(row["FriendId"]));
                    message.AppendString(habbo2.Id.ToString());
                    message.AppendString(habbo2.Username);
                }
                else if (((int)row["Type"]) == 10)
                {
                    MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(Convert.ToInt32(row["FriendId"]));
                    message.AppendString(guild.RoomId.ToString());
                    message.AppendString(guild.Id.ToString());
                    message.AppendString(ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId).Name);
                    message.AppendString(guild.Name.ToString());
                    message.AppendInt32(0);
                    message.AppendInt32(0);
                }
            }
            if (ButterflyEnvironment.HotelStreamMessage != "")
            {
                message.AppendInt32(0);
                message.AppendInt32(4);
                message.AppendString("-1");
                message.AppendString("");
                message.AppendString("null");
                message.AppendString("");
                message.AppendInt32(0);
                message.AppendInt32(6);
                message.AppendInt32(0);
                message.AppendBoolean(true);
                message.AppendBoolean(false);
                message.AppendBoolean(false);
                message.AppendString(ButterflyEnvironment.HotelStreamMessage);
                message.AppendString(ButterflyEnvironment.HotelLink);
            }
            message.AppendInt32(0);
            message.AppendInt32(4);
            message.AppendString("-1");
            message.AppendString("");
            message.AppendString("null");
            message.AppendString("");
            message.AppendInt32(0);
            message.AppendInt32(6);
            message.AppendInt32(0);
            message.AppendBoolean(true);
            message.AppendBoolean(false);
            message.AppendBoolean(false);
            message.AppendString("Welcome back to Brick-hotel.com! We hope you enjoy your stay here!");
            message.AppendString("http://brick-hotel.com");
            this.Session.SendMessage(message);
        }

        internal void InitTrade()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                RoomUser roomUserByVirtualId = room.GetRoomUserManager().GetRoomUserByVirtualId(this.Request.PopWiredInt32());
                if (((roomUserByVirtualId != null) && (roomUserByVirtualId.GetClient() != null)) && (roomUserByVirtualId.GetClient().GetHabbo() != null))
                {
                    bool flag = false;
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery("SELECT block_trade FROM users WHERE id = " + roomUserByVirtualId.GetClient().GetHabbo().Id);
                        flag = ButterflyEnvironment.EnumToBool(adapter.getString());
                    }
                    if (flag)
                    {
                        this.Session.SendNotif(LanguageLocale.GetValue("user.tradedisabled"));
                    }
                    else
                    {
                        room.TryStartTrade(roomUserByHabbo, roomUserByVirtualId);
                    }
                }
            }
        }

        internal void KickBot()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                RoomUser roomUserByVirtualId = room.GetRoomUserManager().GetRoomUserByVirtualId(this.Request.PopWiredInt32());
                if ((roomUserByVirtualId != null) && roomUserByVirtualId.IsBot)
                {
                    room.GetRoomUserManager().RemoveBot(roomUserByVirtualId.VirtualId, true);
                }
            }
        }

        internal void KickUser()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session))
            {
                uint pId = this.Request.PopWiredUInt();
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(pId);
                if (((roomUserByHabbo != null) && !roomUserByHabbo.IsBot) && ((!room.CheckRights(roomUserByHabbo.GetClient(), true) && !roomUserByHabbo.GetClient().GetHabbo().HasFuse("fuse_mod")) && !roomUserByHabbo.GetClient().GetHabbo().HasFuse("fuse_no_kick")))
                {
                    room.GetRoomUserManager().RemoveUserFromRoom(roomUserByHabbo.GetClient(), true, true);
                    roomUserByHabbo.GetClient().CurrentRoomUserID = -1;
                }
            }
        }

        internal void LeaveGame()
        {
            if (((this.Session != null) || (this.Session.GetHabbo() != null)) && ((this.Session.GetHabbo().SnowWar != null) && this.Session.GetHabbo().SnowWar.WarUsers.Contains(this.Session.GetHabbo())))
            {
                Butterfly.HabboHotel.Games.SnowStorm.SnowStorm snowWar = this.Session.GetHabbo().SnowWar;
                ServerMessage packet = new ServerMessage(Outgoing.LeaveGame);
                packet.AppendInt32(this.Session.GetHabbo().Id);
                this.Session.GetHabbo().SnowWar.SendToStorm(packet, true, this.Session.GetHabbo().Id);
                snowWar.WarUsers.Remove(this.Session.GetHabbo());
                if ((snowWar.WarOwner == this.Session.GetHabbo()) && (snowWar.WarUsers.Count > 0))
                {
                    snowWar.WarOwner = snowWar.WarUsers[0];
                }
                this.Session.GetHabbo().SnowWar = null;
            }
        }

        internal void stageReadyMessage()
        {
            Console.WriteLine("Stage ready....");
        }

        internal void LoadArena(Butterfly.HabboHotel.Games.SnowStorm.SnowStorm War)
        {
            this.GetResponse().Init(Outgoing.Game2StageStartingMessageEvent);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendString("snowwar_arena_0");
            this.GetResponse().AppendInt32(5);
            this.CheckArenaStatic(this.GetResponse(), War);
            foreach (Habbo habbo in War.WarUsers)
            {
                this.GetResponse().AppendInt32(5);
                this.GetResponse().AppendInt32(habbo.SnowUserId);
                this.GetResponse().AppendInt32(habbo.SnowX);
                this.GetResponse().AppendInt32(habbo.SnowY);
                this.GetResponse().AppendInt32((int)(habbo.SnowX / 0xc80));
                this.GetResponse().AppendInt32((int)(habbo.SnowY / 0xc80));
                this.GetResponse().AppendInt32(2);
                this.GetResponse().AppendInt32(5);
                this.GetResponse().AppendInt32(5);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32((int)(habbo.SnowX / 0xc80));
                this.GetResponse().AppendInt32((int)(habbo.SnowY / 0xc80));
                this.GetResponse().AppendInt32(habbo.SnowX);
                this.GetResponse().AppendInt32(habbo.SnowY);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(habbo.SnowTeam);
                this.GetResponse().AppendInt32(habbo.Id);
                this.GetResponse().AppendString(habbo.Username);
                this.GetResponse().AppendString(habbo.Motto);
                this.GetResponse().AppendString(habbo.Look);
                this.GetResponse().AppendString(habbo.Gender.ToLower());
            }
            War.SendToStorm(this.GetResponse(), false, 0);
            Thread.Sleep(5000);
            foreach (Habbo habbo in War.WarUsers)
            {
                this.GetResponse().Init(Outgoing.Game2PlayerExitedGameArenaMessageEvent);
                this.GetResponse().AppendInt32(habbo.Id);
                this.GetResponse().AppendInt32(20);
                habbo.GetClient().SendMessage(this.GetResponse());
            }
            this.GetResponse().Init(Outgoing.Game2StageRunningMessageEvent);
            this.GetResponse().AppendInt32(120);
            War.SendToStorm(this.GetResponse(), false, 0);
            War.SnowStormStart();
        }

        public void LoadInvSongs()
        {
            if (((this.Session != null) && (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().GetInventoryComponent() != null))
            {
                this.Session.SendMessage(JukeboxDiscksComposer.SerializeSongInventory(this.Session.GetHabbo().GetInventoryComponent().songDisks));
            }
        }

        public void LoadJukeSongs()
        {
            if (((this.Session != null) && (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().CurrentRoom != null))
            {
                Room currentRoom = this.Session.GetHabbo().CurrentRoom;
                if (currentRoom.CheckRights(this.Session, true) && currentRoom.GotMusicController())
                {
                    RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
                    this.Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList<SongInstance>()));
                }
            }
        }

        public void RejectGuildMember()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                int num2 = this.Request.PopWiredInt32();
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId);

                Habbo habbo = ButterflyEnvironment.getHabboForId((uint)num2);
                if (habbo != null)
                {
                    Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                    guild.Petitions.Remove((int)habbo.Id);
                    string str = "";
                    foreach (int num3 in guild.Petitions)
                    {
                        str = str + num3 + ";";
                    }
                    if (guild.Petitions.Count > 1)
                    {
                        str = str.Substring(0, str.Length - 1);
                    }
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE groups SET Petitions = '", str, "' WHERE Id = '", guild.Id, "'" }));
                    }
                    ServerMessage message;
                    message = new ServerMessage(Outgoing.SendAdvGroupInit);
                    message.AppendInt32(guild.Id);
                    message.AppendBoolean(true);
                    message.AppendInt32(guild.Type);
                    message.AppendString(guild.Name);
                    message.AppendString(guild.Description);
                    message.AppendString(guild.Image);
                    message.AppendInt32(data.Id);
                    message.AppendString(data.Name);
                    if (guild.Petitions.Contains((int)habbo.Id))
                    {
                        message.AppendInt32(2);
                    }
                    else if (!habbo.ImGuilds.Contains(guild.Id))
                    {
                        message.AppendInt32(0);
                    }
                    else if (habbo.ImGuilds.Contains(guild.Id))
                    {
                        message.AppendInt32(1);
                    }
                    message.AppendInt32(guild.Members.Count);
                    message.AppendBoolean(false);
                    message.AppendString(guild.DateCreated);
                    message.AppendBoolean(habbo.Id == guild.OwnerId);

                    if (habbo.ImGuilds.Contains(guild.Id))
                    {
                        if (guild.GuildRanks[(int)habbo.Id] < 2)
                            message.AppendBoolean(true);
                        else message.AppendBoolean(false);
                    }
                    else message.AppendBoolean(false);
                    message.AppendString(guild.OwnerName);
                    message.AppendBoolean(true);
                    message.AppendBoolean(true);
                    message.AppendInt32(guild.Members.Contains((int)habbo.Id) ? guild.Petitions.Count : 0);
                    habbo.GetClient().SendMessage(message);

                }
            }
            LoadMembersPetitions(2, guild.Id);

        }

        public void LoadMembersPetitions(int num = 4, int guildid = 0, int numb2 = 0, string st = "")
        {
            int guildId;
            int num2;
            int num3;
            string str;

            if (num == 4)
            {
                guildId = this.Request.PopWiredInt32();
                num2 = this.Request.PopWiredInt32();
                str = this.Request.PopFixedString();
                num3 = this.Request.PopWiredInt32();
            }
            else
            {
                guildId = guildid;
                num2 = numb2;
                str = st;
                num3 = num;
            }

            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                ServerMessage message;
                Habbo habbo;
                int memberCounter = 0;
                if (num3 == 0)
                {
                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(guild.Members.Count);
                    if (num2 == 0)
                        message.AppendInt32(guild.Members.Count);

                    else message.AppendInt32(guild.Members.Count - (num2 * 14));

                    foreach (int num4 in guild.Members)
                    {
                        if (memberCounter >= (num2 * 14))
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if (guild.OwnerId == habbo.Id)
                            {
                                message.AppendInt32(0);
                            }
                            else
                            {
                                message.AppendInt32(guild.GuildRanks[num4]);
                            }
                            message.AppendInt32(num4);
                            message.AppendString(habbo.Username);
                            message.AppendString(habbo.Look);
                            message.AppendString(guild.JoinDates[memberCounter]);
                        }
                        memberCounter++;
                    }
                    if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                    {
                        if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                            message.AppendBoolean(true);
                        else message.AppendBoolean(false);
                    }
                    else message.AppendBoolean(false);
                    message.AppendInt32(14);
                    message.AppendInt32(num2);
                    message.AppendInt32(0);
                    message.AppendString("");
                    this.Session.SendMessage(message);
                }
                else if (num3 == 1)
                {
                    int admins = 0;

                    foreach (int num4 in guild.Members)
                    {
                        if (guild.GuildRanks[num4] < 2) admins++;

                    }

                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(admins);
                    message.AppendInt32((admins > 13) ? 14 : admins);

                    foreach (int num4 in guild.Members)
                    {
                        habbo = ButterflyEnvironment.getHabboForId((uint)num4);

                        if (guild.GuildRanks[(int)num4] < 2)
                        {
                            if (guild.OwnerId == habbo.Id)
                            {
                                message.AppendInt32(0);
                            }
                            else
                            {
                                message.AppendInt32(guild.GuildRanks[num4]);
                            }
                            message.AppendInt32(num4);
                            message.AppendString(habbo.Username);
                            message.AppendString(habbo.Look);
                            message.AppendString(guild.JoinDates[memberCounter]);
                            memberCounter++;

                        }

                    }
                    if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                    {
                        if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                            message.AppendBoolean(true);
                        else message.AppendBoolean(false);
                    }
                    else message.AppendBoolean(false);
                    message.AppendInt32(14);
                    message.AppendInt32(0);
                    message.AppendInt32(1);
                    message.AppendString("");
                    this.Session.SendMessage(message);
                }
                else if (num3 == 2)
                {
                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(guild.Petitions.Count);
                    message.AppendInt32((guild.Petitions.Count > 13) ? 14 : guild.Petitions.Count);
                    foreach (int num4 in guild.Petitions)
                    {
                        habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                        message.AppendInt32(3);
                        message.AppendInt32(num4);
                        message.AppendString(habbo.Username);
                        message.AppendString(habbo.Look);
                        message.AppendString("");
                        memberCounter++;
                    }
                    if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                        message.AppendBoolean(true);
                    else message.AppendBoolean(false);
                    message.AppendInt32(14);
                    message.AppendInt32(0);
                    message.AppendInt32(2);
                    message.AppendString("");
                    this.Session.SendMessage(message);
                }
                if (num3 == 3)
                {
                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(guild.Members.Count);
                    message.AppendInt32((guild.Members.Count > 13) ? 14 : guild.Members.Count);

                    foreach (int num4 in guild.Members)
                    {
                        habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                        if (guild.OwnerId == habbo.Id)
                        {
                            message.AppendInt32(0);
                        }
                        else
                        {
                            message.AppendInt32(guild.GuildRanks[num4]);
                        }
                        message.AppendInt32(num4);
                        message.AppendString(habbo.Username);
                        message.AppendString(habbo.Look);
                        message.AppendString(guild.JoinDates[memberCounter]);
                        memberCounter++;
                    }
                    if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                        message.AppendBoolean(true);
                    else message.AppendBoolean(false);

                    message.AppendInt32(14);
                    message.AppendInt32(0);
                    message.AppendInt32(0);
                    message.AppendString("");
                    this.Session.SendMessage(message);
                }
            }
        }

        public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
        {
            System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
            return dtDateTime;
        }

        internal void LoadProfile()
        {
            try
            {
                int num = this.Request.PopWiredInt32();
                bool flag = this.Request.PopWiredBoolean();
                Habbo habbo = ButterflyEnvironment.getHabboForId((uint)num);
                if (habbo == null)
                {
                    Console.WriteLine("can't get data por profile with userid = " + num);
                }
                else
                {
                    DataRow Info;
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery("SELECT `reg_timestamp` FROM `user_info` WHERE user_id = '" + habbo.Id + "'");
                        Info = adapter.getRow();
                    }
                    DataRow Last;
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery("SELECT `login_timestamp` FROM `user_info` WHERE user_id = '" + habbo.Id + "'");
                        Last = adapter.getRow();
                    }
                    DateTime lastLogin = UnixTimeStampToDateTime((double)Last["login_timestamp"]);
                    TimeSpan span = (TimeSpan)(DateTime.Now - lastLogin);
                    List<MyGuild> list = new List<MyGuild>();
                    foreach (int num2 in habbo.ImGuilds)
                    {
                        MyGuild item = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(num2);
                        if (!((item == null) || list.Contains(item)))
                        {
                            list.Add(item);
                        }
                    }
                    this.Response.Init(Outgoing.ProfileInformation);
                    this.Response.AppendInt32(habbo.Id);
                    this.Response.AppendString(habbo.Username);
                    this.Response.AppendString(habbo.Look);
                    this.Response.AppendString(habbo.Motto);
                    this.Response.AppendString(UnixTimeStampToDateTime((double)Info["reg_timestamp"]).ToShortDateString());
                    this.Response.AppendInt32(habbo.AchievementPoints);
                    this.Response.AppendInt32(habbo.GetMessenger().myFriends);
                    this.Response.AppendBoolean(habbo.Id != this.Session.GetHabbo().Id);
                    this.Response.AppendBoolean(false);
                    this.Response.AppendBoolean(ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(habbo.Id) != null);
                    this.Response.AppendInt32(list.Count);
                    foreach (MyGuild guild2 in list)
                    {
                        this.Response.AppendInt32(guild2.Id);
                        this.Response.AppendString(guild2.Name);
                        this.Response.AppendString(guild2.Image);
                        this.Response.AppendString(guild2.HtmlColor1);
                        this.Response.AppendString(guild2.HtmlColor2);
                        this.Response.AppendBoolean(habbo.FavoriteGuild == guild2.Id);
                    }
                    this.Response.AppendInt32((int)span.TotalSeconds);
                    this.Response.AppendBoolean(true);
                    this.SendResponse();
                }
            }
            catch
            {
            }
        }

        internal QueuedServerMessage LoadRoomForUser()
        {
            Room currentLoadingRoom = this.CurrentLoadingRoom;
            QueuedServerMessage message = new QueuedServerMessage(this.Session.GetConnection());
            if ((currentLoadingRoom != null) && this.Session.GetHabbo().LoadingChecksPassed)
            {
                this.Response.Init(Outgoing.InitialRoomInformation);
                this.Response.AppendString(currentLoadingRoom.ModelName);
                this.Response.AppendInt32(currentLoadingRoom.RoomId);
                message.appendResponse(this.GetResponse());
                if ((currentLoadingRoom.Type == "private") || (currentLoadingRoom.Type == "public"))
                {
                    if (currentLoadingRoom.Wallpaper != "0.0")
                    {
                        this.Response.Init(Outgoing.RoomDecoration);
                        this.Response.AppendString("wallpaper");
                        this.Response.AppendString(currentLoadingRoom.Wallpaper);
                        message.appendResponse(this.GetResponse());
                    }
                    if (currentLoadingRoom.Floor != "0.0")
                    {
                        this.Response.Init(Outgoing.RoomDecoration);
                        this.Response.AppendString("floor");
                        this.Response.AppendString(currentLoadingRoom.Floor);
                        message.appendResponse(this.GetResponse());
                    }
                    this.Response.Init(Outgoing.RoomDecoration);
                    this.Response.AppendString("landscape");
                    this.Response.AppendString(currentLoadingRoom.Landscape);
                    message.appendResponse(this.GetResponse());

                    if (currentLoadingRoom.CheckRights(this.Session, true))
                    {
                        this.Response.Init(Outgoing.RoomRightsLevel);
                        this.Response.AppendInt32(4);
                        message.appendResponse(this.GetResponse());
                        this.Response.Init(Outgoing.HasOwnerRights);
                        message.appendResponse(this.GetResponse());
                    }

                   /** else if (currentLoadingRoom.checkGroupRights(this.Session))
                    {
                        this.Response.Init(Outgoing.RoomRightsLevel);
                        this.Response.AppendInt32(1);
                        message.appendResponse(this.GetResponse());
                        this.Response.Init(Outgoing.HasOwnerRights);
                        message.appendResponse(this.GetResponse());
                    }*/

                    else if (currentLoadingRoom.CheckRights(this.Session))
                    {
                        this.Response.Init(Outgoing.RoomRightsLevel);
                        this.Response.AppendInt32(1);
                        message.appendResponse(this.GetResponse());
                    }

                    else
                    {
                        this.Response.Init(Outgoing.RoomRightsLevel);
                        this.Response.AppendInt32(0);
                        message.appendResponse(this.GetResponse());
                    }


                    this.Response.Init(Outgoing.ScoreMeter);
                    this.Response.AppendInt32(currentLoadingRoom.Score);
                    this.Response.AppendBoolean(!this.Session.GetHabbo().RatedRooms.Contains(currentLoadingRoom.RoomId) && !currentLoadingRoom.CheckRights(this.Session, true));
                    message.appendResponse(this.GetResponse());
                }
                List<MyGuild> list = new List<MyGuild>();
                MyGuild item = null;
                foreach (RoomUser user in currentLoadingRoom.GetRoomUserManager().UserList.Values)
                {
                    if ((!user.IsPet && !user.IsBot) && (user.GetClient().GetHabbo().FavoriteGuild > 0))
                    {
                        MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(user.GetClient().GetHabbo().FavoriteGuild);
                        if ((guild != null) && !list.Contains(guild))
                        {
                            list.Add(guild);
                        }
                    }
                }
                if (this.Session.GetHabbo().FavoriteGuild > 0)
                {
                    item = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(this.Session.GetHabbo().FavoriteGuild);
                    if ((item != null) && !list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
                this.Response.Init(Outgoing.SendGroup);
                this.Response.AppendInt32(list.Count);
                foreach (MyGuild guild2 in list)
                {
                    this.Response.AppendInt32(guild2.Id);
                    this.Response.AppendString(guild2.Image);
                }
                message.appendResponse(this.GetResponse());
                try
                {
                    if (item != null)
                    {
                        ServerMessage message2 = new ServerMessage(Outgoing.SendGroup);
                        message2.AppendInt32(1);
                        message2.AppendInt32(item.Id);
                        message2.AppendString(item.Image);
                        currentLoadingRoom.SendMessage(message2);
                    }
                }
                catch
                {
                }
            }
            return message;
        }

        public void LoadTalents()
        {
            bool flag = false;
            Dictionary<string, int> achievementGroup = new Dictionary<string, int>();
            List<string> badge = new List<string>();
            achievementGroup.Add("ACH_AvatarLooks", 1);
            badge.Add("ACH_AvatarLooks1");
            achievementGroup.Add("ACH_RespectGiven", 1);
            badge.Add("ACH_RespectGiven1");
            achievementGroup.Add("ACH_AllTimeHotelPresence", 1);
            badge.Add("ACH_AllTimeHotelPresence1");
            achievementGroup.Add("ACH_RoomEntry", 1);
            badge.Add("ACH_RoomEntry1");
            if (ButterflyEnvironment.GetGame().GetAchievementManager().ContainsGroupAch(achievementGroup, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadgeList(badge))
            {
                flag = true;
            }
            bool flag2 = false;
            Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
            List<string> list2 = new List<string>();
            dictionary2.Add("ACH_GuideAdvertisementReader", 1);
            list2.Add("ACH_GuideAdvertisementReader1");
            dictionary2.Add("ACH_RegistrationDuration", 1);
            list2.Add("ACH_RegistrationDuration1");
            dictionary2.Add("ACH_AllTimeHotelPresence", 2);
            list2.Add("ACH_AllTimeHotelPresence2");
            dictionary2.Add("ACH_RoomEntry", 2);
            list2.Add("ACH_RoomEntry2");
            if (ButterflyEnvironment.GetGame().GetAchievementManager().ContainsGroupAch(dictionary2, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadgeList(list2))
            {
                flag2 = true;
            }
            bool flag3 = false;
            Dictionary<string, int> dictionary3 = new Dictionary<string, int>();
            List<string> list3 = new List<string>();
            dictionary3.Add("ACH_GuideAdvertisementReader", 1);
            list3.Add("ACH_GuideAdvertisementReader1");
            dictionary3.Add("ACH_RegistrationDuration", 2);
            list3.Add("ACH_RegistrationDuration2");
            dictionary3.Add("ACH_AllTimeHotelPresence", 3);
            list3.Add("ACH_AllTimeHotelPresence3");
            dictionary3.Add("ACH_RoomEntry", 3);
            list3.Add("ACH_RoomEntry3");
            if (ButterflyEnvironment.GetGame().GetAchievementManager().ContainsGroupAch(dictionary3, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadgeList(list3))
            {
                flag3 = true;
            }
            ServerMessage message = new ServerMessage(0xb76);
            message.AppendString("citizenship");
            message.AppendInt32(5);
            message.AppendInt32(0);
            message.AppendInt32(this.Session.GetHabbo().PassedQuiz ? 2 : 1);
            message.AppendInt32(1);
            message.AppendInt32(0x7d);
            message.AppendInt32(1);
            message.AppendString("ACH_SafetyQuizGraduate1");
            message.AppendInt32(this.Session.GetHabbo().PassedQuiz ? 2 : 1);
            message.AppendInt32(this.Session.GetHabbo().PassedQuiz ? 1 : 0);
            message.AppendInt32(1);
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendString("A1 KUMIANKKA");
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendInt32(flag ? 2 : (this.Session.GetHabbo().PassedQuiz ? 1 : 0));
            message.AppendInt32(4);
            message.AppendInt32(6);
            message.AppendInt32(1);
            message.AppendString("ACH_AvatarLooks1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_AvatarLooks", 1, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_AvatarLooks1")) ? 2 : (this.Session.GetHabbo().PassedQuiz ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendInt32(0x12);
            message.AppendInt32(1);
            message.AppendString("ACH_RespectGiven1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_RespectGiven", 1, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_RespectGiven1")) ? 2 : (this.Session.GetHabbo().PassedQuiz ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(2);
            message.AppendInt32(0x13);
            message.AppendInt32(1);
            message.AppendString("ACH_AllTimeHotelPresence1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_AllTimeHotelPresence", 1, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_AllTimeHotelPresence1")) ? 2 : (this.Session.GetHabbo().PassedQuiz ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(30);
            message.AppendInt32(8);
            message.AppendInt32(1);
            message.AppendString("ACH_RoomEntry1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_RoomEntry", 1, this.Session) || this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_RoomEntry1")) ? 2 : (this.Session.GetHabbo().PassedQuiz ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(5);
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendString("A1 KUMIANKKA");
            message.AppendInt32(flag2 ? 2 : (flag ? 1 : 0));
            message.AppendInt32(2);
            message.AppendInt32(0);
            message.AppendInt32(4);
            message.AppendInt32(0x91);
            message.AppendInt32(1);
            message.AppendString("ACH_GuideAdvertisementReader1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_GuideAdvertisementReader", 1, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_GuideAdvertisementReader1") && flag)) ? 2 : (flag ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendInt32(11);
            message.AppendInt32(1);
            message.AppendString("ACH_RegistrationDuration1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_RegistrationDuration", 1, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_RegistrationDuration1") && flag)) ? 2 : (flag ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendInt32(0x13);
            message.AppendInt32(2);
            message.AppendString("ACH_AllTimeHotelPresence2");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_AllTimeHotelPresence", 2, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_AllTimeHotelPresence2") && flag)) ? 2 : (flag ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(60);
            message.AppendInt32(8);
            message.AppendInt32(2);
            message.AppendString("ACH_RoomEntry2");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_RoomEntry", 2, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_RoomEntry2") && flag)) ? 2 : (flag ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(20);
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendString("A1 KUMIANKKA");
            message.AppendInt32(flag3 ? 2 : (flag2 ? 1 : 0));
            message.AppendInt32(3);
            message.AppendInt32(0);
            message.AppendInt32(4);
            message.AppendInt32(11);
            message.AppendInt32(2);
            message.AppendString("ACH_RegistrationDuration2");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_RegistrationDuration", 2, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_RegistrationDuration2") && flag2)) ? 2 : (flag2 ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(3);
            message.AppendInt32(0x5e);
            message.AppendInt32(1);
            message.AppendString("ACH_HabboWayGraduate1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_HabboWayGraduate", 1, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_HabboWayGraduate1") && flag2)) ? 2 : (flag2 ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendInt32(0x13);
            message.AppendInt32(3);
            message.AppendString("ACH_AllTimeHotelPresence3");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_AllTimeHotelPresence", 3, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_AllTimeHotelPresence3") && flag2)) ? 2 : (flag2 ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(120);
            message.AppendInt32(0x8e);
            message.AppendInt32(1);
            message.AppendString("ACH_FriendListSize1");
            message.AppendInt32((ButterflyEnvironment.GetGame().GetAchievementManager().ContainsAchievement("ACH_FriendListSize", 1, this.Session) || (this.Session.GetHabbo().GetBadgeComponent().HasBadge("ACH_FriendListSize1") && flag2)) ? 2 : (flag2 ? 1 : 0));
            message.AppendInt32(0);
            message.AppendInt32(2);
            message.AppendInt32(1);
            message.AppendString("TRADE");
            message.AppendInt32(1);
            message.AppendString("A1 KUMIANKKA");
            message.AppendInt32(flag3 ? 1 : 0);
            message.AppendInt32(4);
            message.AppendInt32(0);
            message.AppendInt32(0);
            message.AppendInt32(1);
            message.AppendString("CITIZEN");
            message.AppendInt32(2);
            message.AppendString("A1 KUMIANKKA");
            message.AppendInt32(0);
            message.AppendString("HABBO_CLUB_CITIZENSHIP_VIP_REWARD");
            message.AppendInt32(7);
            this.Session.SendMessage(message);
        }

        public void LoadUser2()
        {
            int num = this.Request.PopWiredInt32();
            int num2 = this.Request.PopWiredInt32();
            int num3 = this.Request.PopWiredInt32();
            if ((num2 == 1) && (num3 == 0))
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)num);
                if ((room != null) && (room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id) == null))
                {
                }
            }
            else if ((num2 != 0) || (num3 != 0))
            {
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)num);
                if (data != null)
                {
                    ServerMessage message = new ServerMessage(Outgoing.RoomData);
                    message.AppendBoolean(false);
                    data.Serialize(message, false);
                    message.AppendBoolean(true);
                    message.AppendBoolean(false);
                    message.AppendBoolean(true);
                    message.AppendInt32(0);
                    message.AppendInt32(0);
                    message.AppendInt32(0);
                    this.Session.SendMessage(message);
                }
            }
        }

        internal void LookAt()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    roomUserByHabbo.Unidle();
                    int num = this.Request.PopWiredInt32();
                    int num2 = this.Request.PopWiredInt32();
                    if ((num != roomUserByHabbo.X) || (num2 != roomUserByHabbo.Y))
                    {
                        int rotation = Rotation.Calculate(roomUserByHabbo.X, roomUserByHabbo.Y, num, num2);
                        roomUserByHabbo.SetRot(rotation, false);
                        roomUserByHabbo.UpdateNeeded = true;
                    }
                }
            }


        }

        public void MarketplaceCanSell()
        {
            ServerMessage message = new ServerMessage(Outgoing.CanSell);
            message.AppendInt32(1);
            message.AppendInt32(0);
            this.Session.SendMessage(message);
        }

        internal void MarketplaceClaimCredits()
        {
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT asking_price FROM catalog_marketplace_offers WHERE user_id = " + this.Session.GetHabbo().Id + " AND state = 2");
                DataRow row = adapter.getRow();
                if (row.Table.Rows.Count > 0)
                {
                    int num = 0;
                    foreach (DataRow row2 in row.Table.Rows)
                    {
                        num += (int)row2["asking_price"];
                    }
                    if (num >= 1)
                    {
                        Habbo habbo = this.Session.GetHabbo();
                        habbo.Credits += num;
                        this.Session.GetHabbo().UpdateCreditsBalance();
                    }
                    adapter.runFastQuery("DELETE FROM catalog_marketplace_offers WHERE user_id = " + this.Session.GetHabbo().Id + " AND state = 2");
                }
            }
        }

        internal void MarketplaceGetOffers()
        {
            int minCost = this.Request.PopWiredInt32();
            int maxCost = this.Request.PopWiredInt32();
            string searchQuery = this.Request.PopFixedString();
            int filterMode = this.Request.PopWiredInt32();
            ServerMessage message = Marketplace.SerializeOffers(minCost, maxCost, searchQuery, filterMode);
            this.Session.SendMessage(message);
        }

        public void MarketplaceGetOwnOffers()
        {
            this.Session.SendMessage(Marketplace.SerializeOwnOffers((int)this.Session.GetHabbo().Id));
        }

        public void MarketplacePostItem()
        {
            if (this.Session.GetHabbo().GetInventoryComponent() != null)
            {
                int sellingPrice = this.Request.PopWiredInt32();
                int num2 = this.Request.PopWiredInt32();
                int num3 = this.Request.PopWiredInt32();
                UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem((uint)num3);
                if ((item != null) && item.GetBaseItem().AllowTrade)
                {
                    Marketplace.SellItem(this.Session, (int)item.Id, sellingPrice);
                }
            }
        }

        internal void MarketplacePurchase()
        {
            int i = this.Request.PopWiredInt32();
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT * FROM catalog_marketplace_offers WHERE offer_id = " + i + " ");
                DataRow row = adapter.getRow();
                if (((row.Table.Rows.Count <= 0) || (((int)row["state"]) != 1)) || (((double)row["timestamp"]) <= Marketplace.FormatTimestamp()))
                {
                    this.Session.SendNotif("La oferta est\x00e1 expirada");
                }
                else
                {
                    Item item = ButterflyEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(row["item_id"]));
                    if (item != null)
                    {
                        int num2 = (int)row["total_price"];
                        if (((int)row["total_price"]) >= 1)
                        {
                            Habbo habbo = this.Session.GetHabbo();
                            habbo.Credits -= num2;
                            this.Session.GetHabbo().UpdateCreditsBalance();
                        }
                        List<UserItem> list = ButterflyEnvironment.GetGame().GetCatalog().DeliverItems(this.Session, item, 1, (string)row["extra_data"], 0, 0);
                        this.Session.GetHabbo().GetInventoryComponent().RunDBUpdate();
                        adapter.runFastQuery("UPDATE catalog_marketplace_offers SET state = 2 WHERE offer_id = " + i);
                        ServerMessage message = new ServerMessage(Outgoing.BuyItemMarket);
                        message.AppendInt32(1);
                        message.AppendInt32(i);
                        message.AppendInt32(2);
                        message.AppendInt32(i);
                        this.Session.SendMessage(message);
                        ServerMessage message2 = new ServerMessage(Outgoing.SendPurchaseAlert);
                        message2.AppendInt32(1);
                        message2.AppendInt32((int)row["item_type"]);
                        message2.AppendInt32(list.Count);
                        foreach (UserItem item2 in list.ToArray())
                        {
                            message2.AppendInt32(item2.Id);
                        }
                        this.Session.SendMessage(message2);
                        this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                        ServerMessage message3 = Marketplace.SerializeOffers(-1, -1, "", 1);
                        this.Session.SendMessage(message3);
                    }
                }
            }
        }

        public void MarketplaceTakeBack()
        {
            int i = this.Request.PopWiredInt32();
            DataRow row = null;
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT * FROM catalog_marketplace_offers WHERE offer_id = " + i + " LIMIT 1");
                row = adapter.getRow();
                if ((row.Table.Rows.Count > 0) && (Convert.ToInt32(row["user_id"]) == this.Session.GetHabbo().Id))
                {
                    Item item = ButterflyEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(row["item_id"]));
                    if (item != null)
                    {
                        ButterflyEnvironment.GetGame().GetCatalog().DeliverItems(this.Session, item, 1, (string)row["extra_data"], 0, 0);
                        adapter.runFastQuery("DELETE FROM catalog_marketplace_offers WHERE offer_id = " + i);
                        ServerMessage message = new ServerMessage(Outgoing.QuitMarket);
                        message.AppendInt32(i);
                        message.AppendBoolean(true);
                        this.Session.SendMessage(message);
                        this.Session.SendMessage(new ServerMessage(Outgoing.AddMarket2));
                    }
                }
            }
        }

        internal void ModBanUser()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_ban"))
            {
                uint userId = this.Request.PopWiredUInt();
                string message = this.Request.PopFixedString();
                int length = this.Request.PopWiredInt32() * 0xe10;
                ModerationTool.BanUser(this.Session, userId, length, message);
            }
        }

        internal void ModCloseTicket()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                int result = this.Request.PopWiredInt32();
                int num2 = this.Request.PopWiredInt32();
                uint ticketId = this.Request.PopWiredUInt();
                ButterflyEnvironment.GetGame().GetModerationTool().CloseTicket(this.Session, ticketId, result);
            }
        }

        internal void ModGetRoomChatlog()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_chatlogs"))
            {
                int num = this.Request.PopWiredInt32();
                uint roomID = this.Request.PopWiredUInt();
                if (ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(roomID) != null)
                {
                    this.Session.SendMessage(ModerationTool.SerializeRoomChatlog(roomID));
                }
            }
        }

        internal void ModGetRoomTool()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                uint roomId = this.Request.PopWiredUInt();
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData(roomId);
                this.Session.SendMessage(ModerationTool.SerializeRoomTool(data));
            }
        }

        internal void ModGetRoomVisits()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                uint userId = this.Request.PopWiredUInt();
                this.Session.SendMessage(ModerationTool.SerializeRoomVisits(userId));
            }
        }

        internal void ModGetTicketChatlog()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                SupportTicket ticket = ButterflyEnvironment.GetGame().GetModerationTool().GetTicket(this.Request.PopWiredUInt());
                if (ticket != null)
                {
                    RoomData roomData = ButterflyEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData(ticket.RoomId);
                    if (roomData != null)
                    {
                        this.Session.SendMessage(ModerationTool.SerializeTicketChatlog(ticket, roomData, ticket.Timestamp));
                    }
                }
            }
        }

        internal void ModGetUserChatlog()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_chatlogs"))
            {
                this.Session.SendMessage(ModerationTool.SerializeUserChatlog(this.Request.PopWiredUInt()));
            }
        }

        internal void ModGetUserInfo()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                uint id = this.Request.PopWiredUInt();
                if (ButterflyEnvironment.GetGame().GetClientManager().GetNameById(id) != "Unknown User")
                {
                    this.Session.SendMessage(ModerationTool.SerializeUserInfo(id));
                }
                else
                {
                    this.Session.SendNotif(LanguageLocale.GetValue("user.loadusererror"));
                }
            }
        }

        internal void ModKickUser()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_kick"))
            {
                uint userId = this.Request.PopWiredUInt();
                string message = this.Request.PopFixedString();
                ModerationTool.KickUser(this.Session, userId, message, false);
            }
        }

        internal void ModPerformRoomAction()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                uint roomId = this.Request.PopWiredUInt();
                bool lockRoom = this.Request.PopWiredInt32() == 1;
                bool inappropriateRoom = this.Request.PopWiredInt32() == 1;
                bool kickUsers = this.Request.PopWiredInt32() == 1;
                ModerationTool.PerformRoomAction(this.Session, roomId, kickUsers, lockRoom, inappropriateRoom);
            }
        }

        internal void ModPickTicket()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                int num = this.Request.PopWiredInt32();
                uint ticketId = this.Request.PopWiredUInt();
                ButterflyEnvironment.GetGame().GetModerationTool().PickTicket(this.Session, ticketId);
            }
        }

        internal void ModReleaseTicket()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_mod"))
            {
                int num = this.Request.PopWiredInt32();
                for (int i = 0; i < num; i++)
                {
                    uint ticketId = this.Request.PopWiredUInt();
                    ButterflyEnvironment.GetGame().GetModerationTool().ReleaseTicket(this.Session, ticketId);
                }
            }
        }

        internal void ModSendRoomAlert()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_alert"))
            {
                int num = this.Request.PopWiredInt32();
                int num2 = this.Request.PopWiredInt32();
                string s = this.Request.PopFixedString();
                ServerMessage message = new ServerMessage(Outgoing.SendNotif);
                message.AppendString(s);
                message.AppendString("");
                this.Session.GetHabbo().CurrentRoom.SendMessage(message);
            }
        }

        internal void ModSendUserCaution()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_alert"))
            {
                uint userId = this.Request.PopWiredUInt();
                string message = this.Request.PopFixedString();
                ModerationTool.AlertUser(this.Session, userId, message, true);
            }
        }

        internal void ModSendUserMessage()
        {
            if (this.Session.GetHabbo().HasFuse("fuse_alert"))
            {
                uint userId = this.Request.PopWiredUInt();
                string message = this.Request.PopFixedString();
                ModerationTool.AlertUser(this.Session, userId, message, false);
            }
        }

        internal void MountOnPet()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    uint petId = this.Request.PopWiredUInt();
                    bool flag = this.Request.PopWiredBoolean();
                    RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                    if ((((pet != null) && (pet.PetData != null)) && (!pet.montandoBol || roomUserByHabbo.montandoBol)) && ((pet.PetData.OwnerId == roomUserByHabbo.HabboId) || pet.PetData.CanMountAllPeople))
                    {
                        if (flag)
                        {
                            pet.Statusses.Remove("sit");
                            pet.Statusses.Remove("lay");
                            pet.Statusses.Remove("snf");
                            pet.Statusses.Remove("eat");
                            pet.Statusses.Remove("ded");
                            pet.Statusses.Remove("jmp");
                            int x = roomUserByHabbo.X;
                            int y = roomUserByHabbo.Y;
                            pet.ClearMovement(true);
                            roomUserByHabbo.montandoBol = true;
                            pet.montandoBol = true;
                            pet.montandoID = (uint)roomUserByHabbo.VirtualId;
                            roomUserByHabbo.montandoID = Convert.ToUInt32(pet.VirtualId);
                            pet.PetData.AddExpirience(10);
                            room.SendMessage(room.GetRoomItemHandler().UpdateUserOnRoller(pet, new Point(x, y), 0, room.GetGameMap().SqAbsoluteHeight(x, y)));
                            room.GetRoomUserManager().UpdateUserStatus(pet, false);
                            room.SendMessage(room.GetRoomItemHandler().UpdateUserOnRoller(roomUserByHabbo, new Point(x, y), 0, room.GetGameMap().SqAbsoluteHeight(x, y) + 1.0));
                            room.GetRoomUserManager().UpdateUserStatus(roomUserByHabbo, false);
                            if (pet.PetData.HaveSaddle == 1)
                            {
                                roomUserByHabbo.ApplyEffect(0x4d);
                            }
                            else if (pet.PetData.HaveSaddle == 2)
                            {
                                roomUserByHabbo.ApplyEffect(0x67);
                            }
                            roomUserByHabbo.MoveTo(x + 1, y + 1);
                        }
                        else
                        {
                            pet.Statusses.Remove("sit");
                            pet.Statusses.Remove("lay");
                            pet.Statusses.Remove("snf");
                            pet.Statusses.Remove("eat");
                            pet.Statusses.Remove("ded");
                            pet.Statusses.Remove("jmp");
                            roomUserByHabbo.montandoBol = false;
                            roomUserByHabbo.montandoID = 0;
                            pet.montandoBol = false;
                            pet.montandoID = 0;
                            roomUserByHabbo.MoveTo(roomUserByHabbo.X + 1, roomUserByHabbo.Y + 1);
                            roomUserByHabbo.ApplyEffect(-1);
                        }
                        ServerMessage message = new ServerMessage(Outgoing.SerializeMontura);
                        message.AppendInt32(pet.PetData.VirtualId);
                        message.AppendInt32(pet.PetData.PetId);
                        message.AppendInt32(pet.PetData.Type);
                        message.AppendInt32(int.Parse(pet.PetData.Race));
                        message.AppendString(pet.PetData.Color.ToLower());
                        if (pet.PetData.HaveSaddle == 2)
                        {
                            message.AppendInt32(1);
                            message.AppendInt32(3);
                            message.AppendInt32(4);
                            message.AppendInt32(10);
                            message.AppendInt32(0);
                            message.AppendInt32(2);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(3);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                        }
                        else if (pet.PetData.HaveSaddle == 1)
                        {
                            message.AppendInt32(1);
                            message.AppendInt32(3);
                            message.AppendInt32(2);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(3);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(4);
                            message.AppendInt32(9);
                            message.AppendInt32(0);
                        }
                        else
                        {
                            message.AppendInt32(1);
                            message.AppendInt32(2);
                            message.AppendInt32(2);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                            message.AppendInt32(3);
                            message.AppendInt32(pet.PetData.PetHair);
                            message.AppendInt32(pet.PetData.HairDye);
                        }
                        message.AppendBoolean(pet.PetData.HaveSaddle != 0);
                        message.AppendBoolean(pet.montandoBol);
                        room.SendMessage(message);
                    }
                }
            }
        }

        internal void Move()
        {
            Room currentRoom = this.Session.GetHabbo().CurrentRoom;
            if (currentRoom != null)
            {
                RoomUser roomUserByHabbo = currentRoom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if ((roomUserByHabbo != null) && roomUserByHabbo.CanWalk)
                {
                    int pX = this.Request.PopWiredInt32();
                    int pY = this.Request.PopWiredInt32();
                    if ((pX != roomUserByHabbo.X) || (pY != roomUserByHabbo.Y))
                    {
                        roomUserByHabbo.MoveTo(pX, pY);
                    }
                }
            }
        }

        internal void MoveItem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            uint theitem = this.Request.PopWiredUInt();

            if ((room != null) && room.CheckRights(this.Session))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(theitem);
                if (item != null)
                {
                    IQueryAdapter adapter;
                    if (item.wiredHandler != null)
                    {
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            item.wiredHandler.DeleteFromDatabase(adapter);
                            item.wiredHandler.Dispose();
                            room.GetWiredHandler().RemoveFurniture(item);
                        }
                        item.wiredHandler = null;
                    }
                    if (item.wiredCondition != null)
                    {
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            item.wiredCondition.DeleteFromDatabase(adapter);
                            item.wiredCondition.Dispose();
                            room.GetWiredHandler().conditionHandler.ClearTile(item.Coordinate);
                        }
                        item.wiredCondition = null;
                    }

                    int newX = this.Request.PopWiredInt32();
                    int newY = this.Request.PopWiredInt32();
                    int newRot = this.Request.PopWiredInt32();
                    int num4 = this.Request.PopWiredInt32();
                    int num5 = this.Request.PopWiredInt32();

                    bool flag = false;

                    if (item.GetBaseItem().InteractionType == InteractionType.teleport)
                    {
                        flag = true;
                    }

                    room.GetRoomItemHandler().SetFloorItem(this.Session, item, newX, newY, newRot, false, false, true);
                    item.UpdateState();
                    if (flag)
                    {
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            room.GetRoomItemHandler().SaveFurniture(adapter);
                        }
                    }

                }
            }
        }

        internal void MoveWallItem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session))
            {
                uint pId = this.Request.PopWiredUInt();
                string str = this.Request.PopFixedString();
                RoomItem item = room.GetRoomItemHandler().GetItem(pId);
                if (item != null)
                {
                    try
                    {
                        WallCoordinate coordinate = new WallCoordinate(":" + str.Split(new char[] { ':' })[1]);
                        item.wallCoord = coordinate;
                    }
                    catch
                    {
                        return;
                    }
                    room.GetRoomItemHandler().UpdateItem(item);
                    ServerMessage message = new ServerMessage(Outgoing.UpdateWallItemOnRoom);
                    item.Serialize(message, (int)item.placedBy);
                    room.SendMessage(message);
                }
            }
        }

        internal void OfferTradeItem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                Trade userTrade = room.GetUserTrade(this.Session.GetHabbo().Id);
                UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(this.Request.PopWiredUInt());
                if ((userTrade != null) && (item != null))
                {
                    userTrade.OfferItem(this.Session.GetHabbo().Id, item);
                }
            }
        }

        internal void OnRoomUserAdd()
        {
            QueuedServerMessage message = new QueuedServerMessage(this.Session.GetConnection());
            List<RoomUser> list = new List<RoomUser>();
            if (this.CurrentLoadingRoom != null)
            {
                foreach (RoomUser user in this.CurrentLoadingRoom.GetRoomUserManager().UserList.Values)
                {
                    if (!user.IsSpectator)
                    {
                        list.Add(user);
                    }
                }
                this.Response.Init(Outgoing.SetRoomUser);
                this.Response.AppendInt32(list.Count);
                foreach (RoomUser user in list)
                {
                    user.Serialize(this.Response, this.CurrentLoadingRoom.GetGameMap().gotPublicPool);
                }
                message.appendResponse(this.GetResponse());
                this.Response.Init(Outgoing.ConfigureWallandFloor);
                this.GetResponse().AppendBoolean(this.CurrentLoadingRoom.Hidewall);
                this.GetResponse().AppendInt32(this.CurrentLoadingRoom.WallThickness);
                this.GetResponse().AppendInt32(this.CurrentLoadingRoom.FloorThickness);
                message.appendResponse(this.GetResponse());
                message.appendResponse(this.GetResponse());
                if (this.CurrentLoadingRoom.Type == "public")
                {
                    this.Response.Init(Outgoing.ValidRoom);
                    this.Response.AppendBoolean(true);
                    this.Response.AppendInt32(this.CurrentLoadingRoom.RoomId);
                    this.Response.AppendBoolean(false);
                    message.appendResponse(this.GetResponse());
                }
                else if (this.CurrentLoadingRoom.Type == "private")
                {
                    this.Response.Init(Outgoing.ValidRoom);
                    this.Response.AppendBoolean(true);
                    this.Response.AppendInt32(this.CurrentLoadingRoom.RoomId);
                    this.Response.AppendBoolean(this.CurrentLoadingRoom.CheckRights(this.Session, true));
                    message.appendResponse(this.GetResponse());
                }
                this.Response.Init(Outgoing.RoomData);
                this.Response.AppendBoolean(true);
                this.Response.AppendInt32(this.CurrentLoadingRoom.RoomId);
                this.Response.AppendString(this.CurrentLoadingRoom.Name);
                this.Response.AppendBoolean(true);
                this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId);
                this.Response.AppendString(this.CurrentLoadingRoom.Owner);
                this.Response.AppendInt32(this.CurrentLoadingRoom.State);
                this.Response.AppendInt32(this.CurrentLoadingRoom.UsersNow);
                this.Response.AppendInt32(this.CurrentLoadingRoom.UsersMax);
                this.Response.AppendString(this.CurrentLoadingRoom.Description);
                this.Response.AppendInt32((this.CurrentLoadingRoom.Category == 0x34) ? 2 : 0);
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(this.CurrentLoadingRoom.Score);
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(this.CurrentLoadingRoom.Category);
                if (this.CurrentLoadingRoom.GroupId == 0)
                {
                    this.Response.AppendInt32(0);
                    this.Response.AppendInt32(0);
                }
                else
                {
                    MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(this.CurrentLoadingRoom.GroupId);
                    this.Response.AppendInt32(guild.Id);
                    this.Response.AppendString(guild.Name);
                    this.Response.AppendString(guild.Image);
                }
                this.Response.AppendString("");
                this.Response.AppendInt32(this.CurrentLoadingRoom.TagCount);
                foreach (string str in this.CurrentLoadingRoom.Tags)
                {
                    this.Response.AppendString(str);
                }
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(0);
                this.Response.AppendBoolean(true);
                this.Response.AppendBoolean(true);
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(0);
                this.Response.AppendBoolean(false);
                this.Response.AppendBoolean(false);
                this.Response.AppendBoolean(false);
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(0);
                this.Response.AppendInt32(0);
                message.appendResponse(this.GetResponse());
                if (((this.CurrentLoadingRoom.Type != "public") && (this.CurrentLoadingRoom.UsersWithRights.Count > 0)) && this.CurrentLoadingRoom.CheckRights(this.Session, true))
                {
                    Habbo habbo;
                    this.GetResponse().Init(Outgoing.GetPowerList);
                    this.GetResponse().AppendInt32(this.CurrentLoadingRoom.RoomData.Id);
                    this.GetResponse().AppendInt32(this.CurrentLoadingRoom.UsersWithRights.Count);
                    foreach (uint num in this.CurrentLoadingRoom.UsersWithRights)
                    {
                        habbo = ButterflyEnvironment.getHabboForId(num);
                        this.GetResponse().AppendInt32(habbo.Id);
                        this.GetResponse().AppendString(habbo.Username);
                    }
                    message.appendResponse(this.GetResponse());
                    foreach (uint num in this.CurrentLoadingRoom.UsersWithRights)
                    {
                        habbo = ButterflyEnvironment.getHabboForId(num);
                        this.GetResponse().Init(Outgoing.GivePowers);
                        this.GetResponse().AppendInt32(this.CurrentLoadingRoom.RoomId);
                        this.GetResponse().AppendInt32(habbo.Id);
                        this.GetResponse().AppendString(habbo.Username);
                        message.appendResponse(this.GetResponse());
                    }
                }
                ServerMessage message2 = this.CurrentLoadingRoom.GetRoomUserManager().SerializeStatusUpdates(true);
                if (message2 != null)
                {
                    message.appendResponse(message2);
                }
                foreach (RoomUser user in this.CurrentLoadingRoom.GetRoomUserManager().UserList.Values)
                {
                    if (!user.IsSpectator)
                    {
                        if (user.IsDancing)
                        {
                            this.Response.Init(Outgoing.Dance);
                            this.Response.AppendInt32(user.VirtualId);
                            this.Response.AppendInt32(user.DanceId);
                            message.appendResponse(this.GetResponse());
                        }
                        if (user.IsAsleep)
                        {
                            this.Response.Init(Outgoing.IdleStatus);
                            this.Response.AppendInt32(user.VirtualId);
                            this.Response.AppendBoolean(true);
                            message.appendResponse(this.GetResponse());
                        }
                        if ((user.CarryItemID > 0) && (user.CarryTimer > 0))
                        {
                            this.Response.Init(Outgoing.ApplyCarryItem);
                            this.Response.AppendInt32(user.VirtualId);
                            this.Response.AppendInt32(user.CarryTimer);
                            message.appendResponse(this.GetResponse());
                        }
                        if (!user.IsBot)
                        {
                            try
                            {
                                if ((((user.GetClient() != null) && (user.GetClient().GetHabbo() != null)) && (user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() != null)) && (user.CurrentEffect >= 1))
                                {
                                    this.Response.Init(Outgoing.ApplyEffects);
                                    this.Response.AppendInt32(user.VirtualId);
                                    this.Response.AppendInt32(user.CurrentEffect);
                                    this.Response.AppendInt32(0);
                                    message.appendResponse(this.GetResponse());
                                }
                            }
                            catch (Exception exception)
                            {
                                Logging.HandleException(exception, "Rooms.SendRoomData3");
                            }
                        }
                    }
                }
                if (this.Session.GetHabbo().QuestActivate > 0)
                {
                    QuestManager questById = ButterflyEnvironment.GetGame().GetQuestManager().GetQuestById(this.Session.GetHabbo().QuestActivate);
                    ServerMessage message3 = new ServerMessage(Outgoing.ActivateQuest);
                    message3.AppendString(questById.Category);
                    message3.AppendInt32(ButterflyEnvironment.GetGame().GetQuestManager().MyQuestsCompleted(questById.Category, this.Session.GetHabbo()).Count);
                    message3.AppendInt32(ButterflyEnvironment.GetGame().GetQuestManager().QuestsInCategory(questById.Category).Count);
                    message3.AppendInt32(-1);
                    message3.AppendInt32(questById.Id);
                    message3.AppendBoolean(ButterflyEnvironment.GetGame().GetQuestManager().IsActivated(questById.Id, this.Session.GetHabbo()));
                    message3.AppendString(questById.Type);
                    message3.AppendString(questById.ExtraValue);
                    message3.AppendInt32(questById.Award);
                    message3.AppendString(questById.SecondType);
                    if (this.Session.GetHabbo().QuestsStates.ContainsKey(questById.Id))
                    {
                        message3.AppendInt32(this.Session.GetHabbo().QuestsStates[questById.Id]);
                    }
                    else
                    {
                        message3.AppendInt32(0);
                    }
                    message3.AppendInt32(questById.CountFurnis);
                    message3.AppendInt32(ButterflyEnvironment.GetGame().GetQuestManager().GetIntValue(questById.Category));
                    message3.AppendString("set_kuurna");
                    message3.AppendString("MAIN_CHAIN");
                    message3.AppendBoolean(true);
                    this.Session.SendMessage(message3);
                }
                message.sendResponse();

                this.CurrentLoadingRoom = null;


            }
        }

        internal void OpenFlat()
        {
            if (this.Session.GetHabbo() != null)
            {
                uint roomId = this.Request.PopWiredUInt();
                string password = this.Request.PopFixedString();
                int num2 = this.Request.PopWiredInt32();
                Logging.WriteLine("Loading room [" + roomId + "]");
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId);
                if ((data != null) && !(data.Type != "private"))
                {
                    this.PrepareRoomForUser(roomId, password);
                }
            }
        }

        public void OpenGuildPage()
        {
            Habbo habbo = this.Session.GetHabbo();
            if (habbo.UsersRooms.Count > 0)
            {
                ServerMessage message = new ServerMessage(Outgoing.SendGuildParts);
                message.AppendInt32(10);
                message.AppendInt32((int)(habbo.UsersRooms.Count - this.GetMyRoomsGuilds()));
                foreach (RoomData data in habbo.UsersRooms)
                {
                    if (data.GroupId == 0)
                    {
                        message.AppendInt32(data.Id);
                        message.AppendString(data.Name);
                        message.AppendBoolean(false);
                    }
                }
                message.AppendInt32(5);
                message.AppendInt32(10);
                message.AppendInt32(3);
                message.AppendInt32(4);
                message.AppendInt32(0x19);
                message.AppendInt32(0x11);
                message.AppendInt32(5);
                message.AppendInt32(0x19);
                message.AppendInt32(0x11);
                message.AppendInt32(3);
                message.AppendInt32(0x1d);
                message.AppendInt32(11);
                message.AppendInt32(4);
                message.AppendInt32(0);
                message.AppendInt32(0);
                message.AppendInt32(0);
                this.Session.SendMessage(message);
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetCatalog().mGuildPageBuy);
                this.Session.GetHabbo().ColorsSended = true;
            }
        }

        internal void OpenPostit()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                if ((item != null) && (item.GetBaseItem().InteractionType == InteractionType.postit))
                {
                    this.Response.Init(Outgoing.OpenPostIt);
                    this.Response.AppendString(item.Id.ToString());
                    this.Response.AppendString(item.ExtraData);
                    this.SendResponse();
                }
            }
        }

        internal void OpenPresent()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                uint pId = this.Request.PopWiredUInt();
                RoomItem item = room.GetRoomItemHandler().GetItem(pId);
                if (item != null)
                {
                    IQueryAdapter adapter;
                    item.MagicRemove = true;
                    ServerMessage message = new ServerMessage(Outgoing.UpdateItemOnRoom);
                    item.Serialize(message, room.OwnerId);
                    room.SendMessage(message);
                    DataRow row = null;
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery("SELECT base_id,amount,extra_data FROM user_presents WHERE item_id = " + item.Id);
                        row = adapter.getRow();
                    }
                    if (row == null)
                    {
                        room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                    }
                    else
                    {
                        Item item2 = ButterflyEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(row["base_id"]));
                        if (item2 == null)
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                        }
                        else if (item2.Type.ToString().ToLower().Equals("s") && (item2.InteractionType != InteractionType.teleport))
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "UPDATE items SET base_id = '", row["base_id"], "' WHERE item_id = ", item.Id }));
                                adapter.runFastQuery("UPDATE items_extradata SET data = '' WHERE item_id = " + item.Id);
                                adapter.runFastQuery("DELETE FROM user_presents WHERE item_id = " + item.Id);
                            }
                            string s = item.GetBaseItem().Type.ToString().ToLower();
                            string extraData = item.ExtraData;
                            item.BaseItem = Convert.ToUInt32(row["base_id"]);
                            item.refreshItem();
                            item.ExtraData = "";
                            if (!room.GetRoomItemHandler().SetFloorItem(this.Session, item, item.GetX, item.GetY, item.Rot, true, false, true))
                            {
                                this.Session.SendNotif("Failed to create your gift!");
                            }
                            else
                            {
                                this.Response.Init(Outgoing.OpenGift);
                                this.Response.AppendString(item2.Type.ToString());
                                this.Response.AppendInt32(item2.SpriteId);
                                this.Response.AppendString(item2.Name);
                                this.Response.AppendInt32(item.Id);
                                this.Response.AppendString(s);
                                this.Response.AppendBoolean(true);
                                this.Response.AppendString(extraData);
                                this.SendResponse();
                            }
                        }
                        else
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery("DELETE FROM user_presents WHERE item_id = " + item.Id);
                            }
                            this.Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert);
                            this.Session.GetMessageHandler().GetResponse().AppendInt32(1);
                            int i = 2;
                            if (item2.Type.ToString().ToLower().Equals("s"))
                            {
                                if (item2.InteractionType == InteractionType.pet)
                                {
                                    i = 3;
                                }
                                else
                                {
                                    i = 1;
                                }
                            }
                            this.Session.GetMessageHandler().GetResponse().AppendInt32(i);
                            List<UserItem> list = ButterflyEnvironment.GetGame().GetCatalog().DeliverItems(this.Session, item2, (int)row["amount"], (string)row["extra_data"], 0, 0);
                            this.Session.GetMessageHandler().GetResponse().AppendInt32(list.Count);
                            foreach (UserItem item3 in list)
                            {
                                this.Session.GetMessageHandler().GetResponse().AppendInt32(item3.Id);
                            }
                            this.Session.GetMessageHandler().SendResponse();
                            this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                        }
                    }
                }
            }
        }

        public void OpenQuests()
        {
            ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().LoadQuests(this.Session);
        }

        internal void PerformSearch()
        {
            if (this.Session.GetHabbo() != null)
            {
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeSearchResults(this.Request.PopFixedString()));
            }
        }

        internal void PerformSearch2()
        {
            if (this.Session.GetHabbo() != null)
            {
                int num = this.Request.PopWiredInt32();
                this.Session.SendMessage(ButterflyEnvironment.GetGame().GetNavigator().SerializeSearchResults(this.Request.PopFixedString()));
            }
        }

        internal void PetRaces()
        {
            string str = this.Request.PopFixedString();
            int sRaceId = 0;
            this.GetResponse().Init(Outgoing.PetRace);
            switch (str)
            {
                case "a0 pet0":
                    this.GetResponse().AppendString("a0 pet0");
                    sRaceId = 0;
                    break;

                case "a0 pet1":
                    this.GetResponse().AppendString("a0 pet1");
                    sRaceId = 1;
                    break;

                case "a0 pet2":
                    this.GetResponse().AppendString("a0 pet2");
                    sRaceId = 2;
                    break;

                case "a0 pet3":
                    this.GetResponse().AppendString("a0 pet3");
                    sRaceId = 3;
                    break;

                case "a0 pet4":
                    this.GetResponse().AppendString("a0 pet4");
                    sRaceId = 4;
                    break;

                case "a0 pet5":
                    this.GetResponse().AppendString("a0 pet5");
                    sRaceId = 5;
                    break;

                case "a0 pet6":
                    this.GetResponse().AppendString("a0 pet6");
                    sRaceId = 6;
                    break;

                case "a0 pet7":
                    this.GetResponse().AppendString("a0 pet7");
                    sRaceId = 7;
                    break;

                case "a0 pet8":
                    this.GetResponse().AppendString("a0 pet8");
                    sRaceId = 8;
                    break;

                case "a0 pet9":
                    this.GetResponse().AppendString("a0 pet9");
                    sRaceId = 9;
                    break;

                case "a0 pet10":
                    this.GetResponse().AppendString("a0 pet10");
                    sRaceId = 10;
                    break;

                case "a0 pet11":
                    this.GetResponse().AppendString("a0 pet11");
                    sRaceId = 11;
                    break;

                case "a0 pet12":
                    this.GetResponse().AppendString("a0 pet12");
                    sRaceId = 12;
                    break;

                case "a0 pet13":
                    this.GetResponse().AppendString("a0 pet13");
                    sRaceId = 13;
                    break;

                case "a0 pet14":
                    this.GetResponse().AppendString("a0 pet14");
                    sRaceId = 14;
                    break;

                case "a0 pet15":
                    this.GetResponse().AppendString("a0 pet15");
                    sRaceId = 15;
                    break;

                case "a0 pet16":
                    this.GetResponse().AppendString("a0 pet16");
                    sRaceId = 0x10;
                    break;

                case "a0 pet17":
                    this.GetResponse().AppendString("a0 pet17");
                    sRaceId = 0x11;
                    break;

                case "a0 pet18":
                    this.GetResponse().AppendString("a0 pet18");
                    sRaceId = 0x12;
                    break;

                case "a0 pet19":
                    this.GetResponse().AppendString("a0 pet19");
                    sRaceId = 0x13;
                    break;

                case "a0 pet20":
                    this.GetResponse().AppendString("a0 pet20");
                    sRaceId = 20;
                    break;

                case "a0 pet21":
                    this.GetResponse().AppendString("a0 pet21");
                    sRaceId = 0x15;
                    break;

                case "a0 pet22":
                    this.GetResponse().AppendString("a0 pet22");
                    sRaceId = 0x16;
                    break;
            }
            if (PetRace.RaceGotRaces(sRaceId))
            {
                List<PetRace> racesForRaceId = PetRace.GetRacesForRaceId(sRaceId);
                this.GetResponse().AppendInt32(racesForRaceId.Count);
                foreach (PetRace race in racesForRaceId)
                {
                    this.GetResponse().AppendInt32(sRaceId);
                    this.GetResponse().AppendInt32(race.Color1);
                    this.GetResponse().AppendInt32(race.Color2);
                    this.GetResponse().AppendBoolean(race.Has1Color);
                    this.GetResponse().AppendBoolean(race.Has2Color);
                }
            }
            else
            {
                this.Session.SendNotif("\x00a1Ha ocurrido un error cuando ibas a ver esta mascota, rep\x00f3rtalo a un administrador!");
                this.GetResponse().AppendInt32(0);
            }
            this.SendResponse();
        }

        internal void PickUpPet()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((((this.Session != null) && (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().GetInventoryComponent() != null)) && (((room != null) && !room.IsPublic) && (room.AllowPets || room.CheckRights(this.Session, true))))
            {
                uint petId = this.Request.PopWiredUInt();
                RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                if (pet != null)
                {
                    if (pet.montandoBol)
                    {
                        RoomUser roomUserByVirtualId = room.GetRoomUserManager().GetRoomUserByVirtualId(Convert.ToInt32(pet.montandoID));
                        if (roomUserByVirtualId != null)
                        {
                            roomUserByVirtualId.montandoBol = false;
                            roomUserByVirtualId.ApplyEffect(-1);
                            roomUserByVirtualId.MoveTo(new Point(roomUserByVirtualId.X + 1, roomUserByVirtualId.Y + 1));
                        }
                    }
                    if (pet.PetData.DBState != DatabaseUpdateState.NeedsInsert)
                    {
                        pet.PetData.DBState = DatabaseUpdateState.NeedsUpdate;
                    }
                    pet.PetData.RoomId = 0;
                    this.Session.GetHabbo().GetInventoryComponent().AddPet(pet.PetData);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        room.GetRoomUserManager().SavePets(adapter);
                    }
                    room.GetRoomUserManager().RemoveBot(pet.VirtualId, false);
                    this.Session.SendMessage(this.Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
                }
            }
        }

        internal void Ping()
        {
            Habbo habbo = this.Session.GetHabbo();
            habbo.PointsOnline++;
            ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_AllTimeHotelPresence", 1);
            if ((this.Session.GetHabbo().SnowWar != null) && (this.Session.GetHabbo().SnowStep == 2))
            {
                this.Session.GetHabbo().SnowPing = true;
            }
        }

        internal void PlaceItem()
        {
            Room pRoom = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);

            if ((pRoom != null) && (pRoom.CheckRights(this.Session)))
            {
                string str = this.Request.PopFixedString();
                string[] strArray = str.Split(new char[] { ' ' });
                uint id = uint.Parse(strArray[0].Replace("-", ""));
                UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(id);
                if (item != null)
                {
                    RoomItem item2;
                    if (item.GetBaseItem().InteractionType == InteractionType.dimmer)
                    {
                        MoodlightData moodlightData = pRoom.MoodlightData;
                        if ((moodlightData != null) && (pRoom.GetRoomItemHandler().GetItem(moodlightData.ItemId) != null))
                        {
                            this.Session.SendNotif(LanguageLocale.GetValue("user.maxmoodlightsreached"));
                        }
                    }

                    if (strArray[1].StartsWith(":"))
                    {
                        try
                        {
                            WallCoordinate wallCoord = new WallCoordinate(":" + str.Split(new char[] { ':' })[1]);
                            item2 = new RoomItem(item.Id, pRoom.RoomId, item.BaseItem, item.ExtraData, wallCoord, pRoom, item.Group_data, item.RareId, item.placedBy);
                            if (pRoom.GetRoomItemHandler().SetWallItem(this.Session, item2))
                            {
                                this.Session.GetHabbo().GetInventoryComponent().RemoveItem(id, true);
                            }
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        int x = int.Parse(strArray[1]);
                        int y = int.Parse(strArray[2]);
                        int rot = int.Parse(strArray[3]);
                        if (this.Session.GetHabbo().forceRot > -1)
                        {
                            rot = this.Session.GetHabbo().forceRot;
                        }
                        item2 = new RoomItem(item.Id, pRoom.RoomId, item.BaseItem, item.ExtraData, x, y, 0.0, rot, pRoom, item.Group_data, item.RareId, item.placedBy);
                        if (pRoom.GetRoomItemHandler().SetFloorItem(this.Session, item2, x, y, rot, true, false, true))
                        {
                            this.Session.GetHabbo().GetInventoryComponent().RemoveItem(id, true);
                        }
                        if (WiredUtillity.TypeIsWired(item.GetBaseItem().InteractionType))
                        {
                            WiredSaver.HandleDefaultSave(item.Id, pRoom);
                        }
                    }
                }
            }
        }

        internal void PlacePet()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && (room.AllowPets || room.CheckRights(this.Session, true))) && room.CheckRights(this.Session, true))
            {
                uint id = this.Request.PopWiredUInt();
                Pet petData = this.Session.GetHabbo().GetInventoryComponent().GetPet(id);
                if ((petData != null) && !petData.PlacedInRoom)
                {
                    int x = this.Request.PopWiredInt32();
                    int y = this.Request.PopWiredInt32();
                    if (room.GetGameMap().CanWalk(x, y, false))
                    {
                        RoomUser pet = room.GetRoomUserManager().GetPet(id);
                        if (pet != null)
                        {
                            room.GetRoomUserManager().RemoveBot(pet.VirtualId, false);
                        }
                        petData.PlacedInRoom = true;
                        petData.RoomId = room.RoomId;
                        List<RandomSpeech> speeches = new List<RandomSpeech>();
                        List<BotResponse> responses = new List<BotResponse>();
                        RoomUser user2 = room.GetRoomUserManager().DeployBot(new RoomBot(petData.PetId, petData.RoomId, AIType.Pet, "freeroam", petData.Name, "", petData.Look, x, y, 0, 0, 0, 0, 0, 0, ref speeches, ref responses), petData);
                        this.Session.GetHabbo().GetInventoryComponent().MovePetToRoom(petData.PetId);
                        if (petData.DBState != DatabaseUpdateState.NeedsInsert)
                        {
                            petData.DBState = DatabaseUpdateState.NeedsUpdate;
                        }
                        using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            room.GetRoomUserManager().SavePets(adapter);
                        }
                        this.Session.SendMessage(this.Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
                    }
                }
            }
        }

        internal void PlacePostIt()
        {
            Room pRoom = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((pRoom != null) && pRoom.CheckRights(this.Session))
            {
                uint id = this.Request.PopWiredUInt();
                string str = this.Request.PopFixedString();
                UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(id);
                if ((item != null) && (pRoom != null))
                {
                    try
                    {
                        WallCoordinate wallCoord = new WallCoordinate(":" + str.Split(new char[] { ':' })[1]);
                        RoomItem item2 = new RoomItem(item.Id, pRoom.RoomId, item.BaseItem, item.ExtraData, wallCoord, pRoom, item.Group_data, item.RareId, item.placedBy);
                        if (pRoom.GetRoomItemHandler().SetWallItem(this.Session, item2))
                        {
                            this.Session.GetHabbo().GetInventoryComponent().RemoveItem(id, true);
                        }
                    }
                    catch
                    {
                        this.Response.Init(0x204);
                        this.Response.AppendInt32(11);
                        this.SendResponse();
                    }
                }
            }
        }

        internal void Pong()
        {
            this.Session.TimePingedReceived = DateTime.Now;
        }

        public void PopularGuilds()
        {
            ServerMessage message = new ServerMessage(Outgoing.NavigatorPacket);
            message.AppendInt32(14);
            message.AppendString("");
            KeyValuePair<RoomData, int>[] guildRooms = ButterflyEnvironment.GetGame().GetRoomManager().GetGuildRooms();
            if (guildRooms != null)
            {
                message.AppendInt32(guildRooms.Length);
                for (int i = 0; i < guildRooms.Length; i++)
                {
                    guildRooms[i].Key.Serialize(message, false);
                }
            }
            else
            {
                message.AppendInt32(0);
            }
            message.AppendBoolean(false);
            this.Session.SendMessage(message);
        }

        internal void PrepareRoomForUser(uint Id, string Password)
        {
            this.ClearRoomLoading();
            QueuedServerMessage message = new QueuedServerMessage(this.Session.GetConnection());
            if (ButterflyEnvironment.ShutdownStarted)
            {
                this.Session.SendNotif(LanguageLocale.GetValue("shutdown.alert"));
            }
            else
            {
                if (this.Session.GetHabbo().InRoom)
                {
                    Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                    if (room != null)
                    {
                        room.GetRoomUserManager().RemoveUserFromRoom(this.Session, false, false);
                        this.Session.CurrentRoomUserID = -1;
                    }
                }
                Room room2 = ButterflyEnvironment.GetGame().GetRoomManager().LoadRoom(Id);
                if (((room2.UserCount + 1) >= room2.UsersMax) && (this.Session.GetHabbo().Rank < 5))
                {
                    ServerMessage message2 = new ServerMessage(Outgoing.RoomErrorToEnter);
                    message2.AppendInt32(1);
                    this.Session.SendMessage(message2);
                    ServerMessage message3 = new ServerMessage(Outgoing.OutOfRoom);
                    this.Session.SendMessage(message3);
                }
                else if ((((room2 != null) && (this.Session != null)) && (this.Session.GetHabbo() != null)) && (!this.Session.GetHabbo().IsTeleporting || (this.Session.GetHabbo().TeleportingRoomID == Id)))
                {
                    this.Session.GetHabbo().LoadingRoom = Id;
                    this.CurrentLoadingRoom = room2;
                    if (!this.Session.GetHabbo().HasFuse("fuse_enter_any_room") && room2.UserIsBanned(this.Session.GetHabbo().Id))
                    {
                        if (room2.HasBanExpired(this.Session.GetHabbo().Id))
                        {
                            room2.RemoveBan(this.Session.GetHabbo().Id);
                        }
                        else
                        {
                            this.Response.Init(Outgoing.RoomErrorToEnter);
                            this.Response.AppendInt32(4);
                            message.appendResponse(this.GetResponse());
                            this.Response.Init(Outgoing.OutOfRoom);
                            message.appendResponse(this.GetResponse());
                            message.sendResponse();
                            return;
                        }
                    }
                    if (((room2.UsersNow >= room2.UsersMax) && !this.Session.GetHabbo().HasFuse("fuse_enter_full_rooms")) && !ButterflyEnvironment.GetGame().GetRoleManager().RankHasRight(this.Session.GetHabbo().Rank, "fuse_enter_full_rooms"))
                    {
                        this.Response.Init(Outgoing.RoomErrorToEnter);
                        this.Response.AppendInt32(1);
                        message.appendResponse(this.GetResponse());
                        this.Response.Init(Outgoing.OutOfRoom);
                        message.appendResponse(this.GetResponse());
                        message.sendResponse();
                    }
                    else
                    {
                        if (room2.Type == "private")
                        {
                            this.Response.Init(Outgoing.PrepareRoomForUsers);
                            message.appendResponse(this.GetResponse());
                            if ((!this.Session.GetHabbo().HasFuse("fuse_enter_any_room") && !room2.CheckRights(this.Session, true)) && !this.Session.GetHabbo().IsTeleporting)
                            {
                                if (room2.State == 1)
                                {
                                    if (room2.UserCount == 0)
                                    {
                                        this.Response.Init(Outgoing.DoorBellNoPerson);
                                        message.appendResponse(this.GetResponse());
                                    }
                                    else
                                    {
                                        this.Response.Init(Outgoing.Doorbell);
                                        this.Response.AppendString("");
                                        message.appendResponse(this.GetResponse());
                                        ServerMessage message4 = new ServerMessage(Outgoing.Doorbell);
                                        message4.AppendString(this.Session.GetHabbo().Username);
                                        room2.SendMessageToUsersWithRights(message4);
                                    }
                                    message.sendResponse();
                                    return;
                                }
                                if ((room2.State == 2) && (Password.ToLower() != room2.Password.ToLower()))
                                {
                                    this.Response.Init(Outgoing.RoomError);
                                    this.Response.AppendInt32(-100002);
                                    message.appendResponse(this.GetResponse());
                                    this.Response.Init(Outgoing.OutOfRoom);
                                    message.appendResponse(this.GetResponse());
                                    message.sendResponse();
                                    return;
                                }
                            }
                        }
                        this.Session.GetHabbo().LoadingChecksPassed = true;
                        message.addBytes(this.LoadRoomForUser().getPacket);
                        message.sendResponse();
                    }
                }

            }
        }

        internal void PurchaseGift()
        {
            int pageId = this.Request.PopWiredInt32();
            uint itemId = this.Request.PopWiredUInt();
            string extraData = this.Request.PopFixedString();
            string giftUser = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
            string giftMessage = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
            int giftSpriteId = this.Request.PopWiredInt32();
            int giftLazo = this.Request.PopWiredInt32();
            int giftColor = this.Request.PopWiredInt32();
            bool undef = this.Request.PopWiredBoolean();
            ButterflyEnvironment.GetGame().GetCatalog().HandlePurchase(this.Session, pageId, itemId, extraData, 1, true, giftUser, giftMessage, giftSpriteId, giftLazo, giftColor, undef);
        }

        internal void RateRoom()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && !this.Session.GetHabbo().RatedRooms.Contains(room.RoomId)) && !room.CheckRights(this.Session, true))
            {
                switch (this.Request.PopWiredInt32())
                {
                    case -1:
                        {
                            room.Score--;
                            RoomData roomData = room.RoomData;
                            roomData.Score--;
                            goto Label_00D0;
                        }
                    case 1:
                        {
                            room.Score++;
                            RoomData data2 = room.RoomData;
                            data2.Score++;
                            goto Label_00D0;
                        }
                }
            }
            return;
        Label_00D0:
            ButterflyEnvironment.GetGame().GetRoomManager().QueueVoteAdd(room.RoomData);
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery(string.Concat(new object[] { "UPDATE rooms SET score = ", room.Score, " WHERE id = ", room.RoomId }));
            }
            this.Session.GetHabbo().RatedRooms.Add(room.RoomId);
            this.Response.Init(Outgoing.RateRoom);
            this.Response.AppendInt32(room.Score);
            this.SendResponseWithOwnerParam();
        }

        internal void RecycleItems()
        {
            if (this.Session.GetHabbo().InRoom)
            {
                int num = this.Request.PopWiredInt32();
                if (num == 5)
                {
                    uint num3;
                    for (int i = 0; i < num; i++)
                    {
                        UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(this.Request.PopWiredUInt());
                        if ((item != null) && item.GetBaseItem().AllowRecycle)
                        {
                            this.Session.GetHabbo().GetInventoryComponent().RemoveItem(item.Id, false);
                        }
                        else
                        {
                            return;
                        }
                    }
                    EcotronReward randomEcotronReward = ButterflyEnvironment.GetGame().GetCatalog().GetRandomEcotronReward();
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        if (adapter.dbType == DatabaseType.MSSQL)
                        {
                            adapter.setQuery("INSERT INTO user_items (user_id,base_item,extra_data) OUTPUT INSERTED.* VALUES ( @userid ,1478, @timestamp)");
                        }
                        else
                        {
                            adapter.setQuery("INSERT INTO user_items (user_id,base_item,extra_data) VALUES ( @userid ,1478, @timestamp)");
                        }
                        adapter.addParameter("userid", (int)this.Session.GetHabbo().Id);
                        adapter.addParameter("timestamp", DateTime.Now.ToLongDateString());
                        num3 = (uint)adapter.insertQuery();
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (", num3, ",", randomEcotronReward.BaseId, ",1,'')" }));
                    }
                    this.Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                    this.Response.Init(0x1fc);
                    this.Response.AppendBoolean(true);
                    this.Response.AppendInt32(num3);
                    this.SendResponse();
                }
            }
        }

        internal void RedeemExchangeFurni()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                if ((item != null) && (item.GetBaseItem().Name.StartsWith("CF_") || item.GetBaseItem().Name.StartsWith("CFC_")))
                {
                    int num = int.Parse(item.GetBaseItem().Name.Split(new char[] { '_' })[1]);
                    if (num > 0)
                    {
                        Habbo habbo = this.Session.GetHabbo();
                        habbo.Credits += num;
                        this.Session.GetHabbo().UpdateCreditsBalance();
                    }
                    room.GetRoomItemHandler().RemoveFurniture(null, item.Id);
                    this.Response.Init(Outgoing.UpdateInventary);
                    this.SendResponse();
                }
            }
        }

        internal void RedeemVoucher()
        {
            VoucherHandler.TryRedeemVoucher(this.Session, this.Request.PopFixedString());
        }

        internal void RemoveBuddy()
        {
            if (this.Session.GetHabbo().GetMessenger() != null)
            {
                int num = this.Request.PopWiredInt32();
                for (int i = 0; i < num; i++)
                {
                    this.Session.GetHabbo().GetMessenger().DestroyFriendship(this.Request.PopWiredUInt());
                }
            }
        }

        public void RemoveCdToJuke()
        {
            if (((this.Session != null) && (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().CurrentRoom != null))
            {
                Room currentRoom = this.Session.GetHabbo().CurrentRoom;
                if (currentRoom.CheckRights(this.Session, true) && currentRoom.GotMusicController())
                {
                    RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
                    SongItem item = roomMusicController.RemoveDisk(this.Request.PopWiredInt32());
                    if (item != null)
                    {
                        item.RemoveFromDatabase();
                        this.Session.GetHabbo().GetInventoryComponent().AddNewItem((uint)item.itemID, item.baseItem.ItemId, item.songID.ToString(), true, true, 0, "", (uint)item.songID);
                        this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                        this.Session.SendMessage(JukeboxDiscksComposer.SerializeSongInventory(this.Session.GetHabbo().GetInventoryComponent().songDisks));
                        this.Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList<SongInstance>()));
                    }
                }
            }
        }

        internal void RemoveFavorite()
        {
            if (this.Session.GetHabbo() != null)
            {
                uint num = this.Request.PopWiredUInt();
                this.Session.GetHabbo().FavoriteRooms.Remove(num);
                this.GetResponse().Init(Outgoing.FavsUpdate);
                this.GetResponse().AppendInt32(num);
                this.GetResponse().AppendBoolean(false);
                this.SendResponse();
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.runFastQuery(string.Concat(new object[] { "DELETE FROM user_favorites WHERE user_id = ", this.Session.GetHabbo().Id, " AND room_id = ", num }));
                }
            }
        }

        internal void RemoveGuildFavorite()
        {
            this.Session.GetHabbo().FavoriteGuild = 0;
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery("UPDATE users SET FavoriteGroup = '0' WHERE Id = '" + this.Session.GetHabbo().Id + "'");
            }
            ServerMessage message = new ServerMessage(Outgoing.UpdatePetitionsGuild);
            message.AppendInt32(0);
            message.AppendInt32(-1);
            message.AppendInt32(-1);
            message.AppendString("");
            if (this.Session.GetHabbo().CurrentRoomId > 0)
            {
                ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).SendMessage(message);
            }
            else
            {
                this.Session.SendMessage(message);
            }
            ServerMessage message2 = new ServerMessage(Outgoing.RemoveGuildFavorite);
            message2.AppendInt32((int)this.Session.GetHabbo().Id);
            this.Session.SendMessage(message2);
        }

        internal void RemoveHanditem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if ((roomUserByHabbo != null) && ((roomUserByHabbo.CarryItemID > 0) && (roomUserByHabbo.CarryTimer > 0)))
                {
                    roomUserByHabbo.CarryItem(0);
                }
            }
        }

        internal void RemoveSaddle()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && !room.IsPublic) && (room.AllowPets || room.CheckRights(this.Session, true)))
            {
                uint petId = this.Request.PopWiredUInt();
                RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                if (((pet != null) && (pet.PetData != null)) && (pet.PetData.OwnerId == this.Session.GetHabbo().Id))
                {
                    if (pet.PetData.HaveSaddle == 2)
                    {
                        ButterflyEnvironment.GetGame().GetCatalog().DeliverItems(this.Session, ButterflyEnvironment.GetGame().GetItemManager().GetItem(0xfa1), 1, "", 0, 0);
                    }
                    else if (pet.PetData.HaveSaddle == 1)
                    {
                        ButterflyEnvironment.GetGame().GetCatalog().DeliverItems(this.Session, ButterflyEnvironment.GetGame().GetItemManager().GetItem(0xaf4), 1, "", 0, 0);
                    }
                    pet.PetData.HaveSaddle = 0;
                    this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery("UPDATE user_pets SET have_saddle = 0 WHERE id = " + pet.PetData.PetId);
                    }
                    ServerMessage message = new ServerMessage(Outgoing.SerializeMontura);
                    message.AppendInt32(pet.PetData.VirtualId);
                    message.AppendInt32(pet.PetData.PetId);
                    message.AppendInt32(pet.PetData.Type);
                    message.AppendInt32(int.Parse(pet.PetData.Race));
                    message.AppendString(pet.PetData.Color.ToLower());
                    message.AppendInt32(1);
                    message.AppendInt32(2);
                    message.AppendInt32(2);
                    message.AppendInt32(pet.PetData.PetHair);
                    message.AppendInt32(pet.PetData.HairDye);
                    message.AppendInt32(3);
                    message.AppendInt32(pet.PetData.PetHair);
                    message.AppendInt32(pet.PetData.HairDye);
                    message.AppendBoolean(pet.PetData.HaveSaddle != 0);
                    message.AppendBoolean(pet.montandoBol);
                    room.SendMessage(message);
                }
            }
        }

        internal void ReqLoadRoomForUser()
        {
            this.LoadRoomForUser().sendResponse();
        }

        internal void RequestBuddy()
        {
            if ((this.Session.GetHabbo().GetMessenger() != null) && this.Session.GetHabbo().GetMessenger().RequestBuddy(this.Request.PopFixedString()))
            {
                ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("REQUEST_FRIEND", this.Session);
            }
        }

        internal void RespectPet()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && !room.IsPublic) && (room.AllowPets || room.CheckRights(this.Session, true)))
            {
                uint petId = this.Request.PopWiredUInt();
                RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                if (((pet != null) && (pet.PetData != null)) && (pet.PetData.OwnerId == this.Session.GetHabbo().Id))
                {
                    pet.PetData.OnRespect();
                    Habbo habbo = this.Session.GetHabbo();
                    habbo.DailyPetRespectPoints--;
                    ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_PetRespectGiver", 1);
                    ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(pet.PetData.OwnerId), "ACH_PetRespectReceiver", 1);
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery("UPDATE users SET daily_pet_respect_points = daily_pet_respect_points - 1 WHERE id = " + this.Session.GetHabbo().Id);
                    }
                }
            }
        }

        internal void SaveMannequin()
        {
            uint ItemId = Request.PopWiredUInt();
            Room Room = Session.GetHabbo().CurrentRoom;
            RoomItem Item = Room.GetRoomItemHandler().GetItem(ItemId);
            if (Session.GetHabbo().Look.Contains(GetHair(Session.GetHabbo().Look)))
            {
                Item.ExtraData = Session.GetHabbo().Look.Replace(GetHair(Session.GetHabbo().Look), "");
            }
            else
            {
                Item.ExtraData = Session.GetHabbo().Look;
            }
            Item.UpdateNeeded = true;
            Item.ProcessUpdates();
            Room.GetRoomItemHandler().SetFloorItem(Session, Item, Item.GetX, Item.GetY, Item.Rot, false, false, true);
            Room.GetRoomItemHandler().SaveFurniture(ButterflyEnvironment.GetDatabaseManager().getQueryreactor());
            IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor();
            dbClient.runFastQuery("DELETE FROM items_extradata WHERE item_id = " + Item.Id);
            dbClient.runFastQuery("INSERT INTO items_extradata (item_id, data) VALUES (" + Item.Id + ", '" + Item.ExtraData + "')");
        }

        internal string GetHair(string _Figure)
        {
            string FigurePartHair = _Figure;
            string GetHairPart;

            GetHairPart = System.Text.RegularExpressions.Regex.Split(_Figure, "hr")[1];
            FigurePartHair = GetHairPart.Split('.')[0];
            string FigurePartBody = _Figure;
            string GetBodyPart;

            GetBodyPart = System.Text.RegularExpressions.Regex.Split(_Figure, "hd")[1];
            FigurePartBody = GetBodyPart.Split('.')[0];

            string _Uni = Convert.ToString("hr" + FigurePartHair + "." + "hd" + FigurePartBody + ".");

            return _Uni;
        }

        public void SaveNameToChange()
        {
            string s = this.Request.PopFixedString();
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                string username = this.Session.GetHabbo().Username;
                this.Session.GetHabbo().Username = s;
                this.Session.GetHabbo().CanChangeName = false;
                foreach (RoomData data in this.Session.GetHabbo().UsersRooms)
                {
                    data.Owner = s;
                }
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET username = '", s, "', canchangename = '0' WHERE id = '", this.Session.GetHabbo().Id, "'" }));
                    adapter.runFastQuery("UPDATE rooms SET owner = '" + s + "' WHERE owner = '" + username + "'");
                }
                ServerMessage message = new ServerMessage(Outgoing.GetName);
                message.AppendInt32(0);
                message.AppendString(s);
                message.AppendInt32(0);
                this.Session.SendMessage(message);
                ServerMessage message2 = new ServerMessage(Outgoing.ChangePublicName);
                message2.AppendInt32(this.Session.GetHabbo().Id);
                message2.AppendInt32(this.Session.CurrentRoomUserID);
                message2.AppendString(s);
                room.SendMessage(message2);
                if (this.Session.GetHabbo().Id == room.OwnerId)
                {
                    ServerMessage message3 = new ServerMessage(Outgoing.UpdateRoom);
                    message3.AppendInt32(room.RoomId);
                    room.SendMessage(message3);
                }
                ServerMessage message4 = new ServerMessage(Outgoing.UpdateUserInformation);
                message4.AppendInt32(-1);
                message4.AppendString(this.Session.GetHabbo().Look);
                message4.AppendString(this.Session.GetHabbo().Gender.ToLower());
                message4.AppendString(this.Session.GetHabbo().Motto);
                message4.AppendInt32(this.Session.GetHabbo().AchievementPoints);
                this.Session.SendMessage(message4);
                ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Session, "ACH_Name", 1);
                if (this.Session.GetHabbo().InRoom)
                {
                    ServerMessage message5 = new ServerMessage(Outgoing.UpdateUserInformation);
                    message5.AppendInt32(room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id).VirtualId);
                    message5.AppendString(this.Session.GetHabbo().Look);
                    message5.AppendString(this.Session.GetHabbo().Gender.ToLower());
                    message5.AppendString(this.Session.GetHabbo().Motto);
                    message5.AppendInt32(this.Session.GetHabbo().AchievementPoints);
                    room.SendMessage(message5);
                }
                ServerMessage message6 = new ServerMessage(Outgoing.RoomData);
                message6.AppendBoolean(true);
                message6.AppendInt32(room.RoomId);
                message6.AppendString(room.Name);
                message6.AppendBoolean(true);
                message6.AppendInt32(room.OwnerId);
                message6.AppendString(room.Owner);
                message6.AppendInt32(room.State);
                message6.AppendInt32(room.UsersNow);
                message6.AppendInt32(room.UsersMax);
                message6.AppendString(room.Description);
                message6.AppendInt32(0);
                message6.AppendInt32((room.Category == 0x34) ? 2 : 0);
                message6.AppendInt32(room.Score);
                message6.AppendInt32(0);
                message6.AppendInt32(room.Category);
                if (room.GetRoomGuild() == null)
                {
                    message6.AppendInt32(0);
                    message6.AppendInt32(0);
                }
                else
                {
                    message6.AppendInt32(room.GetRoomGuild().Id);
                    message6.AppendString(room.GetRoomGuild().Name);
                    message6.AppendString(room.GetRoomGuild().Image);
                }
                message6.AppendString("");
                message6.AppendInt32(room.TagCount);
                foreach (string str3 in room.Tags.ToArray())
                {
                    message6.AppendString(str3);
                }
                message6.AppendInt32(0);
                message6.AppendInt32(0);
                message6.AppendInt32(0);
                message6.AppendBoolean(true);
                message6.AppendBoolean(true);
                message6.AppendInt32(0);
                message6.AppendInt32(0);
                message6.AppendBoolean(false);
                message6.AppendBoolean(false);
                message6.AppendBoolean(false);
                message6.AppendInt32(0);
                message6.AppendInt32(0);
                message6.AppendInt32(0);
                room.SendMessage(message6);
            }
        }

        internal void SavePostit()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                if ((item != null) && (item.GetBaseItem().InteractionType == InteractionType.postit))
                {
                    string str = this.Request.PopFixedString();
                    string str2 = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString(), true);
                    if (room.CheckRights(this.Session) || str2.StartsWith(item.ExtraData))
                    {
                        string str3 = str;
                        if ((str3 != null) && ((((str3 == "FFFF33") || (str3 == "FF9CFF")) || (str3 == "9CCEFF")) || (str3 == "9CFF9C")))
                        {
                            item.ExtraData = str + " " + str2;
                            item.UpdateState(true, true);
                        }
                    }
                }
            }
        }

        internal void SaveRoomData()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            RoomData roomData = room.RoomData;
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                int num = this.Request.PopWiredInt32();
                string str = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                string str2 = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                int num2 = this.Request.PopWiredInt32();
                string str3 = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                int num3 = this.Request.PopWiredInt32();
                int id = this.Request.PopWiredInt32();
                int num5 = this.Request.PopWiredInt32();
                List<string> tags = new List<string>();
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < num5; i++)
                {
                    if (i > 0)
                    {
                        builder.Append(",");
                    }
                    string item = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString().ToLower());
                    tags.Add(item);
                    builder.Append(item);
                }
                int num7 = this.Request.PopWiredInt32();
                bool k = this.Request.PopWiredBoolean();
                bool flag2 = this.Request.PopWiredBoolean();
                bool flag3 = this.Request.PopWiredBoolean();
                bool flag4 = this.Request.PopWiredBoolean();
                int num8 = this.Request.PopWiredInt32();
                int num9 = this.Request.PopWiredInt32();
                if ((num8 < -2) || (num8 > 1))
                {
                    num8 = 0;
                }
                if ((num9 < -2) || (num9 > 1))
                {
                    num9 = 0;
                }
                if (((str.Length >= 1) && ((num2 >= 0) && (num2 <= 2))) && ((num3 >= 10) && (num3 <= 50)))
                {
                    FlatCat flatCat = ButterflyEnvironment.GetGame().GetNavigator().GetFlatCat(id);
                    if (flatCat != null)
                    {
                        if (flatCat.MinRank > this.Session.GetHabbo().Rank)
                        {
                            this.Session.SendNotif(LanguageLocale.GetValue("user.roomdata.rightserror"));
                            id = 0;
                        }
                        if (num5 <= 2)
                        {
                            room.AllowPets = k;
                            room.AllowPetsEating = flag2;
                            room.AllowWalkthrough = flag3;
                            room.Hidewall = flag4;
                            room.RoomData.AllowPets = k;
                            room.RoomData.AllowPetsEating = flag2;
                            room.RoomData.AllowWalkthrough = flag3;
                            room.RoomData.Hidewall = flag4;
                            room.Name = str;
                            room.State = num2;
                            room.Description = str2;
                            room.Category = id;
                            room.Password = str3;
                            room.RoomData.Name = str;
                            room.RoomData.State = num2;
                            room.RoomData.Description = str2;
                            room.RoomData.Category = id;
                            room.RoomData.Password = str3;
                            room.ClearTags();
                            room.AddTagRange(tags);
                            room.UsersMax = num3;
                            room.RoomData.Tags.Clear();
                            room.RoomData.Tags.AddRange(tags);
                            room.RoomData.UsersMax = num3;
                            room.WallThickness = num8;
                            room.FloorThickness = num9;
                            room.RoomData.WallThickness = num8;
                            room.RoomData.FloorThickness = num9;
                            string str5 = "open";
                            if (room.State == 1)
                            {
                                str5 = "locked";
                            }
                            else if (room.State > 1)
                            {
                                str5 = "password";
                            }
                            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.setQuery(string.Concat(new object[] { 
                                    "UPDATE rooms SET caption = @caption, description = @description, password = @password, category = ", id, ", state = '", str5, "', tags = @tags, users_max = ", num3, ", allow_pets = ", TextHandling.BooleanToInt(k), ", allow_pets_eat = ", TextHandling.BooleanToInt(flag2), ", allow_walkthrough = ", TextHandling.BooleanToInt(flag3), ", allow_hidewall = ", TextHandling.BooleanToInt(room.Hidewall), ", floorthickness = ", room.FloorThickness, 
                                    ", wallthickness = ", room.WallThickness, " WHERE id = ", room.RoomId
                                 }));
                                adapter.addParameter("caption", room.Name);
                                adapter.addParameter("description", room.Description);
                                adapter.addParameter("password", room.Password);
                                adapter.addParameter("tags", builder.ToString());
                                adapter.runQuery();
                            }

                            this.GetResponse().Init(Outgoing.UpdateRoomOne);
                            this.GetResponse().AppendInt32(room.RoomId);

                            this.SendResponse();

                            this.GetResponse().Init(Outgoing.ConfigureWallandFloor);
                            this.GetResponse().AppendBoolean(room.Hidewall);
                            this.GetResponse().AppendInt32(room.WallThickness);
                            this.GetResponse().AppendInt32(room.FloorThickness);

                            this.Session.GetHabbo().CurrentRoom.SendMessage(this.GetResponse());

                            RoomData data2 = room.RoomData;

                            this.GetResponse().Init(Outgoing.RoomData);
                            this.GetResponse().AppendBoolean(false);
                            this.GetResponse().AppendInt32(room.RoomId);
                            this.GetResponse().AppendString(room.Name);
                            this.GetResponse().AppendBoolean(true);
                            this.GetResponse().AppendInt32(room.OwnerId);
                            this.GetResponse().AppendString(room.Owner);
                            this.GetResponse().AppendInt32(room.State);
                            this.GetResponse().AppendInt32(room.UsersNow);
                            this.GetResponse().AppendInt32(room.UsersMax);
                            this.GetResponse().AppendString(room.Description);
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32((room.Category == 0x34) ? 2 : 0);
                            this.GetResponse().AppendInt32(room.Score);
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(room.Category);

                            if (room.GroupId == 0)
                            {
                                this.GetResponse().AppendInt32(0);
                                this.GetResponse().AppendInt32(0);
                            }
                            else
                            {
                                MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(room.GroupId);
                                this.GetResponse().AppendInt32(guild.Id);
                                this.GetResponse().AppendString(guild.Name);
                                this.GetResponse().AppendString(guild.Image);
                            }

                            this.GetResponse().AppendString("");
                            this.GetResponse().AppendInt32(room.TagCount);

                            foreach (string str6 in room.Tags)
                            {
                                this.GetResponse().AppendString(str6);
                            }

                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendBoolean(true);
                            this.GetResponse().AppendBoolean(true);
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(0);

                            this.Response.AppendBoolean(false);
                            this.Response.AppendBoolean(false);
                            this.Response.AppendBoolean(false);

                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(0);
                            this.GetResponse().AppendInt32(0);

                            this.Session.GetHabbo().CurrentRoom.SendMessage(this.GetResponse());
                        }
                    }
                }
            }
        }

        public void SaveSettingsPackets(MyGuild Guild, Room Room)
        {
            ServerMessage message = new ServerMessage(Outgoing.ConfigureWallandFloor);
            message.AppendBoolean(Room.Hidewall);
            message.AppendInt32(Room.WallThickness);
            message.AppendInt32(Room.FloorThickness);
            this.Session.SendMessage(message);
            ServerMessage message2 = new ServerMessage(Outgoing.RoomData);
            message2.AppendBoolean(false);
            message2.AppendInt32(Room.RoomId);
            message2.AppendString(Room.Name);
            message2.AppendBoolean(true);
            message2.AppendInt32(Room.OwnerId);
            message2.AppendString(Room.Owner);
            message2.AppendInt32(Room.State);
            message2.AppendInt32(Room.UsersNow);
            message2.AppendInt32(Room.UsersMax);
            message2.AppendString(Room.Description);
            message2.AppendInt32(0);
            message2.AppendInt32((Room.Category == 0x34) ? 2 : 0);
            message2.AppendInt32(Room.Score);
            message2.AppendInt32(0);
            message2.AppendInt32(Room.Category);
            if (Room.GetRoomGuild() == null)
            {
                message2.AppendInt32(0);
                message2.AppendInt32(0);
            }
            else
            {
                message2.AppendInt32(Guild.Id);
                message2.AppendString(Guild.Name);
                message2.AppendString(Guild.Image);
            }
            message2.AppendString("");
            message2.AppendInt32(Room.TagCount);
            foreach (string str in Room.Tags.ToArray())
            {
                message2.AppendString(str);
            }
            message2.AppendInt32(0);
            message2.AppendInt32(0);
            message2.AppendInt32(0);
            message2.AppendBoolean(true);
            message2.AppendBoolean(true);
            message2.AppendInt32(0);
            message2.AppendInt32(0);
            message2.AppendBoolean(false);
            message2.AppendBoolean(false);
            message2.AppendBoolean(false);
            message2.AppendInt32(0);
            message2.AppendInt32(0);
            message2.AppendInt32(0);
            Room.SendMessage(message2);
        }

        internal void SaveWardrobe()
        {
            uint num = this.Request.PopWiredUInt();
            string look = this.Request.PopFixedString();
            string gender = this.Request.PopFixedString();
            if (AntiMutant.ValidateLook(look, gender))
            {
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.setQuery(string.Concat(new object[] { "SELECT null FROM user_wardrobe WHERE user_id = ", this.Session.GetHabbo().Id, " AND slot_id = ", num }));
                    adapter.addParameter("look", look);
                    adapter.addParameter("gender", gender.ToUpper());
                    if (adapter.getRow() != null)
                    {
                        adapter.setQuery(string.Concat(new object[] { "UPDATE user_wardrobe SET look = @look, gender = @gender WHERE user_id = ", this.Session.GetHabbo().Id, " AND slot_id = ", num, ";" }));
                        adapter.addParameter("look", look);
                        adapter.addParameter("gender", gender.ToUpper());
                        adapter.runQuery();
                    }
                    else
                    {
                        adapter.setQuery(string.Concat(new object[] { "INSERT INTO user_wardrobe (user_id,slot_id,look,gender) VALUES (", this.Session.GetHabbo().Id, ",", num, ",@look,@gender)" }));
                        adapter.addParameter("look", look);
                        adapter.addParameter("gender", gender.ToUpper());
                        adapter.runQuery();
                    }
                }
            }
        }

        internal void SaveWired()
        {
            uint itemID = this.Request.PopWiredUInt();
            WiredSaver.HandleSave(this.Session, itemID, this.Session.GetHabbo().CurrentRoom, this.Request);
        }

        internal void SaveWiredConditions()
        {
            WiredSaver.HandleConditionSave(this.Request.PopWiredUInt(), this.Session.GetHabbo().CurrentRoom, this.Request, this.Session);
        }

        internal void SearchHabbo()
        {
            if (this.Session.GetHabbo().GetMessenger() != null)
            {
                this.Session.SendMessage(this.Session.GetHabbo().GetMessenger().PerformSearch(this.Request.PopFixedString()));
            }
        }

        internal void SearchHelpTopics()
        {
            string query = this.Request.PopFixedString();
            if (query.Length >= 3)
            {
                this.Session.SendMessage(HelpTool.SerializeSearchResults(query));
            }
        }

        public void SendAllowances()
        {
            this.GetResponse().Init(Outgoing.SendAllowances);
            this.GetResponse().AppendString("2012-11-09 19:00,hstarsa;2012-11-30 12:00,");
            this.GetResponse().AppendString("hstarsa");
            this.SendResponse();
            this.GetResponse().Init(Outgoing.SendAllowances);
            this.GetResponse().AppendString("2012-11-09 15:00,hstarsbots;2012-11-16 18:00,diarare;2012-11-19 12:00,xmasghost1;2012-11-22 20:00,xmasghost2;2012-11-22 20:45,xmasghost1;2012-11-25 21:00,xmasghost2;2012-11-25 21:45,xmasghost1;2012-11-28 22:00,xmasghost2;2012-11-28 22:45,xmasghost1;2012-11-30 14:00,");
            this.GetResponse().AppendString("xmasghost1");
            this.SendResponse();
            this.GetResponse().Init(Outgoing.SendAllowances);
            this.GetResponse().AppendString("2012-11-23 18:00,hstarssubmit2;2012-11-26 11:00,;2012-11-26 14:00,hstarsvote2;2012-11-28 11:00,");
            this.GetResponse().AppendString("hstarsvote2");
            this.SendResponse();
            this.GetResponse().Init(Outgoing.SendAllowances);
            this.GetResponse().AppendString("2012-11-09 18:00,hspeedway;2012-11-15 15:00,hstarsdiamonds;2012-11-30 12:00,");
            this.GetResponse().AppendString("hstarsdiamonds");
            this.SendResponse();
            this.GetResponse().Init(Outgoing.SendAllowances);
            this.GetResponse().AppendString("");
            this.GetResponse().AppendString("");
            this.SendResponse();
            if (!this.Session.GetHabbo().PassedQuiz)
            {
                this.GetResponse().Init(Outgoing.CitizenshipPanel);
                this.GetResponse().AppendString("citizenship");
                this.GetResponse().AppendInt32(1);
                this.GetResponse().AppendInt32(4);
                this.SendResponse();
            }
        }

        internal void SendFurniGuild()
        {
            ServerMessage message = new ServerMessage(Outgoing.SendHtmlColors);
            message.AppendInt32(this.Session.GetHabbo().ImGuilds.Count);
            foreach (int num in this.Session.GetHabbo().ImGuilds)
            {
                MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(num);
                message.AppendInt32(guild.Id);
                message.AppendString(guild.Name);
                message.AppendString(guild.Image);
                message.AppendString(guild.HtmlColor1);
                message.AppendString(guild.HtmlColor2);
                message.AppendBoolean(guild.Id == this.Session.GetHabbo().FavoriteGuild);
            }
            this.Session.SendMessage(message);
        }

        internal void SendInstantInvite()
        {
            int num = this.Request.PopWiredInt32();
            List<uint> list = new List<uint>();
            for (int i = 0; i < num; i++)
            {
                list.Add(this.Request.PopWiredUInt());
            }
            string s = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString(), true);
            ServerMessage message = new ServerMessage(Outgoing.InstantInvite);
            message.AppendInt32(this.Session.GetHabbo().Id);
            message.AppendString(s);
            foreach (uint num3 in list)
            {
                if (this.Session.GetHabbo().GetMessenger().FriendshipExists(num3))
                {
                    GameClient clientByUserID = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num3);
                    if (clientByUserID == null)
                    {
                        break;
                    }
                    clientByUserID.SendMessage(message);
                }
            }
        }

        internal void SendInstantMessenger()
        {
            if (!ButterflyEnvironment.SystemMute)
            {
                uint toId = this.Request.PopWiredUInt();
                string message = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                if (this.Session.GetHabbo().GetMessenger() != null)
                {
                    this.Session.GetHabbo().GetMessenger().SendInstantMessage(toId, message);
                }
            }
        }

        public void SendRequestGuild()
        {
            int guildId = this.Request.PopWiredInt32();
            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId);
                if (data != null)
                {
                    IQueryAdapter adapter;
                    ServerMessage message4;
                    if (guild.Type == 0)
                    {
                        if (!this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            guild.Members.Add((int)this.Session.GetHabbo().Id);
                            if (this.Session.GetHabbo().FavoriteGuild == 0)
                            {
                                this.Session.GetHabbo().FavoriteGuild = guild.Id;
                                if (this.Session.GetHabbo().CurrentRoomId > 0)
                                {
                                    Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom((uint)guild.RoomId);
                                    if (data == null)
                                    {
                                        return;
                                    }
                                    List<RoomUser> list = new List<RoomUser>(ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).GetRoomUserManager().UserList.Values);
                                    ServerMessage message = new ServerMessage(Outgoing.SendGroup);
                                    message.AppendInt32(1);
                                    message.AppendInt32(guild.Id);
                                    message.AppendString(guild.Image);
                                    this.Session.SendMessage(message);
                                    ServerMessage message2 = new ServerMessage(Outgoing.SetRoomUser);
                                    message2.AppendInt32(1);
                                    foreach (RoomUser user in list)
                                    {
                                        if (user.HabboId == this.Session.GetHabbo().Id)
                                        {
                                            user.Serialize(message2, false);
                                        }
                                    }
                                    room.SendMessage(message2);
                                }
                            }
                            this.Session.GetHabbo().ImGuilds.Add(guild.Id);
                            guild.GuildRanks.Add((int)this.Session.GetHabbo().Id, 2);
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET FavoriteGroup = '", this.Session.GetHabbo().FavoriteGuild, "' WHERE Id = '", this.Session.GetHabbo().Id, "'" }));
                                adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_groups VALUES (NULL, '", this.Session.GetHabbo().Username, "','", this.Session.GetHabbo().Id, "','", guildId, "','", DateTime.Now.Day, " - ", DateTime.Now.Month, " -  ", DateTime.Now.Year, "', '2')" }));
                                adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO user_stream VALUES (NULL, '", this.Session.GetHabbo().Id, "','", ButterflyEnvironment.LinkConfig, guild.Image, ".gif','10','", guild.Id, "','0','')" }));
                            }
                            ServerMessage message3 = new ServerMessage(Outgoing.SendHtmlColors);
                            message3.AppendInt32(this.Session.GetHabbo().ImGuilds.Count);
                            foreach (int num2 in this.Session.GetHabbo().ImGuilds)
                            {
                                MyGuild guild2 = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(num2);
                                message3.AppendInt32(guild2.Id);
                                message3.AppendString(guild2.Name);
                                message3.AppendString(guild2.Image);
                                message3.AppendString(guild2.HtmlColor1);
                                message3.AppendString(guild2.HtmlColor2);
                                message3.AppendBoolean(guild2.Id == this.Session.GetHabbo().FavoriteGuild);
                            }
                            this.Session.SendMessage(message3);
                            message4 = new ServerMessage(Outgoing.SendAdvGroupInit);
                            message4.AppendInt32(guild.Id);
                            message4.AppendBoolean(true);
                            message4.AppendInt32(guild.Type);
                            message4.AppendString(guild.Name);
                            message4.AppendString(guild.Description);
                            message4.AppendString(guild.Image);
                            message4.AppendInt32(data.Id);
                            message4.AppendString(data.Name);
                            if (guild.Petitions.Contains((int)this.Session.GetHabbo().Id))
                            {
                                message4.AppendInt32(2);
                            }
                            else if (!this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                message4.AppendInt32(0);
                            }
                            else if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                            {
                                message4.AppendInt32(1);
                            }
                            message4.AppendInt32(guild.Members.Count);
                            message4.AppendBoolean(false);
                            message4.AppendString(guild.DateCreated);
                            message4.AppendBoolean(this.Session.GetHabbo().Id == guild.OwnerId);
                            message4.AppendBoolean(this.Session.GetHabbo().FavoriteGuild == guild.Id);
                            message4.AppendString(guild.OwnerName);
                            message4.AppendBoolean(true);
                            message4.AppendBoolean(true);
                            message4.AppendInt32(guild.Members.Contains((int)this.Session.GetHabbo().Id) ? guild.Petitions.Count : 0);
                            this.Session.SendMessage(message4);
                        }
                    }
                    else if ((guild.Type == 1) && !guild.Petitions.Contains((int)this.Session.GetHabbo().Id))
                    {
                        guild.Petitions.Add((int)this.Session.GetHabbo().Id);
                        string str = "";
                        foreach (int num3 in guild.Petitions)
                        {
                            str = str + num3 + ";";
                        }
                        if (str.Length > (this.Session.GetHabbo().Id.ToString().Length + 1))
                        {
                            str = str.Substring(0, str.Length - 1);
                        }
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            adapter.runFastQuery(string.Concat(new object[] { "UPDATE groups SET Petitions = '", str, "' WHERE Id = '", guild.Id, "'" }));
                        }
                        message4 = new ServerMessage(Outgoing.SendAdvGroupInit);
                        message4.AppendInt32(guild.Id);
                        message4.AppendBoolean(true);
                        message4.AppendInt32(guild.Type);
                        message4.AppendString(guild.Name);
                        message4.AppendString(guild.Description);
                        message4.AppendString(guild.Image);
                        message4.AppendInt32((int)data.Id);
                        message4.AppendString(data.Name);
                        if (guild.Petitions.Contains((int)this.Session.GetHabbo().Id))
                        {
                            message4.AppendInt32(2);
                        }
                        else if (!this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            message4.AppendInt32(0);
                        }
                        else if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            message4.AppendInt32(1);
                        }
                        message4.AppendInt32(guild.Members.Count);
                        message4.AppendBoolean(false);
                        message4.AppendString(guild.DateCreated);
                        message4.AppendBoolean(this.Session.GetHabbo().Id == guild.OwnerId);
                        message4.AppendBoolean(this.Session.GetHabbo().FavoriteGuild == guild.Id);
                        message4.AppendString(guild.OwnerName);
                        message4.AppendBoolean(true);
                        message4.AppendBoolean(true);
                        message4.AppendInt32(guild.Members.Contains((int)this.Session.GetHabbo().Id) ? guild.Petitions.Count : 0);
                        this.Session.SendMessage(message4);
                    }
                }
            }
        }

        internal void SendResponse()
        {
            if (((this.Response != null) && (this.Response.Id > 0)) && (this.Session.GetConnection() != null))
            {
                this.Session.GetConnection().SendData(this.Response.GetBytes());
            }
        }

        internal void SendResponseWithOwnerParam()
        {
            if (((this.Response != null) && (this.Response.Id > 0)) && (this.Session.GetConnection() != null))
            {
                this.Response.AppendBoolean(this.Session.GetHabbo().CurrentRoom.CheckRights(this.Session, true));
                this.Session.GetConnection().SendData(this.Response.GetBytes());
            }
        }

        internal void setClientVars()
        {

            string str = this.Request.PopFixedString();
            string str2 = this.Request.PopFixedString();

        }

        internal void SetHomeRoom()
        {
            uint roomId = this.Request.PopWiredUInt();
            RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId);
            if ((roomId == 0) || ((data != null)))
            {
                this.Session.GetHabbo().HomeRoom = roomId;
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET home_room = ", roomId, " WHERE id = ", this.Session.GetHabbo().Id }));
                }
                this.Response.Init(Outgoing.HomeRoom);
                this.Response.AppendInt32(roomId);
                this.Response.AppendInt32(roomId);
                this.SendResponse();
            }
        }

        internal void SetLookTransfer()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session))
            {
                uint key = this.Request.PopWiredUInt();
                string str = this.Request.PopFixedString().ToUpper();
                string figure = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                RoomItem item = room.GetRoomItemHandler().mFloorItems.GetValue(key);
                if ((str.Length <= 1) && (!(str != "M") || !(str != "F")))
                {
                    item.Figure = ButterflyEnvironment.FilterFigure(figure);
                    item.Gender = str;
                    item.ExtraData = str + ":" + figure;
                }
            }
        }

        internal void setUniqueIDToClient()
        {
            string str = this.Request.PopFixedString();
            this.Session.MachineId = str;
        }

        internal void Shout()
        {
            if (!ButterflyEnvironment.SystemMute)
            {
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                if (room != null)
                {
                    RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                    if (roomUserByHabbo != null)
                    {
                        roomUserByHabbo.Chat(this.Session, ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString()), true, this.Request.PopWiredInt32());
                    }
                }
            }
        }

        internal void Sign()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    roomUserByHabbo.Unidle();
                    int num = this.Request.PopWiredInt32();
                    roomUserByHabbo.AddStatus("sign", Convert.ToString(num));
                    roomUserByHabbo.UpdateNeeded = true;
                }
            }
        }

        internal void SSOLogin()
        {
            if (this.Session.GetHabbo() == null)
            {
                this.Session.tryLogin(this.Request.PopFixedString());
                this.Session.TimePingedReceived = DateTime.Now;
            }
            else
            {
                this.Session.SendNotif(LanguageLocale.GetValue("user.allreadylogedon"));
            }
        }

        internal void StartGame(Butterfly.HabboHotel.Games.SnowStorm.SnowStorm War)
        {
            War.AssignTeams();
            War.WarStarted = 1;
            this.GetResponse().Init(Outgoing.SetStep1);
            this.GetResponse().AppendInt32(War.WarId);
            this.GetResponse().AppendString("SnowStorm level " + War.WarLevel);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(War.WarLevel);
            this.GetResponse().AppendInt32(2);
            this.GetResponse().AppendInt32(War.MaxUsers);
            this.GetResponse().AppendString(War.WarOwner.Username);
            this.GetResponse().AppendInt32(15);
            this.GetResponse().AppendInt32(War.WarUsers.Count);
            foreach (Habbo habbo in War.WarUsers)
            {
                this.GetResponse().AppendInt32(habbo.Id);
                this.GetResponse().AppendString(habbo.Username);
                this.GetResponse().AppendString(habbo.Look);
                this.GetResponse().AppendString((habbo.Gender.ToUpper() == "M") ? "M" : "f");
                this.GetResponse().AppendInt32(habbo.SnowTeam);
                this.GetResponse().AppendInt32(habbo.SnowLevel);
                this.GetResponse().AppendInt32(habbo.SnowPoints);
                this.GetResponse().AppendInt32(ButterflyEnvironment.GetGame().GetStormWars().LevelScore[habbo.SnowLevel]);
            }
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(120);
            War.SendToStorm(this.GetResponse(), false, 0);
            this.GetResponse().Init(Outgoing.Game2EnterArenaMessageEvent);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(War.WarLevel);
            this.GetResponse().AppendInt32(2);
            this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(50);
            this.GetResponse().AppendInt32(50);
            this.GetResponse().AppendString(War.Model.SerializeHeightMap());
            this.GetResponse().AppendInt32(War.Model.SnowItems.Count);
            foreach (SnowItems items in War.Model.SnowItems)
            {
                items.SerializeItem(this.GetResponse());
            }
            War.SendToStorm(this.GetResponse(), false, 0);
            foreach (Habbo habbo in War.WarUsers)
            {
                this.GetResponse().Init(Outgoing.Game2ArenaEnteredMessageEvent);
                this.GetResponse().AppendInt32(habbo.Id);
                this.GetResponse().AppendString(habbo.Username);
                this.GetResponse().AppendString(habbo.Look);
                this.GetResponse().AppendString(habbo.Gender.ToLower());
                this.GetResponse().AppendInt32(habbo.SnowTeam);
                War.SendToStorm(this.GetResponse(), false, 0);
            }
            this.GetResponse().Init(Outgoing.Game2StageLoadMessageEvent);
            this.GetResponse().AppendInt32(0);
            War.SendToStorm(this.GetResponse(), false, 0);
            Action<object> action = delegate(object obj)
            {
                Thread.Sleep(0x1388);
                this.GetResponse().Init(Outgoing.Game2StageStillLoadingMessageEvent);
                this.GetResponse().AppendInt32(0);
                this.GetResponse().AppendInt32(0);
                War.SendToStorm(this.GetResponse(), false, 0);
                this.LoadArena(War);
            };
            new Task(action, "pingsession").Start();
        }

        internal void StartPanel()
        {
            Action<object> action2 = null;
            Butterfly.HabboHotel.Games.SnowStorm.SnowStorm War = this.CheckAGame();
            if (War == null)
            {
                War = new Butterfly.HabboHotel.Games.SnowStorm.SnowStorm(this.Session.GetHabbo());
                ServerMessage message = new ServerMessage(Outgoing.CreateWar);
                message.AppendInt32(-1);
                message.AppendString("SnowStorm level " + War.WarLevel);
                message.AppendInt32(0);
                message.AppendInt32(War.WarLevel);
                message.AppendInt32(2);
                message.AppendInt32(War.MaxUsers);
                message.AppendString(War.WarOwner.Username);
                message.AppendInt32(0x11);
                message.AppendInt32(1);
                message.AppendInt32(War.WarOwner.Id);
                message.AppendString(War.WarOwner.Username);
                message.AppendString(War.WarOwner.Look);
                message.AppendString(War.WarOwner.Gender.ToLower());
                message.AppendInt32(-1);
                message.AppendInt32(War.WarOwner.SnowLevel);
                message.AppendInt32(War.WarOwner.SnowPoints);
                message.AppendInt32(1);
                message.AppendInt32(0);
                message.AppendInt32(120);
                this.Session.SendMessage(message);
            }
            War.SendToStorm(this.AddToNewGame(War), false, 0);
            if (War.WarUsers.Count >= 1)
            {
                ServerMessage packet = new ServerMessage(Outgoing.StartCounter);
                packet.AppendInt32(15);
                War.SendToStorm(packet, false, 0);
                if (action2 == null)
                {
                    action2 = delegate(object obj)
                    {
                        Thread.Sleep(0x3a98);
                        this.StartGame(War);
                    };
                }
                Action<object> action = action2;
                new Task(action, "break").Start();
            }
        }

        public void StartQuest()
        {
            ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().ActiveQuest(this.Session, this.Request);
        }

        public void StartQuiz()
        {
            if (this.Request.PopFixedString() == "SafetyQuiz1")
            {
                this.EndQuiz();
            }
            else
            {
                ServerMessage message = new ServerMessage(Outgoing.LoadQuiz);
                message.AppendString("HabboWay1");
                message.AppendInt32(5);
                message.AppendInt32(5);
                message.AppendInt32(7);
                message.AppendInt32(0);
                message.AppendInt32(1);
                message.AppendInt32(6);
                this.Session.SendMessage(message);
            }
        }

        internal void StartTyping()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    ServerMessage message = new ServerMessage(Outgoing.TypingStatus);
                    message.AppendInt32(roomUserByHabbo.VirtualId);
                    message.AppendInt32(1);
                    room.SendMessage(message);
                }
            }
        }

        public void StopQuest()
        {
            ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().CancelQuest(this.Session);
        }

        internal void StopTrade()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                room.TryStopTrade(this.Session.GetHabbo().Id);
            }
        }

        internal void StopTyping()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    ServerMessage message = new ServerMessage(Outgoing.TypingStatus);
                    message.AppendInt32(roomUserByHabbo.VirtualId);
                    message.AppendInt32(0);
                    room.SendMessage(message);
                }
            }
        }

        internal void StreamLike()
        {
            int num = this.Request.PopWiredInt32();
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery("UPDATE user_stream SET Likes=Likes + 1 WHERE Id = '" + num + "'");
            }
        }

        internal void SubmitHelpTicket()
        {
            bool flag = false;
            if (ButterflyEnvironment.GetGame().GetModerationTool().UsersHasPendingTicket(this.Session.GetHabbo().Id))
            {
                flag = true;
            }
            if (!flag)
            {
                string message = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                int num = this.Request.PopWiredInt32();
                int category = this.Request.PopWiredInt32();
                uint reportedUser = this.Request.PopWiredUInt();
                ButterflyEnvironment.GetGame().GetModerationTool().SendNewTicket(this.Session, category, reportedUser, message);
                ServerMessage TicketSended = new ServerMessage(1855);
                TicketSended.AppendInt32(0);
                Session.SendMessage(TicketSended);
            }
        }

        internal void SwitchMoodlightStatus()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && room.CheckRights(this.Session, true)) && (room.MoodlightData != null))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(room.MoodlightData.ItemId);
                if ((item != null) && (item.GetBaseItem().InteractionType == InteractionType.dimmer))
                {
                    if (room.MoodlightData.Enabled)
                    {
                        room.MoodlightData.Disable();
                    }
                    else
                    {
                        room.MoodlightData.Enable();
                    }
                    item.ExtraData = room.MoodlightData.GenerateExtraData();
                    item.UpdateState();
                }
            }
        }

        internal void TakeAllRights()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                foreach (uint num in room.UsersWithRights)
                {
                    RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(num);
                    this.Response.Init(Outgoing.RemovePowers);
                    this.Response.AppendInt32(room.RoomId);
                    this.Response.AppendInt32(num);
                    this.SendResponse();
                    roomUserByHabbo.UpdateNeeded = true;
                }
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.runFastQuery("DELETE FROM room_rights WHERE room_id = " + room.RoomId);
                }
                room.UsersWithRights.Clear();
            }
        }

        internal void TakeBackTradeItem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                Trade userTrade = room.GetUserTrade(this.Session.GetHabbo().Id);
                UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(this.Request.PopWiredUInt());
                if ((userTrade != null) && (item != null))
                {
                    userTrade.TakeBackItem(this.Session.GetHabbo().Id, item);
                }
            }
        }

        internal void TakeItem()
        {
            int num = this.Request.PopWiredInt32();
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && (room.CheckRights(this.Session, true)) || (room.checkGroupRights(this.Session)))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                if ((item != null) && (item.GetBaseItem().InteractionType != InteractionType.postit))
                {
                    room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                    this.Session.GetHabbo().GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, true, true, item.RareId, item.Guilds_Data_String, 0);
                    this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                }
            }
        }

        internal void EjectFurni()
        {
            int num = this.Request.PopWiredInt32();
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && ((room.CheckRights(this.Session, true)) || (room.checkGroupRights(this.Session))))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                Habbo habbo = ButterflyEnvironment.getHabboForId(item.placedBy);

                if ((item != null) && (item.GetBaseItem().InteractionType != InteractionType.postit) && (item.placedBy != room.OwnerId))
                {
                    if (habbo.GetClient() == null)
                    {
                        IQueryAdapter adapter;
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            if (adapter.dbType == DatabaseType.MSSQL)
                            {
                                adapter.setQuery("DELETE FROM items_users WHERE item_id = " + item.Id);
                                adapter.setQuery(string.Concat(new object[] { "INSERT INTO items_users VALUES (", item.Id, ",", item.placedBy, ")" }));
                            }
                            else
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "REPLACE INTO items_users VALUES (", item.Id, ",", item.placedBy, ")" }));
                            }
                        }

                        room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                    }
                    else
                    {
                        room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                        room.GetRoomItemHandler().RemoveFurniture(habbo.GetClient(), item.Id);
                        habbo.GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, true, true, item.RareId, item.Guilds_Data_String, 0);
                        habbo.GetInventoryComponent().UpdateItems(false);
                    }
                }
            }
        }

        internal void TakeRights()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                StringBuilder builder = new StringBuilder();
                int num = this.Request.PopWiredInt32();
                for (int i = 0; i < num; i++)
                {
                    if (i > 0)
                    {
                        builder.Append(" OR ");
                    }
                    uint item = this.Request.PopWiredUInt();
                    room.UsersWithRights.Remove(item);
                    builder.Append(string.Concat(new object[] { "room_id = '", room.RoomId, "' AND user_id = '", item, "'" }));
                    Session.SendNotif(num.ToString() + " " + item.ToString());
                    RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(item);
                    this.Response.Init(Outgoing.RemovePowers);
                    this.Response.AppendInt32(room.RoomId);
                    this.Response.AppendInt32(item);
                    this.SendResponse();

                    ServerMessage message = new ServerMessage(Outgoing.QuitRights);
                    roomUserByHabbo.GetClient().SendMessage(message);
                    roomUserByHabbo.RemoveStatus("flatctrl 1");
                    roomUserByHabbo.AddStatus("flatctrl 0", "");
                    roomUserByHabbo.UpdateNeeded = true;
                }
                if (builder.ToString().Length > 0)
                {
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery("DELETE FROM room_rights WHERE " + builder.ToString());
                    }
                }
            }
        }

        internal void Talk()
        {
            try
            {
                if (!ButterflyEnvironment.SystemMute)
                {
                    Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                    if (room != null)
                    {
                        RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                        if (roomUserByHabbo != null)
                        {
                            roomUserByHabbo.Chat(this.Session, ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString()), false, this.Request.PopWiredInt32());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }

        internal void TalkGame()
        {
            if (((this.Session != null) || (this.Session.GetHabbo() != null)) && (this.Session.GetHabbo().SnowWar != null))
            {
                Butterfly.HabboHotel.Games.SnowStorm.SnowStorm snowWar = this.Session.GetHabbo().SnowWar;
                string s = this.Request.PopFixedString();
                this.GetResponse().Init(Outgoing.Game2GameChatFromPlayerMessageEvent);
                this.GetResponse().AppendInt32(this.Session.GetHabbo().Id);
                this.GetResponse().AppendString(s);
                snowWar.SendToStorm(this.GetResponse(), false, 0);
            }
        }

        internal void TriggerItem()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                uint pId = this.Request.PopWiredUInt();
                RoomItem item = room.GetRoomItemHandler().GetItem(pId);
                if (item != null)
                {
                    if (item.GetBaseItem().Name.ToLower().Contains("bw_lgchair") && (this.Session.GetHabbo().QuestActivate == 10))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bw_sboard") && (this.Session.GetHabbo().QuestActivate == 12))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bw_van") && (this.Session.GetHabbo().QuestActivate == 13))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("party_floor") && (this.Session.GetHabbo().QuestActivate == 14))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("party_ball") && (this.Session.GetHabbo().QuestActivate == 15))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("jukebox") && (this.Session.GetHabbo().QuestActivate == 0x10))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bb_gate_b") && (this.Session.GetHabbo().QuestActivate == 0x11))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bb_patch") && (this.Session.GetHabbo().QuestActivate == 0x12))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bb_rnd_tele") && (this.Session.GetHabbo().QuestActivate == 0x13))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("es_gate_r") && (this.Session.GetHabbo().QuestActivate == 20))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("es_score_r") && (this.Session.GetHabbo().QuestActivate == 0x15))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("es_exit") && (this.Session.GetHabbo().QuestActivate == 0x16))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("es_tagging") && (this.Session.GetHabbo().QuestActivate == 0x18))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bb_counter") && (this.Session.GetHabbo().QuestActivate == 0x1a))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("bb_score_b") && (this.Session.GetHabbo().QuestActivate == 0x1b))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("es_tile") && (this.Session.GetHabbo().QuestActivate == 0x31))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    else if (item.GetBaseItem().Name.ToLower().Contains("es_box") && (this.Session.GetHabbo().QuestActivate == 50))
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("FIND_STUFF", this.Session);
                    }
                    bool userHasRights = false;
                    if (room.CheckRights(this.Session) || (item.GetBaseItem().InteractionType == InteractionType.dice))
                    {
                        userHasRights = true;
                    }
                    string extraData = item.ExtraData;
                    int request = this.Request.PopWiredInt32();
                    item.Interactor.OnTrigger(this.Session, item, request, userHasRights);
                    item.OnTrigger(room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id));
                    if (room.GotWired() && !WiredUtillity.TypeIsWired(item.GetBaseItem().InteractionType))
                    {
                        bool flag2 = false;
                        int getX = item.GetX;
                        int getY = item.GetY;
                        Point coord = new Point(getX, getY + 1);
                        Point point2 = new Point(getX + 1, getY);
                        Point point3 = new Point(getX, getY - 1);
                        Point point4 = new Point(getX - 1, getY);
                        foreach (RoomItem item2 in room.GetGameMap().GetCoordinatedItems(coord))
                        {
                            if (WiredHandler.TypeIsWire(item2.GetBaseItem().InteractionType))
                            {
                                flag2 = true;
                            }
                        }
                        foreach (RoomItem item2 in room.GetGameMap().GetCoordinatedItems(point2))
                        {
                            if (WiredHandler.TypeIsWire(item2.GetBaseItem().InteractionType))
                            {
                                flag2 = true;
                            }
                        }
                        foreach (RoomItem item2 in room.GetGameMap().GetCoordinatedItems(point3))
                        {
                            if (WiredHandler.TypeIsWire(item2.GetBaseItem().InteractionType))
                            {
                                flag2 = true;
                            }
                        }
                        foreach (RoomItem item2 in room.GetGameMap().GetCoordinatedItems(point4))
                        {
                            if (WiredHandler.TypeIsWire(item2.GetBaseItem().InteractionType))
                            {
                                flag2 = true;
                            }
                        }
                        if (flag2)
                        {
                            room.GetWiredHandler().TriggerOnWire(item.Coordinate);
                        }
                        else
                        {
                            room.GetWiredHandler().RemoveWiredItem(item.Coordinate);
                        }
                    }
                }
            }
        }

        internal void TriggerItemDiceSpecial()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                if (item != null)
                {
                    bool userHasRights = false;
                    if (room.CheckRights(this.Session))
                    {
                        userHasRights = true;
                    }
                    item.Interactor.OnTrigger(this.Session, item, -1, userHasRights);
                    item.OnTrigger(room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id));
                }
            }
        }

        internal void UnacceptTrade()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CanTradeInRoom)
            {
                Trade userTrade = room.GetUserTrade(this.Session.GetHabbo().Id);
                if (userTrade != null)
                {
                    userTrade.Unaccept(this.Session.GetHabbo().Id);
                }
            }
        }

        internal void UnignoreUser()
        {
            if (this.Session.GetHabbo().CurrentRoom != null)
            {
                string username = this.Request.PopFixedString();
                Habbo habbo = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(username).GetHabbo();
                if ((habbo != null) && this.Session.GetHabbo().MutedUsers.Contains(habbo.Id))
                {
                    this.Session.GetHabbo().MutedUsers.Remove(habbo.Id);
                    this.Response.Init(Outgoing.UpdateIgnoreStatus);
                    this.Response.AppendInt32(3);
                    this.Response.AppendString(username);
                    this.SendResponse();
                }
            }
        }

        internal void UpdateAllMount()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && !room.IsPublic) && (room.AllowPets || room.CheckRights(this.Session, true)))
            {
                uint petId = this.Request.PopWiredUInt();
                RoomUser pet = room.GetRoomUserManager().GetPet(petId);
                if (((pet != null) && (pet.PetData != null)) && (pet.PetData.OwnerId == this.Session.GetHabbo().Id))
                {
                    IQueryAdapter adapter;
                    if (pet.PetData.CanMountAllPeople)
                    {
                        pet.PetData.CanMountAllPeople = false;
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            adapter.runFastQuery("UPDATE user_pets SET can_all = 0 WHERE id = " + pet.PetData.PetId);
                        }
                    }
                    else
                    {
                        pet.PetData.CanMountAllPeople = true;
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            adapter.runFastQuery("UPDATE user_pets SET can_all = 1 WHERE id = " + pet.PetData.PetId);
                        }
                    }
                    this.Session.SendMessage(pet.PetData.SerializeInfo());
                }
            }
        }

        internal void UpdateBadges()
        {
            IQueryAdapter adapter;
            this.Session.GetHabbo().GetBadgeComponent().ResetSlots();
            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery("UPDATE user_badges SET badge_slot = 0 WHERE user_id = " + this.Session.GetHabbo().Id);
            }
            for (int i = 0; i < 5; i++)
            {
                int num2 = this.Request.PopWiredInt32();
                string str = this.Request.PopFixedString();
                if (str.Length != 0)
                {
                    if ((!this.Session.GetHabbo().GetBadgeComponent().HasBadge(str) || (num2 < 1)) || (num2 > 5))
                    {
                        return;
                    }
                    this.Session.GetHabbo().GetBadgeComponent().GetBadge(str).Slot = num2;
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE user_badges SET badge_slot = ", num2, " WHERE badge_id = '", str, "' AND user_id = ", this.Session.GetHabbo().Id }));
                    }
                }
            }
            ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("WEAR_BADGE", this.Session);
            ServerMessage message = new ServerMessage(Outgoing.UpdateBadges);
            message.AppendInt32(this.Session.GetHabbo().Id);
            message.AppendInt32(this.Session.GetHabbo().GetBadgeComponent().EquippedCount);
            foreach (Badge badge in this.Session.GetHabbo().GetBadgeComponent().BadgeList.Values)
            {
                if (badge.Slot > 0)
                {
                    message.AppendInt32(badge.Slot);
                    message.AppendString(badge.Code);
                }
            }
            if (this.Session.GetHabbo().InRoom && (ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId) != null))
            {
                ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId).SendMessage(message);
            }
            else
            {
                this.Session.SendMessage(message);
            }
        }

        internal void UpdateMoodlight()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (((room != null) && room.CheckRights(this.Session, true)) && (room.MoodlightData != null))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(room.MoodlightData.ItemId);
                if ((item != null) && (item.GetBaseItem().InteractionType == InteractionType.dimmer))
                {
                    int preset = this.Request.PopWiredInt32();
                    int num2 = this.Request.PopWiredInt32();
                    string color = this.Request.PopFixedString();
                    int intensity = this.Request.PopWiredInt32();
                    bool bgOnly = false;
                    if (num2 >= 2)
                    {
                        bgOnly = true;
                    }
                    room.MoodlightData.Enabled = true;
                    room.MoodlightData.CurrentPreset = preset;
                    room.MoodlightData.UpdatePreset(preset, color, intensity, bgOnly);
                    item.ExtraData = room.MoodlightData.GenerateExtraData();
                    item.UpdateState();
                }
            }
        }

        public void UpdateUserFromRankGuild()
        {
            int guildId = this.Request.PopWiredInt32();
            int UserId = this.Request.PopWiredInt32();
        }

        public void UpdateUserToRankGuild()
        {
            int guildId = this.Request.PopWiredInt32();

            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                int num2 = this.Request.PopWiredInt32();

                Habbo habbo = ButterflyEnvironment.getHabboForId((uint)num2);
                if (habbo != null)
                {
                    RoomData data = ButterflyEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)guild.RoomId); guild.GuildRanks[num2] = (guild.GuildRanks[num2] == 1) ? 2 : 1;

                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.runFastQuery(string.Concat(new object[] { "UPDATE user_groups SET Rank = '", guild.GuildRanks[num2], "' WHERE UserId = '", num2, "' AND GroupId = '", guildId, "'" }));
                    }

                    try
                    {
                        ServerMessage message = new ServerMessage(Outgoing.SendHtmlColors);
                        message.AppendInt32(habbo.ImGuilds.Count);
                        foreach (int num3 in habbo.ImGuilds)
                        {
                            MyGuild guild2 = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(num3);
                            message.AppendInt32(guild2.Id);
                            message.AppendString(guild2.Name);
                            message.AppendString(guild2.Image);
                            message.AppendString(guild2.HtmlColor1);
                            message.AppendString(guild2.HtmlColor2);
                            message.AppendBoolean(guild2.Id == habbo.FavoriteGuild);
                        }

                        habbo.GetClient().SendMessage(message);
                        ServerMessage message1;

                        message1 = new ServerMessage(Outgoing.SendAdvGroupInit);
                        message1.AppendInt32(guild.Id);
                        message1.AppendBoolean(true);
                        message1.AppendInt32(guild.Type);
                        message1.AppendString(guild.Name);
                        message1.AppendString(guild.Description);
                        message1.AppendString(guild.Image);
                        message1.AppendInt32(data.Id);
                        message1.AppendString(data.Name);
                        if (guild.Petitions.Contains((int)habbo.Id))
                        {
                            message1.AppendInt32(2);
                        }
                        else if (!habbo.ImGuilds.Contains(guild.Id))
                        {
                            message1.AppendInt32(0);
                        }
                        else if (habbo.ImGuilds.Contains(guild.Id))
                        {
                            message1.AppendInt32(1);
                        }
                        message1.AppendInt32(guild.Members.Count);
                        message1.AppendBoolean(false);
                        message1.AppendString(guild.DateCreated);
                        message1.AppendBoolean(habbo.Id == guild.OwnerId);

                        if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                        {
                            if (guild.GuildRanks[(int)habbo.Id] < 2)
                                message1.AppendBoolean(true);
                            else message1.AppendBoolean(false);
                        }
                        else message1.AppendBoolean(false);
                        message1.AppendString(guild.OwnerName);
                        message1.AppendBoolean(true);
                        message1.AppendBoolean(true);
                        message1.AppendInt32(guild.Members.Contains((int)habbo.Id) ? guild.Petitions.Count : 0);
                        habbo.GetClient().SendMessage(message);
                    }
                    catch
                    {

                    }
                    LoadMembersPetitions(0, guildId, 0, "");
                }
            }
        }

        internal void ViewHelpTopic()
        {
            uint topicId = this.Request.PopWiredUInt();
            HelpTopic topic = ButterflyEnvironment.GetGame().GetHelpTool().GetTopic(topicId);
            if (topic != null)
            {
                this.Session.SendMessage(HelpTool.SerializeTopic(topic));
            }
        }

        internal void unknown()
        {

        }

        internal void volumeControl()
        {
            int num = this.Request.PopWiredInt32();
            int num1 = this.Request.PopWiredInt32();
            int num2 = this.Request.PopWiredInt32();

            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (adapter.dbType == DatabaseType.MySQL)
                {
                    adapter.runFastQuery("REPLACE INTO user_volume (userid, system_volume, furni_volume, trax_volume) VALUES (" + this.Session.GetHabbo().Id + "," + num + "," + num1 + ", " + num2 + " )");
                }

            }

        }

        internal void WalkGame()
        {
            //int num = this.Request.PopWiredInt32();
            //int num2 = this.Request.PopWiredInt32();
            //Console.WriteLine(string.Concat(new object[] { "X: ", num, " ;Y:", num2 }));


        }

        internal void Wave()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if (room != null)
            {
                RoomUser roomUserByHabbo = room.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                if (roomUserByHabbo != null)
                {
                    roomUserByHabbo.Unidle();
                    int i = this.Request.PopWiredInt32();
                    roomUserByHabbo.DanceId = 0;
                    ServerMessage message = new ServerMessage(Outgoing.Action);
                    message.AppendInt32(roomUserByHabbo.VirtualId);
                    message.AppendInt32(i);
                    room.SendMessage(message);
                    if (i == 5)
                    {
                        roomUserByHabbo.IsAsleep = true;
                        ServerMessage message2 = new ServerMessage(Outgoing.IdleStatus);
                        message2.AppendInt32(roomUserByHabbo.VirtualId);
                        message2.AppendBoolean(roomUserByHabbo.IsAsleep);
                        room.SendMessage(message2);
                    }
                    ButterflyEnvironment.GetGame().GetQuestManager().GetQuests().UpdateState("WAVE", this.Session);
                }
            }
        }

        internal void Whisper()
        {
            if (!ButterflyEnvironment.SystemMute && ((this.Session != null) && (this.Session.GetHabbo() != null)))
            {
                Room currentRoom = this.Session.GetHabbo().CurrentRoom;
                if (currentRoom != null)
                {
                    if (this.Session.GetHabbo().Muted)
                    {
                        this.Session.SendNotif(LanguageLocale.GetValue("user.ismuted"));
                    }
                    else if (!currentRoom.RoomMuted)
                    {
                        string str = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                        string pName = str.Split(new char[] { ' ' })[0];
                        string s = LanguageLocale.FilterSwearwords(str.Substring(pName.Length + 1));
                        RoomUser roomUserByHabbo = currentRoom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                        RoomUser user2 = currentRoom.GetRoomUserManager().GetRoomUserByHabbo(pName);
                        int i = this.Request.PopWiredInt32();
                        ServerMessage message = new ServerMessage();
                        message.Init(Outgoing.Whisp);
                        message.AppendInt32(roomUserByHabbo.VirtualId);
                        message.AppendString(s);
                        message.AppendInt32(0);
                        message.AppendInt32(i);
                        message.AppendInt32(0);
                        message.AppendInt32(-1);
                        if (!((roomUserByHabbo == null) || roomUserByHabbo.IsBot))
                        {
                            roomUserByHabbo.GetClient().SendMessage(message);
                        }
                        roomUserByHabbo.Unidle();
                        if ((((user2 != null) && !user2.IsBot) && (user2.userID != roomUserByHabbo.userID)) && !user2.GetClient().GetHabbo().MutedUsers.Contains(this.Session.GetHabbo().Id))
                        {
                            user2.GetClient().SendMessage(message);
                        }
                        TimeSpan span = (TimeSpan)(DateTime.Now - this.FloodTime);
                        if (span.Seconds > 4)
                        {
                            this.FloodCount = 0;
                        }
                        if (((span.Seconds < 4) && (this.FloodCount > 5)) && (this.Session.GetHabbo().Rank < 5))
                        {
                            ServerMessage message2 = new ServerMessage(Outgoing.FloodFilter);
                            message2.AppendInt32(30);
                            roomUserByHabbo.GetClient().SendMessage(message2);
                        }
                        else
                        {
                            this.FloodTime = DateTime.Now;
                            this.FloodCount++;
                            List<RoomUser> roomUserByRank = currentRoom.GetRoomUserManager().GetRoomUserByRank(4);
                            if (roomUserByRank.Count > 0)
                            {
                                message = new ServerMessage();
                                message.Init(Outgoing.Whisp);
                                message.AppendInt32(roomUserByHabbo.VirtualId);
                                message.AppendString(LanguageLocale.GetValue("moderation.whisper") + pName + ": " + s);
                                message.AppendInt32(0);
                                message.AppendInt32(i);
                                message.AppendInt32(0);
                                message.AppendInt32(-1);
                                foreach (RoomUser user3 in roomUserByRank)
                                {
                                    if (((user3 != null) && ((user3.HabboId != user2.HabboId) && (user3.HabboId != roomUserByHabbo.HabboId))) && (user3.GetClient() != null))
                                    {
                                        user3.GetClient().SendMessage(message);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Incoming.cs
Code:
using System;

namespace HabboEvents
{
    public static class Incoming
    {
        public static int CheckReleaseMessageEvent;

        public static int InitCrypto;

        public static int SecretKey;

        public static int ClientVars;

        public static int UniqueMachineID;

        public static int SSOTicket;

        public static int UserInformation;

        public static int SerializeClub;

        public static int LoadCategorys;

        public static int Pong;

        public static int Ping;

        public static int EndQuiz;

        public static int LoadUser2;

        public static int OpenHelpTool;

        public static int GetWardrobe;

        public static int SaveWardrobe;

        public static int OpenAchievements;

        public static int CatalogData1;

        public static int CatalogData2;

        public static int ExtraVipWindow;

        public static int LoadTalents;

        public static int OpenCatalog;

        public static int OpenCatalogPage;

        public static int CatalogGetRace;

        public static int CheckPetName;

        public static int PurchaseCatalogItem;

        public static int PurchaseGift;

        public static int OpenGift;

        public static int StartEffect;

        public static int EnableEffect;

        public static int RedeemVoucher;

        public static int LoadFeaturedRooms;

        public static int LoadAllRooms;

        public static int LoadMyRooms;

        public static int LoadPopularTags;

        public static int RoomsWhereMyFriends;

        public static int RoomsOfMyFriends;

        public static int MyFavs;

        public static int RecentRooms;

        public static int HighRatedRooms;

        public static int SearchRoomByName;

        public static int CanCreateRoom;

        public static int CreateRoom;

        public static int GetRoomData;

        public static int SaveRoomData;

        public static int LoadFirstRoomData;

        public static int LoadHeightMap;

        public static int UpdateAllMount;

        public static int AddUserToRoom;

        public static int AddUserToRoom2;

        public static int LookTo;

        public static int StartTrade;

        public static int SendOffer;

        public static int CancelOffer;

        public static int AcceptTrade;

        public static int UnacceptTrade;

        public static int ConfirmTrade;

        public static int CancelTrade;

        public static int Move;

        public static int Talk;

        public static int Shout;

        public static int SendRespects;

        public static int ChangeLook;

        public static int ChangeMotto;

        public static int ApplyDance;

        public static int ApplySign;

        public static int ApplyAction;

        public static int Sit;

        public static int GetFriends;

        public static int FriendRequest;

        public static int AcceptRequest;

        public static int DeclineRequest;

        public static int SendInstantMessenger;

        public static int FollowFriend;

        public static int UpdateFriendsState;

        public static int InviteFriendsToMyRoom;

        public static int SearchFriend;

        public static int DeleteFriend;

        public static int LoadProfile;

        public static int OpenInventory;

        public static int PetInventary;

        public static int PlacePet;

        public static int AnswerQuestion;

        public static int PickupPet;

        public static int RespetPet;

        public static int AddSaddleToPet;

        public static int RemoveSaddle;

        public static int MountOnPet;

        public static int PetInfo;

        public static int ApplySpace;

        public static int AddFloorItem;

        public static int MoveOrRotate;

        public static int MoveWall;

        public static int HandleItem;

        public static int HandleWallItem;

        public static int StartMoodlight;

        public static int TurnOnMoodlight;

        public static int ApplyMoodlightChanges;

        public static int AddPostIt;

        public static int OpenPostIt;

        public static int SavePostIt;

        public static int DeletePostIt;

        public static int SetHome;

        public static int RemoveRoom;

        public static int RedeemExchangeFurni;

        public static int StartTyping;

        public static int StopTyping;

        public static int GiveRights;

        public static int RemoveAllRights;

        public static int RemoveRightsFrom;

        public static int PickupItem;

        public static int SaveWiredTrigger;

        public static int SaveWiredEffect;

        public static int ToolForThisRoom;

        public static int ToolForUser;

        public static int GetRoomVisits;

        public static int UserChatlog;

        public static int SendMessageByTemplate;

        public static int ModActionKickUser;

        public static int ModActionMuteUser;

        public static int ModActionBanUser;

        public static int SendUserMessage;

        public static int CreateTicket;

        public static int PickIssue;

        public static int IssueChatlog;

        public static int CloseIssue;

        public static int ReleaseIssue;

        public static int PerformRoomAction;

        public static int OpenRoomChatlog;

        public static int GiveRoomScore;

        public static int SendRoomAlert;

        public static int KickUserOfRoom;

        public static int BanUserOfRoom;

        public static int IgnoreUser;

        public static int UnignoreUser;

        public static int AnswerDoorBell;

        public static int ReqLoadByDoorBell;

        public static int AddFavourite;

        public static int RemoveFavourite;

        public static int Whisp;

        public static int BadgesInventary;

        public static int BotsInventary;

        public static int ApplyBadge;

        public static int GetUserBadges;

        public static int GetUserTags;

        public static int GoToHotelView;

        public static int RemoveHanditem;

        public static int GiveObject;

        public static int OpenDice;

        public static int RunDice;

        public static int TrainPet;

        public static int SaveConditional;

        public static int OpenQuests;

        public static int ActiveQuests;

        public static int CancelQuests;

        public static int ActiveEndedQuest;

        public static int CheckNameChange;

        public static int SaveNameChange;

        public static int ListenPreview;

        public static int LoadInvSongs;

        public static int LoadJukeSongs;

        public static int AddNewCdToJuke;

        public static int RemoveCdToJuke;

        public static int MarketplaceCanSell;

        public static int MarketplacePostItem;

        public static int MarketplaceGetOwnOffers;

        public static int MarketplaceTakeBack;

        public static int MarketplaceClaimCredits;

        public static int MarketplaceGetOffers;

        public static int MarketplacePurchase;

        public static int OpenGuildPage;

        public static int BuyGroup;

        public static int EndConfirmBuy;

        public static int EditGuild;

        public static int EditIdentidad;

        public static int EditPlaca;

        public static int EditColores;

        public static int EditAjustes;

        public static int PopularGuilds;

        public static int ExitGuild;

        public static int SendRequestGuild;

        public static int LoadMembersPetitions;

        public static int RejectGuildMember;

        public static int AcceptMember;

        public static int UpdateUserToRankGuild;

        public static int UpdateUserFromRankGuild;

        public static int SendFurniGuild;

        public static int GetGuildFavorite;

        public static int RemoveGuildFavorite;

        public static int StartQuiz;

        public static int GetGames;

        public static int GetGame;

        public static int StartPanel;

        public static int Game2LeaveGameMessageComposer;

        public static int Game2GameChatMessageComposer;

        public static int Game2SetUserMoveTargetMessageComposer;

        public static int InitStream;

        public static int StreamLike;

        public static int CreateStream;

        public static int SearchStream;

        public static int EjectFurni;

        public static int volumeControl;

        public static int unknown;

        public static int Game2LoadStageReadyMessageComposer;

        public static int Mannequinshit;



        static Incoming()
        {
            Incoming.Mannequinshit = 2242;
            Incoming.CheckReleaseMessageEvent = 4000;
            Incoming.InitCrypto = 2996;
            Incoming.SecretKey = 840;
            Incoming.ClientVars = 3561;
            Incoming.UniqueMachineID = 3570;
            Incoming.SSOTicket = 442;
            Incoming.UserInformation = 3183;
            Incoming.SerializeClub = 2757;
            Incoming.LoadCategorys = 2570;
            Incoming.Pong = 121;
            Incoming.Ping = 67;
            Incoming.EndQuiz = 1741;
            Incoming.LoadUser2 = 858;
            Incoming.OpenHelpTool = 456;
            Incoming.GetWardrobe = 3885;
            Incoming.SaveWardrobe = 383;
            Incoming.OpenAchievements = 301;
            Incoming.CatalogData1 = 3549;
            Incoming.CatalogData2 = 1973;
            Incoming.ExtraVipWindow = 1936;
            Incoming.LoadTalents = 64;
            Incoming.OpenCatalog = 3038;
            Incoming.OpenCatalogPage = 1132;
            Incoming.CatalogGetRace = 1875;
            Incoming.CheckPetName = 467;
            Incoming.PurchaseCatalogItem = 3487;
            Incoming.PurchaseGift = 553;
            Incoming.OpenGift = 225;
            Incoming.StartEffect = 1006;
            Incoming.EnableEffect = 1423;
            Incoming.RedeemVoucher = 2265;
            Incoming.LoadFeaturedRooms = 1930;
            Incoming.LoadAllRooms = 2958;
            Incoming.LoadMyRooms = 3350;
            Incoming.LoadPopularTags = 2086;
            Incoming.RoomsWhereMyFriends = 3649;
            Incoming.RoomsOfMyFriends = 2623;
            Incoming.MyFavs = 3414;
            Incoming.RecentRooms = 557;
            Incoming.HighRatedRooms = 2390;
            Incoming.SearchRoomByName = 3891;
            Incoming.CanCreateRoom = 2115;
            Incoming.CreateRoom = 2431;
            Incoming.GetRoomData = 1677;
            Incoming.SaveRoomData = 1815;
            Incoming.LoadFirstRoomData = 1650;
            Incoming.LoadHeightMap = 562;
            Incoming.UpdateAllMount = 1148;
            Incoming.AddUserToRoom = 2346;
            Incoming.AddUserToRoom2 = 1188;
            Incoming.LookTo = 3714;
            Incoming.StartTrade = 3314;
            Incoming.SendOffer = 1909;
            Incoming.CancelOffer = 2654;
            Incoming.AcceptTrade = 3847;
            Incoming.UnacceptTrade = 1426;
            Incoming.ConfirmTrade = 3402;
            Incoming.CancelTrade = 311;
            Incoming.Move = 703;
            Incoming.Talk = 1548;
            Incoming.Shout = 1953;
            Incoming.SendRespects = 1198;
            Incoming.ChangeLook = 1332;
            Incoming.ChangeMotto = 3603;
            Incoming.ApplyDance = 1157;
            Incoming.ApplySign = 1879;
            Incoming.Sit = 3679;
            Incoming.ApplyAction = 499;
            Incoming.GetFriends = 1237;
            Incoming.FriendRequest = 2913;
            Incoming.AcceptRequest = 2665;
            Incoming.DeclineRequest = 2481;
            Incoming.SendInstantMessenger = 90;
            Incoming.FollowFriend = 2289;
            Incoming.UpdateFriendsState = 2621;
            Incoming.InviteFriendsToMyRoom = 1490;
            Incoming.SearchFriend = 1487;
            Incoming.DeleteFriend = 2594;
            Incoming.LoadProfile = 1611;
            Incoming.OpenInventory = 964;
            Incoming.PetInventary = 1831;
            Incoming.PlacePet = 2461;
            Incoming.AnswerQuestion = 1251;
            Incoming.PickupPet = 2759;
            Incoming.RespetPet = 3642;
            Incoming.AddSaddleToPet = 3937;
            Incoming.RemoveSaddle = 1984;
            Incoming.MountOnPet = 1233;
            Incoming.PetInfo = 891;
            Incoming.ApplySpace = 623;
            Incoming.AddFloorItem = 3078;
            Incoming.MoveOrRotate = 2792;
            Incoming.MoveWall = 2863;
            Incoming.HandleItem = 2417;
            Incoming.HandleWallItem = 2622;
            Incoming.StartMoodlight = 1823;
            Incoming.TurnOnMoodlight = 3249;
            Incoming.ApplyMoodlightChanges = 3338;
            Incoming.AddPostIt = 3918;
            Incoming.OpenPostIt = 1653;
            Incoming.SavePostIt = 2768;
            Incoming.DeletePostIt = 3426;
            Incoming.SetHome = 3896;
            Incoming.RemoveRoom = 3856;
            Incoming.RedeemExchangeFurni = 195;
            Incoming.StartTyping = 1123;
            Incoming.StopTyping = 3916;
            Incoming.GiveRights = 1283;
            Incoming.RemoveAllRights = 1396;
            Incoming.RemoveRightsFrom = 3638;
            Incoming.PickupItem = 2805;
            Incoming.SaveWiredTrigger = 776;
            Incoming.SaveWiredEffect = 2134;
            Incoming.ToolForThisRoom = 1847;
            Incoming.ToolForUser = 3530;
            Incoming.GetRoomVisits = 2761;
            Incoming.UserChatlog = 2101;
            Incoming.SendMessageByTemplate = 3053;
            Incoming.ModActionKickUser = 391;
            Incoming.ModActionMuteUser = 798;
            Incoming.ModActionBanUser = 1038;
            Incoming.SendUserMessage = 987;
            Incoming.CreateTicket = 22;
            Incoming.PickIssue = 791;
            Incoming.IssueChatlog = 3605;
            Incoming.CloseIssue = 843;
            Incoming.ReleaseIssue = 3471;
            Incoming.PerformRoomAction = 2560;
            Incoming.OpenRoomChatlog = 2620;
            Incoming.GiveRoomScore = 1243;
            Incoming.SendRoomAlert = 2998;
            Incoming.KickUserOfRoom = 12;
            Incoming.BanUserOfRoom = 3746;
            Incoming.IgnoreUser = 1141;
            Incoming.UnignoreUser = 2377;
            Incoming.AnswerDoorBell = 2116;
            Incoming.ReqLoadByDoorBell = 356;
            Incoming.AddFavourite = 2634;
            Incoming.RemoveFavourite = 249;
            Incoming.Whisp = 2512;
            Incoming.BadgesInventary = 3313;
            Incoming.BotsInventary = 2680;
            Incoming.ApplyBadge = 1451;
            Incoming.GetUserBadges = 2756;
            Incoming.GetUserTags = 3030;
            Incoming.GoToHotelView = 2718;
            Incoming.RemoveHanditem = 1124;
            Incoming.GiveObject = 2755;
            Incoming.OpenDice = 1374;
            Incoming.RunDice = 409;
            Incoming.TrainPet = 2127;
            Incoming.SaveConditional = 2287;
            Incoming.OpenQuests = 657;
            Incoming.ActiveQuests = 2689;
            Incoming.CancelQuests = 3462;
            Incoming.ActiveEndedQuest = 3145;
            Incoming.CheckNameChange = 256;
            Incoming.SaveNameChange = 3930;
            Incoming.ListenPreview = 2112;
            Incoming.LoadInvSongs = 3718;
            Incoming.LoadJukeSongs = 3862;
            Incoming.AddNewCdToJuke = 1153;
            Incoming.RemoveCdToJuke = 1178;
            Incoming.MarketplaceCanSell = 1942;
            Incoming.MarketplacePostItem = 2491;
            Incoming.MarketplaceGetOwnOffers = 2726;
            Incoming.MarketplaceTakeBack = 3620;
            Incoming.MarketplaceClaimCredits = 1088;
            Incoming.MarketplaceGetOffers = 1289;
            Incoming.MarketplacePurchase = 3693;
            Incoming.OpenGuildPage = 2005;
            Incoming.BuyGroup = 1258;
            Incoming.EndConfirmBuy = 1787;
            Incoming.EditGuild = 2205;
            Incoming.EditIdentidad = 3122;
            Incoming.EditPlaca = 609;
            Incoming.EditColores = 2427;
            Incoming.EditAjustes = 2537;
            Incoming.PopularGuilds = 3152;
            Incoming.ExitGuild = 597;
            Incoming.SendRequestGuild = 3671;
            Incoming.LoadMembersPetitions = 1923;
            Incoming.RejectGuildMember = 257;
            Incoming.AcceptMember = 2959;
            Incoming.UpdateUserToRankGuild = 3069;
            Incoming.UpdateUserFromRankGuild = 3259;
            Incoming.SendFurniGuild = 607;
            Incoming.GetGuildFavorite = 3523;
            Incoming.RemoveGuildFavorite = 2394;
            Incoming.StartQuiz = 2510;
            Incoming.GetGames = 2498;
            Incoming.GetGame = 39;
            
            Incoming.StartPanel = 1508;

            Incoming.Game2LeaveGameMessageComposer = 42;
            Incoming.Game2GameChatMessageComposer = 1462;
            Incoming.Game2SetUserMoveTargetMessageComposer = 1630;
            Incoming.Game2LoadStageReadyMessageComposer = 270;

            Incoming.InitStream = 2626;
            Incoming.StreamLike = 1816;
            Incoming.CreateStream = 1919;
            Incoming.SearchStream = 1430;
            Incoming.EjectFurni = 650;

            Incoming.volumeControl = 1297;
            Incoming.unknown = 3870;
        }
    }
}

InteractionType.cs
Code:
namespace Butterfly.HabboHotel.Items
{
    using System;

    internal enum InteractionType
    {
        none,
        gate,
        gld_gate,
        gld_wall,
        mannequin,
        postit,
        roomeffect,
        dimmer,
        trophy,
        bed,
        scoreboard,
        vendingmachine,
        alert,
        onewaygate,
        loveshuffler,
        habbowheel,
        dice,
        bottle,
        teleport,
        rentals,
        pet,
        pool,
        roller,
        fbgate,
        pet0,
        pet1,
        pet2,
        pet3,
        pet4,
        pet5,
        pet6,
        pet7,
        pet8,
        pet9,
        pet10,
        pet11,
        pet12,
        pet13,
        pet14,
        pet15,
        pet16,
        pet17,
        pet18,
        pet19,
        pet20,
        pet21,
        pet22,
        iceskates,
        normslaskates,
        lowpool,
        haloweenpool,
        football,
        footballgoalgreen,
        footballgoalyellow,
        footballgoalblue,
        footballgoalred,
        footballcountergreen,
        footballcounteryellow,
        footballcounterblue,
        footballcounterred,
        banzaigateblue,
        banzaigatered,
        banzaigateyellow,
        banzaigategreen,
        banzaifloor,
        banzaiscoreblue,
        banzaiscorered,
        banzaiscoreyellow,
        banzaiscoregreen,
        banzaicounter,
        banzaitele,
        banzaipuck,
        banzaipyramid,
        freezetimer,
        freezeexit,
        freezeredcounter,
        freezebluecounter,
        freezeyellowcounter,
        freezegreencounter,
        freezeyellowgate,
        freezeredgate,
        freezegreengate,
        freezebluegate,
        freezetileblock,
        freezetile,
        jukebox,
        musicdisc,
        puzzlebox,
        obstacle_h,
        triggertimer,
        triggerroomenter,
        triggergameend,
        triggergamestart,
        triggerrepeater,
        triggeronusersay,
        triggerscoreachieved,
        triggerstatechanged,
        triggerwalkonfurni,
        triggerwalkofffurni,
        actiongivescore,
        actionposreset,
        actionmoverotate,
        actionresettimer,
        actionshowmessage,
        actionteleportto,
        actiontogglestate,
        conditionfurnishaveusers,
        conditionstatepos,
        conditiontimelessthan,
        conditiontimemorethan,
        conditiontriggeronfurni,
        arrowplate,
        preassureplate,
        ringplate,
        colortile,
        colorwheel,
        floorswitch1,
        floorswitch2,
        firegate,
        glassfoor,
        specialrandom,
        specialunseen,
        wire,
        wireCenter,
        wireCorner,
        wireSplitter,
        wireStandard,
        gift
    }
}

InventoryComponent.cs
Code:
namespace Butterfly.HabboHotel.Users.Inventory
{
    using Butterfly;
    using Butterfly.Collections;
    using Butterfly.Core;
    using Butterfly.HabboHotel.Catalogs;
    using Butterfly.HabboHotel.GameClients;
    using Butterfly.HabboHotel.Items;
    using Butterfly.HabboHotel.Pets;
    using Butterfly.HabboHotel.Users.UserDataManagement;
    using Butterfly.Messages;
    using Database_Manager.Database;
    using Database_Manager.Database.Session_Details.Interfaces;
    using HabboEvents;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Runtime.InteropServices;

    internal class InventoryComponent
    {
        private Hashtable discs;
        private Hashtable floorItems;
        private SafeDictionary<uint, Pet> InventoryPets;
        private bool isUpdated;
        private Hashtable mAddedItems;
        private GameClient mClient;
        private ArrayList mRemovedItems;
        private bool userAttatched = false;
        internal uint UserId;
        private Hashtable wallItems;

        internal InventoryComponent(uint UserId, GameClient Client, UserData UserData)
        {
            this.mClient = Client;
            this.UserId = UserId;
            this.floorItems = new Hashtable();
            this.wallItems = new Hashtable();
            this.discs = new Hashtable();
            foreach (UserItem item in UserData.inventory)
            {
                if (item.GetBaseItem().InteractionType == InteractionType.musicdisc)
                {
                    this.discs.Add(item.Id, item);
                }
                if (item.isWallItem)
                {
                    this.wallItems.Add(item.Id, item);
                }
                else
                {
                    this.floorItems.Add(item.Id, item);
                }
            }
            this.InventoryPets = new SafeDictionary<uint, Pet>(UserData.pets);
            this.mAddedItems = new Hashtable();
            this.mRemovedItems = new ArrayList();
            this.isUpdated = false;
        }

        internal void AddItem(RoomItem item)
        {
            this.AddNewItem(item.Id, item.BaseItem, item.ExtraData, true, true, item.RareId, item.Guilds_Data_String, 0);
        }

        internal void AddItemArray(List<RoomItem> RoomItemList)
        {
            foreach (RoomItem item in RoomItemList)
            {
                this.AddItem(item);
            }
        }

        internal UserItem AddNewItem(uint Id, uint BaseItem, string ExtraData, bool insert, bool fromRoom, uint RareId, string GroupString, uint songID = 0)
        {
            this.isUpdated = false;
            if (insert)
            {
                IQueryAdapter adapter;
                if (fromRoom)
                {
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        if (adapter.dbType == DatabaseType.MSSQL)
                        {
                            adapter.setQuery("DELETE FROM items_users WHERE item_id = " + Id);
                            adapter.setQuery(string.Concat(new object[] { "INSERT INTO items_users VALUES (", Id, ",", this.UserId, ")" }));
                        }
                        else
                        {
                            adapter.runFastQuery(string.Concat(new object[] { "REPLACE INTO items_users VALUES (", Id, ",", this.UserId, ")" }));
                        }
                    }
                    Item item = ButterflyEnvironment.GetGame().GetItemManager().GetItem(BaseItem);
                    if ((item != null) && (item.InteractionType == InteractionType.musicdisc))
                    {
                        using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            adapter.runFastQuery("DELETE FROM room_items_songs WHERE item_id = " + Id);
                        }
                    }
                }
                else
                {
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        if (adapter.dbType == DatabaseType.MSSQL)
                        {
                            adapter.setQuery(string.Concat(new object[] { "INSERT INTO items (base_id, rareid, group_data, placedBy) OUTPUT INSERTED.* VALUES (", BaseItem, ",", RareId, ",'", GroupString, "',",(int)this.UserId,")" }));
                        }
                        else
                        {
                            adapter.setQuery(string.Concat(new object[] { "INSERT INTO items (base_id, rareid, group_data, placedBy) VALUES (", BaseItem, ",", RareId, ",'", GroupString, "',", (int)this.UserId,")" }));
                        }
                        Id = (uint) adapter.insertQuery();
                        if (!string.IsNullOrEmpty(ExtraData))
                        {
                            adapter.setQuery("INSERT INTO items_extradata VALUES (" + Id + ",@extradata)");
                            adapter.addParameter("extradata", ExtraData);
                            adapter.runQuery();
                        }
                        adapter.runFastQuery(string.Concat(new object[] { "INSERT INTO items_users VALUES (", Id, ",", this.UserId, ")" }));
                    }
                }
            }
            UserItem item2 = new UserItem(Id, BaseItem, ExtraData, RareId, GroupString, (uint)this.UserId);
            if (this.UserHoldsItem(Id))
            {
                this.RemoveItem(Id, false);
            }
            if (item2.GetBaseItem().InteractionType == InteractionType.musicdisc)
            {
                this.discs.Add(item2.Id, item2);
            }
            if (item2.isWallItem)
            {
                this.wallItems.Add(item2.Id, item2);
            }
            else
            {
                this.floorItems.Add(item2.Id, item2);
            }
            if (this.mRemovedItems.Contains(Id))
            {
                this.mRemovedItems.Remove(Id);
            }
            if (!this.mAddedItems.ContainsKey(Id))
            {
                this.mAddedItems.Add(Id, item2);
            }
            return item2;
        }

        internal void AddPet(Pet Pet)
        {
            this.isUpdated = false;
            if ((Pet != null) && !this.InventoryPets.ContainsKey(Pet.PetId))
            {
                Pet.PlacedInRoom = false;
                Pet.RoomId = 0;
                this.InventoryPets.Add(Pet.PetId, Pet);

                this.SerializePetInventory();

                
            }
        }

        internal void ClearItems()
        {
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery("DELETE FROM items_users WHERE user_id = " + this.UserId);
            }
            this.mAddedItems.Clear();
            this.mRemovedItems.Clear();
            this.floorItems.Clear();
            this.wallItems.Clear();
            this.discs.Clear();
            this.InventoryPets.Clear();
            this.isUpdated = true;
            this.mClient.GetMessageHandler().GetResponse().Init(Outgoing.UpdateInventary);
            this.GetClient().GetMessageHandler().SendResponse();
        }

        private GameClient GetClient()
        {
            return ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId);
        }

        internal UserItem GetItem(uint Id)
        {
            this.isUpdated = false;
            if (this.floorItems.ContainsKey(Id))
            {
                return (UserItem) this.floorItems[Id];
            }
            if (this.wallItems.ContainsKey(Id))
            {
                return (UserItem) this.wallItems[Id];
            }
            return null;
        }

        internal Pet GetPet(uint Id)
        {
            if (this.InventoryPets.ContainsKey(Id))
            {
                return this.InventoryPets[Id];
            }
            return null;
        }

        internal List<Pet> GetPets()
        {
            List<Pet> list = new List<Pet>();
            foreach (Pet pet in this.InventoryPets.Values)
            {
                list.Add(pet);
            }
            return list;
        }

        internal void LoadInventory()
        {
            DataTable table;
            IQueryAdapter adapter;
            DataTable table2;
            
            this.floorItems.Clear();
            this.wallItems.Clear();
            this.discs.Clear();
            this.InventoryPets.Clear();

            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (adapter.dbType == DatabaseType.MySQL)
                {
                    adapter.setQuery("CALL getuseritems(@userid)");
                }
                else
                {
                    adapter.setQuery("EXECUTE getuseritems @userid");
                }
                adapter.addParameter("userid", (int) this.UserId);
                table = adapter.getTable();
            }
            foreach (DataRow row in table.Rows)
            {
                string str;
                uint id = Convert.ToUInt32(row[0]);
                uint baseItem = Convert.ToUInt32(row[1]);
                if (!DBNull.Value.Equals(row[2]))
                {
                    str = (string) row[2];
                }
                else
                {
                    str = string.Empty;
                }
                uint rareid = Convert.ToUInt32(row[3]);
                string groupstring = (string) row[4];
                UserItem item = new UserItem(id, baseItem, str, rareid, groupstring, (uint)this.UserId);
                if (item.GetBaseItem().InteractionType == InteractionType.musicdisc)
                {
                    this.discs.Add(id, item);
                }
                if (item.isWallItem)
                {
                    this.wallItems.Add(id, item);
                }
                else
                {
                    this.floorItems.Add(id, item);
                }
            }
            
            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT * FROM user_pets WHERE user_id = " + this.UserId + " AND room_id = 0");
                table2 = adapter.getTable();
            }
            if (table2 != null)
            {
                foreach (DataRow row in table2.Rows)
                {
                    Pet pet = Catalog.GeneratePetFromRow(row);
                    this.InventoryPets.Add(pet.PetId, pet);
                }
            }
        }

        internal void MovePetToRoom(uint PetId)
        {
            this.isUpdated = false;
            this.RemovePet(PetId);
        }

        internal void RemoveItem(uint Id, bool PlacedInroom)
        {
            this.isUpdated = false;
            this.GetClient().GetMessageHandler().GetResponse().Init(Outgoing.RemoveObjectFromInventory);
            this.GetClient().GetMessageHandler().GetResponse().AppendInt32(Id);
            this.GetClient().GetMessageHandler().SendResponse();
            if (this.mAddedItems.ContainsKey(Id))
            {
                this.mAddedItems.Remove(Id);
            }
            if (!this.mRemovedItems.Contains(Id))
            {
                this.discs.Remove(Id);
                this.floorItems.Remove(Id);
                this.wallItems.Remove(Id);
                this.mRemovedItems.Add(Id);
            }
        }

        internal bool RemovePet(uint PetId)
        {
            this.isUpdated = false;
            ServerMessage message = new ServerMessage(0x25c);
            message.AppendInt32(PetId);
            this.GetClient().SendMessage(message);
            this.InventoryPets.Remove(PetId);
            return true;
        }

        internal void RunCycleUpdate()
        {
            this.isUpdated = true;
            this.RunDBUpdate();
        }

        internal void RunDBUpdate()
        {
            try
            {
                if (((this.mRemovedItems.Count > 0) || (this.mAddedItems.Count > 0)) || (this.InventoryPets.Count > 0))
                {
                    using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        if (this.mAddedItems.Count > 0)
                        {
                            foreach (UserItem item in this.mAddedItems.Values)
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "UPDATE items_users SET user_id = ", this.UserId, " WHERE item_id = ", item.Id }));
                            }
                            this.mAddedItems.Clear();
                        }
                        if (this.mRemovedItems.Count > 0)
                        {
                            foreach (uint num in this.mRemovedItems.ToArray())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "DELETE FROM items_users WHERE item_id=", num, " AND user_id=", this.UserId }));
                            }
                            this.mRemovedItems.Clear();
                        }
                        foreach (Pet pet in this.InventoryPets.Values)
                        {
                            if (pet.DBState == DatabaseUpdateState.NeedsUpdate)
                            {
                                adapter.runFastQuery(string.Concat(new object[] { 
                                    "UPDATE user_pets SET room_id = ", pet.RoomId, ", name = @name, race = @race, color = @color, type = ", pet.Type, ", expirience = ", pet.Expirience, ", energy = ", pet.Energy, ", nutrition = ", pet.Nutrition, 
                                    ", respect = ", pet.Respect, ", createstamp = '", pet.CreationStamp, "', x = ", pet.X, ", Y = ", pet.Y, ", Z = ", pet.Z, " WHERE id = ", pet.PetId
                                 }));
                                adapter.addParameter("name", pet.Name);
                                adapter.addParameter("race", pet.Race);
                                adapter.addParameter("color", pet.Color);
                                
                            }
                            pet.DBState = DatabaseUpdateState.Updated;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Logging.LogCacheError("FATAL ERROR DURING USER INVENTORY DB UPDATE: " + exception.ToString());
            }
        }

        internal void SendFloorInventoryUpdate()
        {
            this.mClient.SendMessage(this.SerializeFloorItemInventory());
        }

        internal ServerMessage SerializeFloorItemInventory()
        {
            ServerMessage message = new ServerMessage(Outgoing.Inventory);
            message.AppendString("S");
            message.AppendInt32(1);
            message.AppendInt32(1);
            message.AppendInt32((int) (this.floorItems.Count + this.discs.Count));
            foreach (UserItem item in this.floorItems.Values)
            {
                item.SerializeFloor(message, true);
            }
            foreach (UserItem item in this.discs.Values)
            {
                item.SerializeFloor(message, true);
            }
            return message;
        }

        internal ServerMessage SerializeMusicDiscs()
        {
            ServerMessage message = new ServerMessage(0x14d);
            message.AppendInt32(this.discs.Count);
            foreach (UserItem item in this.discs.Values)
            {
                uint result = 0;
                uint.TryParse(item.ExtraData, out result);
                message.AppendInt32(item.Id);
                message.AppendInt32(result);
            }
            return message;
        }

        internal ServerMessage SerializePetInventory()
        {
            ServerMessage message = new ServerMessage(Outgoing.PetInventory);
            message.AppendInt32(1);
            message.AppendInt32(1);
            message.AppendInt32(this.InventoryPets.Count);


            foreach (Pet pet in this.InventoryPets.Values)
            {
                pet.SerializeInventory(message);
            }
            
            return message;
        }

        internal ServerMessage SerializeWallItemInventory()
        {
            ServerMessage message = new ServerMessage(Outgoing.Inventory);
            message.AppendString("I");
            message.AppendInt32(1);
            message.AppendInt32(1);
            message.AppendInt32(this.wallItems.Count);
            foreach (UserItem item in this.wallItems.Values)
            {
                item.SerializeWall(message, true);
            }
            return message;
        }

        internal void SetActiveState(GameClient client)
        {
            this.mClient = client;
            this.userAttatched = true;
        }

        internal void SetIdleState()
        {
            this.userAttatched = false;
            this.mClient = null;
        }

        internal void UpdateItems(bool FromDatabase)
        {
            if (FromDatabase)
            {
                this.RunDBUpdate();
                this.LoadInventory();
            }
            if (((this.mClient != null) && (this.mClient.GetMessageHandler() != null)) && (this.mClient.GetMessageHandler().GetResponse() != null))
            {
                this.mClient.GetMessageHandler().GetResponse().Init(Outgoing.UpdateInventary);
                this.mClient.GetMessageHandler().SendResponse();
            }
        }

        private bool UserHoldsItem(uint itemID)
        {
            return (this.discs.ContainsKey(itemID) || (this.floorItems.ContainsKey(itemID) || this.wallItems.ContainsKey(itemID)));
        }

        public bool isInactive
        {
            get
            {
                return !this.userAttatched;
            }
        }

        internal bool NeedsUpdate
        {
            get
            {
                return (!this.userAttatched && !this.isUpdated);
            }
        }

        internal Hashtable songDisks
        {
            get
            {
                return this.discs;
            }
        }
    }
}

OutGoing.cs
Code:
using System;

namespace HabboEvents
{
    public static class Outgoing
    {
        public static int SendBannerMessageComposer;

        public static int SecretKeyComposer;

        public static int Ping;

        public static int AuthenticationOK;

        public static int HomeRoom;

        public static int FavouriteRooms;

        public static int FavsUpdate;

        public static int Fuserights;

        public static int bools1;

        public static int EndTalentPractise;

        public static int SendAllowances;

        public static int CitizenshipPanel;

        public static int LoadQuiz;

        public static int CheckQuiz;

        public static int ActivityPoints;

        public static int CreditsBalance;

        public static int UniqueID;

        public static int HabboInfomation;

        public static int ProfileInformation;

        public static int Allowances;

        public static int AchievementPoints;

        public static int SerializePublicRooms;

        public static int NavigatorPacket;

        public static int OpenShop;

        public static int OpenShopPage;

        public static int ShopData1;

        public static int ShopData2;

        public static int Offer;

        public static int PetRace;

        public static int CheckPetName;

        public static int UpdateShop;

        public static int AchievementList;

        public static int AchievementProgress;

        public static int UnlockAchievement;

        public static int OpenModTools;

        public static int SendNotif;

        public static int ModResponse;

        public static int BroadcastMessage;

        public static int SerializeMontura;

        public static int GiftError;

        public static int UpdateInventary;

        public static int SerializePurchaseInformation;

        public static int SendPurchaseAlert;

        public static int PublicCategories;

        public static int EffectsInventary;

        public static int AddEffectToInventary;

        public static int EnableEffect;

        public static int StopEffect;

        public static int OpenHelpTool;

        public static int CanCreateRoom;

        public static int OnCreateRoomInfo;

        public static int RoomDataEdit;

        public static int UpdateRoomOne;

        public static int RoomAds;

        public static int PrepareRoomForUsers;

        public static int RoomErrorToEnter;

        public static int OutOfRoom;

        public static int RoomError;

        public static int DoorBellNoPerson;

        public static int Doorbell;

        public static int ValidDoorBell;

        public static int InitFriends;

        public static int InitRequests;

        public static int SendFriendRequest;

        public static int FriendUpdate;

        public static int InstantChat;

        public static int InstantInvite;

        public static int InstantChatError;

        public static int InitialRoomInformation;

        public static int FollowBuddy;

        public static int FollowBuddyError;

        public static int SearchFriend;

        public static int TradeStart;

        public static int TradeUpdate;

        public static int TradeAcceptUpdate;

        public static int TradeComplete;

        public static int TradeCloseClean;

        public static int TradeClose;

        public static int RoomDecoration;

        public static int RoomRightsLevel;

        public static int QuitRights;

        public static int HasOwnerRights;

        public static int RateRoom;

        public static int ScoreMeter;

        public static int CanCreateEvent;

        public static int RoomEvent;

        public static int HeightMap;

        public static int RelativeMap;

        public static int OpenGift;

        public static int SerializeFloorItems;

        public static int SerializeWallItems;

        public static int FloodFilter;

        public static int SetRoomUser;

        public static int ConfigureWallandFloor;

        public static int ValidRoom;

        public static int RoomData;

        public static int UpdateState;

        public static int SerializeClub;

        public static int ClubComposer;

        public static int PopularTags;

        public static int FlatCats;

        public static int Talk;

        public static int Shout;

        public static int Whisp;

        public static int UpdateIgnoreStatus;

        public static int GiveRespect;

        public static int PrepareCampaing;

        public static int SendCampaingData;

        public static int UpdateUserInformation;

        public static int Dance;

        public static int Action;

        public static int IdleStatus;

        public static int Inventory;

        public static int PetInventory;

        public static int PlaceBot;

        public static int PetInformation;

        public static int RespectPet;

        public static int AddExperience;

        public static int BadgesInventory;

        public static int UpdateBadges;

        public static int GetUserBadges;

        public static int GetUserTags;

        public static int GivePowers;

        public static int RemovePowers;

        public static int GetPowerList;

        public static int TypingStatus;

        public static int RemoveObjectFromInventory;

        public static int AddFloorItemToRoom;

        public static int AddWallItemToRoom;

        public static int UpdateItemOnRoom;

        public static int UpdateWallItemOnRoom;

        public static int UpdateFloorItemExtraData;

        public static int PickUpFloorItem;

        public static int PickUpWallItem;

        public static int WiredTrigger;

        public static int WiredEffect;

        public static int WiredCondition;

        public static int SaveWired;

        public static int UserLeftRoom;

        public static int RoomTool;

        public static int UserTool;

        public static int RoomChatlog;

        public static int UserChatlog;

        public static int RoomVisits;

        public static int IssueChatlog;

        public static int SerializeIssue;

        public static int UpdateIssue;

        public static int ApplyEffects;

        public static int ApplyCarryItem;

        public static int ObjectOnRoller;

        public static int DimmerData;

        public static int OpenPostIt;

        public static int UpdateFreezeLives;

        public static int WardrobeData;

        public static int HelpRequest;

        public static int SerializeCompetitionWinners;

        public static int InitStream;

        public static int SetCommandsView;

        public static int PetTrainPanel;

        public static int LoadQuests;

        public static int ActivateQuest;

        public static int QuitAlertQ;

        public static int CompleteQuests;

        public static int GetName;

        public static int CheckName;

        public static int ChangePublicName;

        public static int UpdateRoom;

        public static int CanSell;

        public static int AddMarket;

        public static int MySells;

        public static int QuitMarket;

        public static int GetOffers;

        public static int BuyItemMarket;

        public static int AddMarket2;

        public static int ListenPreviewSong;

        public static int SerializeInvSongs;

        public static int SerializeJukeSongs;

        public static int PlayStopMusic;

        public static int SendGuildParts;

        public static int SendGuildElements;

        public static int SendHtmlColors;

        public static int SendRoomAndGroup;

        public static int SendAdvGroupInit;

        public static int SendGestionGroup;

        public static int SendMembersAndPetitions;

        public static int AddNewMember;

        public static int UpdatePetitionsGuild;

        public static int SendGroup;

        public static int RemoveGuildFavorite;

        public static int GetRankInGame;

        public static int CreateWar;

        public static int AddToNewGame;

        public static int LeaveGame;

        public static int StartCounter;

        public static int SetStep1;

        public static int Game2EnterArenaMessageEvent;

        public static int Game2ArenaEnteredMessageEvent;

        public static int Game2StageStillLoadingMessageEvent;

        public static int Game2StageLoadMessageEvent;

        public static int Game2StageStartingMessageEvent;

        public static int Game2GameChatFromPlayerMessageEvent;

        public static int Game2StageRunningMessageEvent;

        public static int Game2PlayerExitedGameArenaMessageEvent;

        public static int Game2GameStatusMessageEvent;

        static Outgoing()
        {
            Outgoing.SendBannerMessageComposer = 3500;
            Outgoing.SecretKeyComposer = 659;
            Outgoing.Ping = 1080;
            Outgoing.AuthenticationOK = 1065;
            Outgoing.HomeRoom = 1994;
            Outgoing.FavouriteRooms = 2429;
            Outgoing.FavsUpdate = 3068;
            Outgoing.Fuserights = 978;
            Outgoing.bools1 = 1060;
            Outgoing.EndTalentPractise = 840;
            Outgoing.SendAllowances = 1064;
            Outgoing.CitizenshipPanel = 3244;
            Outgoing.LoadQuiz = 1652;
            Outgoing.CheckQuiz = 68;
            Outgoing.ActivityPoints = 2542;
            Outgoing.CreditsBalance = 2995;
            Outgoing.UniqueID = 1130;
            Outgoing.HabboInfomation = 2228;
            Outgoing.ProfileInformation = 2776;
            Outgoing.Allowances = 519;
            Outgoing.AchievementPoints = 1614;
            Outgoing.SerializePublicRooms = 3700;
            Outgoing.NavigatorPacket = 2160;
            Outgoing.OpenShop = 2563;
            Outgoing.OpenShopPage = 2826;
            Outgoing.ShopData1 = 1242;
            Outgoing.ShopData2 = 2889;
            Outgoing.Offer = 2437;
            Outgoing.PetRace = 1721;
            Outgoing.CheckPetName = 3771;
            Outgoing.UpdateShop = 1956;
            Outgoing.AchievementList = 1576;
            Outgoing.AchievementProgress = 1888;
            Outgoing.UnlockAchievement = 1173;
            Outgoing.OpenModTools = 2659;
            Outgoing.SendNotif = 3192;
            Outgoing.ModResponse = 904;
            Outgoing.BroadcastMessage = 2491;
            Outgoing.SerializeMontura = 3397;
            Outgoing.GiftError = 2612;
            Outgoing.UpdateInventary = 3586;
            Outgoing.SerializePurchaseInformation = 1128;
            Outgoing.SendPurchaseAlert = 1642;
            Outgoing.PublicCategories = 3700;
            Outgoing.EffectsInventary = 2938;
            Outgoing.AddEffectToInventary = 1722;
            Outgoing.EnableEffect = 1569;
            Outgoing.StopEffect = 3650;
            Outgoing.OpenHelpTool = 1500;
            Outgoing.CanCreateRoom = 3859;
            Outgoing.OnCreateRoomInfo = 290;
            Outgoing.RoomDataEdit = 3975;
            Outgoing.UpdateRoomOne = 1926;
            Outgoing.RoomAds = 1475;
            Outgoing.PrepareRoomForUsers = 3798;
            Outgoing.RoomErrorToEnter = 2945;
            Outgoing.OutOfRoom = 567;
            Outgoing.RoomError = 2120;
            Outgoing.DoorBellNoPerson = 3941;
            Outgoing.Doorbell = 265;
            Outgoing.ValidDoorBell = 3374;
            Outgoing.InitFriends = 398;
            Outgoing.InitRequests = 1671;
            Outgoing.SendFriendRequest = 3858;
            Outgoing.FriendUpdate = 1141;
            Outgoing.InstantChat = 399;
            Outgoing.InstantInvite = 2073;
            Outgoing.InstantChatError = 412;
            Outgoing.InitialRoomInformation = 999;
            Outgoing.FollowBuddy = 944;
            Outgoing.FollowBuddyError = 1109;
            Outgoing.SearchFriend = 812;
            Outgoing.TradeStart = 2567;
            Outgoing.TradeUpdate = 1685;
            Outgoing.TradeAcceptUpdate = 1168;
            Outgoing.TradeComplete = 59;
            Outgoing.TradeCloseClean = 303;
            Outgoing.TradeClose = 433;
            Outgoing.RoomDecoration = 3663;
            Outgoing.RoomRightsLevel = 1496;
            Outgoing.QuitRights = 1519;
            Outgoing.HasOwnerRights = 213;
            Outgoing.RateRoom = 3401;
            Outgoing.ScoreMeter = 3401;
            Outgoing.CanCreateEvent = 2099;
            Outgoing.RoomEvent = 743;
            Outgoing.HeightMap = 9;
            Outgoing.RelativeMap = 2483;
            Outgoing.OpenGift = 1208;
            Outgoing.SerializeFloorItems = 3580;
            Outgoing.SerializeWallItems = 3096;
            Outgoing.FloodFilter = 1641;
            Outgoing.SetRoomUser = 2204;
            Outgoing.ConfigureWallandFloor = 939;
            Outgoing.ValidRoom = 1084;
            Outgoing.RoomData = 3116;
            Outgoing.UpdateState = 493;
            Outgoing.SerializeClub = 2974;
            Outgoing.ClubComposer = 3935;
            Outgoing.PopularTags = 1574;
            Outgoing.FlatCats = 1154;
            Outgoing.Talk = 2119;
            Outgoing.Shout = 3165;
            Outgoing.Whisp = 701;
            Outgoing.UpdateIgnoreStatus = 2600;
            Outgoing.GiveRespect = 2283;
            Outgoing.PrepareCampaing = 3745;
            Outgoing.SendCampaingData = 1064;
            Outgoing.UpdateUserInformation = 421;
            Outgoing.Dance = 3301;
            Outgoing.Action = 523;
            Outgoing.IdleStatus = 746;
            Outgoing.Inventory = 177;
            Outgoing.PetInventory = 3678;
            Outgoing.PlaceBot = 2204;
            Outgoing.PetInformation = 3529;
            Outgoing.RespectPet = 1773;
            Outgoing.AddExperience = 994;
            Outgoing.BadgesInventory = 3148;
            Outgoing.UpdateBadges = 178;
            Outgoing.GetUserBadges = 178;
            Outgoing.GetUserTags = 2884;
            Outgoing.GivePowers = 3945;
            Outgoing.RemovePowers = 3889;
            Outgoing.GetPowerList = 703;
            Outgoing.TypingStatus = 851;
            Outgoing.RemoveObjectFromInventory = 606;
            Outgoing.AddFloorItemToRoom = 1243;
            Outgoing.AddWallItemToRoom = 165;
            Outgoing.UpdateItemOnRoom = 2565;
            Outgoing.UpdateWallItemOnRoom = 783;
            Outgoing.UpdateFloorItemExtraData = 3124;
            Outgoing.PickUpFloorItem = 2113;
            Outgoing.PickUpWallItem = 2208;
            Outgoing.WiredTrigger = 3393;
            Outgoing.WiredEffect = 2189;
            Outgoing.WiredCondition = 2423;
            Outgoing.SaveWired = 2466;
            Outgoing.UserLeftRoom = 3770;
            Outgoing.RoomTool = 1180;
            Outgoing.UserTool = 1231;
            Outgoing.RoomChatlog = 3800;
            Outgoing.UserChatlog = 2287;
            Outgoing.RoomVisits = 1470;
            Outgoing.IssueChatlog = 1999;
            Outgoing.SerializeIssue = 1775;
            Outgoing.UpdateIssue = 226;
            Outgoing.ApplyEffects = 329;
            Outgoing.ApplyCarryItem = 1773;
            Outgoing.ObjectOnRoller = 1508;
            Outgoing.DimmerData = 2078;
            Outgoing.OpenPostIt = 2768;
            Outgoing.UpdateFreezeLives = 2845;
            Outgoing.WardrobeData = 3443;
            Outgoing.HelpRequest = 1314;
            Outgoing.SerializeCompetitionWinners = 827;
            Outgoing.InitStream = 2143;
            Outgoing.SetCommandsView = 2307;
            Outgoing.PetTrainPanel = 971;
            Outgoing.LoadQuests = 3361;
            Outgoing.ActivateQuest = 1881;
            Outgoing.QuitAlertQ = 435;
            Outgoing.CompleteQuests = 1638;
            Outgoing.GetName = 588;
            Outgoing.CheckName = 3839;
            Outgoing.ChangePublicName = 355;
            Outgoing.UpdateRoom = 3530;
            Outgoing.CanSell = 645;
            Outgoing.AddMarket = 1468;
            Outgoing.MySells = 1900;
            Outgoing.QuitMarket = 1178;
            Outgoing.GetOffers = 1294;
            Outgoing.BuyItemMarket = 2182;
            Outgoing.AddMarket2 = 3586;
            Outgoing.ListenPreviewSong = 976;
            Outgoing.SerializeInvSongs = 3173;
            Outgoing.SerializeJukeSongs = 3318;
            Outgoing.PlayStopMusic = 1528;
            Outgoing.SendGuildParts = 862;
            Outgoing.SendGuildElements = 873;
            Outgoing.SendHtmlColors = 3640;
            Outgoing.SendRoomAndGroup = 1093;
            Outgoing.SendAdvGroupInit = 3463;
            Outgoing.SendGestionGroup = 3352;
            Outgoing.SendMembersAndPetitions = 1491;
            Outgoing.AddNewMember = 255;
            Outgoing.UpdatePetitionsGuild = 3649;
            Outgoing.SendGroup = 1696;
            Outgoing.RemoveGuildFavorite = 1928;
            Outgoing.GetRankInGame = 1414;
            Outgoing.CreateWar = 2737;
            Outgoing.AddToNewGame = 2200;
            Outgoing.LeaveGame = 3543;
            Outgoing.StartCounter = 2155;
            Outgoing.SetStep1 = 3828;
            Outgoing.Game2EnterArenaMessageEvent = 811;
            Outgoing.Game2ArenaEnteredMessageEvent = 2312;
            Outgoing.Game2StageStillLoadingMessageEvent = 1048;
            Outgoing.Game2StageLoadMessageEvent = 1125;
            Outgoing.Game2StageStartingMessageEvent = 2942;
            Outgoing.Game2GameChatFromPlayerMessageEvent = 483;
            Outgoing.Game2StageRunningMessageEvent = 2975;
            Outgoing.Game2PlayerExitedGameArenaMessageEvent = 2050;
            Outgoing.Game2GameStatusMessageEvent = 275;

        }
    }
}

Roomitem.cs
Code:
namespace Butterfly.HabboHotel.Items
{
    using Butterfly;
    using Butterfly.Core;
    using Butterfly.HabboHotel.Catalogs;
    using Butterfly.HabboHotel.Habbo.Guilds;
    using Butterfly.HabboHotel.Habbo.Users;
    using Butterfly.HabboHotel.Items.Interactors;
    using Butterfly.HabboHotel.Pathfinding;
    using Butterfly.HabboHotel.Rooms;
    using Butterfly.HabboHotel.Rooms.Games;
    using Butterfly.HabboHotel.Rooms.Wired.WiredHandlers.Interfaces;
    using Butterfly.Messages;
    using Database_Manager.Database.Session_Details.Interfaces;
    using HabboEvents;
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Threading;
    

    public class RoomItem : IEquatable<RoomItem>
    {
        internal uint BaseItem;
        internal string ExtraData;
        internal string Figure;
        internal FreezePowerUp freezePowerUp;
        internal string Gender;
        internal List<string> Guilds_Data;
        internal uint placedBy;
        internal string Guilds_Data_String;
        internal uint Id;
        internal uint interactingBallUser;
        internal uint InteractingUser;
        internal uint InteractingUser2;
        public byte interactionCount;
        internal byte interactionCountHelper;
        internal bool IsTrans;
        private Dictionary<int, ThreeDCoord> mAffectedPoints;
        internal bool MagicRemove;
        private Item mBaseItem;
        private bool mIsFloorItem;
        private bool mIsRoller;
        private bool mIsWallItem;
        private Room mRoom;
        private int mX;
        private int mY;
        private double mZ;
        internal string originalExtraData;
        internal bool pendingReset;
        private Point placedPosition;
        internal uint RareId;
        internal uint RoomId;
        internal int Rot;
        internal Team team;
        internal int UpdateCounter;
        private bool updateNeeded;
        internal int value;
        internal WallCoordinate wallCoord;
        internal IWiredCondition wiredCondition;
        internal IWiredTrigger wiredHandler;

        internal event OnItemTrigger itemTriggerEventHandler;

        internal event UserWalksFurniDelegate OnUserWalksOffFurni;

        internal event UserWalksFurniDelegate OnUserWalksOnFurni;

        internal RoomItem(uint Id, uint RoomId, uint BaseItem, string ExtraData, WallCoordinate wallCoord, Room pRoom, string Guilds_data_string, uint rareid, uint placedBy)
        {
            this.placedBy = placedBy;
            this.Guilds_Data = new List<string>();
            this.pendingReset = false;
            this.MagicRemove = false;
            this.Id = Id;
            this.RoomId = RoomId;
            this.BaseItem = BaseItem;
            this.ExtraData = ExtraData;
            this.originalExtraData = ExtraData;
            this.mX = 0;
            this.mY = 0;
            this.mZ = 0.0;
            this.UpdateNeeded = false;
            this.UpdateCounter = 0;
            this.InteractingUser = 0;
            this.InteractingUser2 = 0;
            this.IsTrans = false;
            this.RareId = rareid;
            this.interactingBallUser = 0;
            this.interactionCount = 0;
            this.value = 0;
            this.placedPosition = new Point(0, 0);
            this.wallCoord = wallCoord;
            this.Guilds_Data_String = Guilds_data_string;
            if (this.Guilds_Data_String.Length > 0)
            {
                try
                {
                    foreach (string str in this.Guilds_Data_String.Split(new char[] { ';' }))
                    {
                        this.Guilds_Data.Add(str);
                    }
                }
                catch
                {
                }
            }
            this.mBaseItem = ButterflyEnvironment.GetGame().GetItemManager().GetItem(BaseItem);
            this.mRoom = pRoom;
            if (this.GetBaseItem() == null)
            {
                Logging.LogException("Unknown baseID: " + BaseItem);
            }
            this.mIsWallItem = true;
            this.mIsFloorItem = false;
            this.mAffectedPoints = new Dictionary<int, ThreeDCoord>();
            
        }

        internal RoomItem(uint Id, uint RoomId, uint BaseItem, string ExtraData, int X, int Y, double Z, int Rot, Room pRoom, string Guilds_data_string, uint rareid, uint placedBy)
        {
            this.placedBy = placedBy;
            this.Guilds_Data = new List<string>();
            this.pendingReset = false;
            this.MagicRemove = false;
            this.Id = Id;
            this.RoomId = RoomId;
            this.BaseItem = BaseItem;
            this.ExtraData = ExtraData;
            this.originalExtraData = ExtraData;
            this.mX = X;
            if ((((this.GetX + 3) > pRoom.GetGameMap().StaticModel.MapSizeX) && ((Rot == 2) || (Rot == 6))) && (this.GetBaseItem().InteractionType == InteractionType.obstacle_h))
            {
                this.mX--;
            }
            this.mY = Y;
            if ((((this.GetY + 2) > pRoom.GetGameMap().StaticModel.MapSizeY) && ((Rot == 0) || (Rot == 4))) && (this.GetBaseItem().InteractionType == InteractionType.obstacle_h))
            {
                this.mY--;
            }
            if (!double.IsInfinity(Z))
            {
                this.mZ = Z;
            }
            this.Rot = Rot;
            this.UpdateNeeded = false;
            this.UpdateCounter = 0;
            this.InteractingUser = 0;
            this.InteractingUser2 = 0;
            this.RareId = rareid;
            this.IsTrans = false;
            this.interactingBallUser = 0;
            this.interactionCount = 0;
            this.value = 0;
            this.placedPosition = new Point(X, Y);
            this.Guilds_Data_String = Guilds_data_string;
            if (this.Guilds_Data_String.Length > 0)
            {
                try
                {
                    foreach (string str in this.Guilds_Data_String.Split(new char[] { ';' }))
                    {
                        this.Guilds_Data.Add(str);
                    }
                }
                catch
                {
                }
            }
            this.mBaseItem = ButterflyEnvironment.GetGame().GetItemManager().GetItem(BaseItem);
            this.mRoom = pRoom;
            if (this.GetBaseItem() == null)
            {
                Logging.LogException("Unknown baseID: " + BaseItem);
                using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    adapter.runFastQuery("DELETE FROM items WHERE item_id = '" + this.Id + "'");
                    this.Id = 0;
                }
            }
            InteractionType interactionType = this.GetBaseItem().InteractionType;
            if (interactionType != InteractionType.teleport)
            {
                switch (interactionType)
                {
                    case InteractionType.footballcountergreen:
                    case InteractionType.banzaigategreen:
                    case InteractionType.banzaiscoregreen:
                    case InteractionType.freezegreencounter:
                    case InteractionType.freezegreengate:
                        this.team = Team.green;
                        break;

                    case InteractionType.footballcounteryellow:
                    case InteractionType.banzaigateyellow:
                    case InteractionType.banzaiscoreyellow:
                    case InteractionType.freezeyellowcounter:
                    case InteractionType.freezeyellowgate:
                        this.team = Team.yellow;
                        break;

                    case InteractionType.footballcounterblue:
                    case InteractionType.banzaigateblue:
                    case InteractionType.banzaiscoreblue:
                    case InteractionType.freezebluecounter:
                    case InteractionType.freezebluegate:
                        this.team = Team.blue;
                        break;

                    case InteractionType.footballcounterred:
                    case InteractionType.banzaigatered:
                    case InteractionType.banzaiscorered:
                    case InteractionType.freezeredcounter:
                    case InteractionType.freezeredgate:
                        this.team = Team.red;
                        break;

                    case InteractionType.banzaitele:
                        this.ExtraData = "";
                        break;

                    case InteractionType.roller:
                        this.mIsRoller = true;
                        pRoom.GetRoomItemHandler().GotRollers = true;
                        break;

                    case InteractionType.gld_wall:
                        
                        break;
                }
            }
            else
            {
                this.IsTrans = true;
                this.ReqUpdate(0, true);
            }
            this.mIsWallItem = this.GetBaseItem().Type.ToString().ToLower() == "i";
            this.mIsFloorItem = this.GetBaseItem().Type.ToString().ToLower() == "s";
            this.mAffectedPoints = Gamemap.GetAffectedTiles(this.GetBaseItem().Length, this.GetBaseItem().Width, this.mX, this.mY, Rot);
            
        }

        internal void Destroy()
        {
            this.mRoom = null;
            this.mAffectedPoints.Clear();
            if (this.wiredHandler != null)
            {
                this.wiredHandler.Dispose();
            }
            this.wiredHandler = null;
            this.itemTriggerEventHandler = null;
            this.OnUserWalksOffFurni = null;
            this.OnUserWalksOnFurni = null;
        }

        public bool Equals(RoomItem comparedItem)
        {
            return (comparedItem.Id == this.Id);
        }

        internal Item GetBaseItem()
        {
            if (this.mBaseItem == null)
            {
                this.mBaseItem = ButterflyEnvironment.GetGame().GetItemManager().GetItem(this.BaseItem);
            }
            return this.mBaseItem;
        }

        internal Point GetPlacementPosition()
        {
            return this.placedPosition;
        }

        internal CatalogItem GetRareCatalogItem(int ItemId)
        {
            return ButterflyEnvironment.GetGame().GetCatalog().RaresItems[(uint) ItemId];
        }

        internal Room GetRoom()
        {
            if (this.mRoom == null)
            {
                this.mRoom = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.RoomId);
            }
            return this.mRoom;
        }

        internal void OnTrigger(RoomUser user)
        {
            if (this.itemTriggerEventHandler != null)
            {
                this.itemTriggerEventHandler(null, new ItemTriggeredArgs(user, this));
            }
        }

        internal void ProcessUpdates()
        {
            this.UpdateCounter--;
            if ((this.UpdateCounter <= 0) || this.IsTrans)
            {
                int num4;
                this.UpdateNeeded = false;
                this.UpdateCounter = 0;
                RoomUser roomUserByHabbo = null;
                RoomUser user2 = null;
                switch (this.GetBaseItem().InteractionType)
                {
                    case InteractionType.banzaicounter:
                        if (!string.IsNullOrEmpty(this.ExtraData))
                        {
                            num4 = 0;
                            try
                            {
                                num4 = int.Parse(this.ExtraData);
                            }
                            catch
                            {
                            }
                            if (num4 > 0)
                            {
                                if (this.interactionCountHelper == 1)
                                {
                                    num4--;
                                    this.interactionCountHelper = 0;
                                    if (!this.GetRoom().GetBanzai().isBanzaiActive)
                                    {
                                        break;
                                    }
                                    this.ExtraData = num4.ToString();
                                    this.UpdateState();
                                }
                                else
                                {
                                    this.interactionCountHelper = (byte) (this.interactionCountHelper + 1);
                                }
                                this.UpdateCounter = 1;
                            }
                            else
                            {
                                this.UpdateCounter = 0;
                                this.GetRoom().GetBanzai().BanzaiEnd();
                            }
                            break;
                        }
                        break;

                    case InteractionType.banzaitele:
                        this.ExtraData = string.Empty;
                        this.UpdateState();
                        break;

                    case InteractionType.banzaipuck:
                        if (this.interactionCount <= 4)
                        {
                            this.interactionCount = 0;
                            this.UpdateCounter = 0;
                            break;
                        }
                        this.interactionCount = (byte) (this.interactionCount + 1);
                        this.UpdateCounter = 1;
                        break;

                    case InteractionType.gld_wall:
                                              
                        break;
                    
                    case InteractionType.freezetimer:
                        if (!string.IsNullOrEmpty(this.ExtraData))
                        {
                            num4 = 0;
                            try
                            {
                                num4 = int.Parse(this.ExtraData);
                            }
                            catch
                            {
                            }
                            if (num4 > 0)
                            {
                                if (this.interactionCountHelper == 1)
                                {
                                    num4--;
                                    this.interactionCountHelper = 0;
                                    if (!this.GetRoom().GetFreeze().GameIsStarted)
                                    {
                                        break;
                                    }
                                    this.ExtraData = num4.ToString();
                                    this.UpdateState();
                                }
                                else
                                {
                                    this.interactionCountHelper = (byte) (this.interactionCountHelper + 1);
                                }
                                this.UpdateCounter = 1;
                            }
                            else
                            {
                                this.UpdateNeeded = false;
                                this.GetRoom().GetFreeze().StopGame();
                            }
                            break;
                        }
                        break;

                    case InteractionType.freezetile:
                        if (this.InteractingUser > 0)
                        {
                            this.ExtraData = "11000";
                            this.UpdateState(false, true);
                            this.GetRoom().GetFreeze().onFreezeTiles(this, this.freezePowerUp, this.InteractingUser);
                            this.InteractingUser = 0;
                            this.interactionCountHelper = 0;
                        }
                        break;

                    case InteractionType.scoreboard:
                        if (!string.IsNullOrEmpty(this.ExtraData))
                        {
                            num4 = 0;
                            try
                            {
                                num4 = int.Parse(this.ExtraData);
                            }
                            catch
                            {
                            }
                            if (num4 > 0)
                            {
                                if (this.interactionCountHelper == 1)
                                {
                                    num4--;
                                    this.interactionCountHelper = 0;
                                    this.ExtraData = num4.ToString();
                                    this.UpdateState();
                                }
                                else
                                {
                                    this.interactionCountHelper = (byte) (this.interactionCountHelper + 1);
                                }
                                this.UpdateCounter = 1;
                            }
                            else
                            {
                                this.UpdateCounter = 0;
                            }
                            break;
                        }
                        break;

                    case InteractionType.vendingmachine:
                        if (this.ExtraData == "1")
                        {
                            roomUserByHabbo = this.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(this.InteractingUser);
                            if (roomUserByHabbo != null)
                            {
                                roomUserByHabbo.UnlockWalking();
                                int num3 = this.GetBaseItem().VendingIds[ButterflyEnvironment.GetRandomNumber(0, this.GetBaseItem().VendingIds.Count - 1)];
                                roomUserByHabbo.CarryItem(num3);
                            }
                            this.InteractingUser = 0;
                            this.ExtraData = "0";
                            this.UpdateState(false, true);
                        }
                        break;

                    case InteractionType.alert:
                        if (this.ExtraData == "1")
                        {
                            this.ExtraData = "0";
                            this.UpdateState(false, true);
                        }
                        break;

                    case InteractionType.onewaygate:
                    case InteractionType.gld_gate:
                        roomUserByHabbo = null;
                        if (this.InteractingUser > 0)
                        {
                            roomUserByHabbo = this.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(this.InteractingUser);
                        }
                        if (((roomUserByHabbo != null) && (roomUserByHabbo.X == this.mX)) && (roomUserByHabbo.Y == this.mY))
                        {
                            this.ExtraData = "1";
                            roomUserByHabbo.MoveTo(this.SquareBehind);
                            this.ReqUpdate(1, false);
                            this.UpdateState(false, true);
                        }
                        else if ((roomUserByHabbo != null) && (roomUserByHabbo.Coordinate == this.SquareBehind))
                        {
                            roomUserByHabbo.UnlockWalking();
                            this.ExtraData = "0";
                            this.InteractingUser = 0;
                            this.UpdateState(false, true);
                        }
                        else if (this.ExtraData == "1")
                        {
                            this.ExtraData = "0";
                            this.UpdateState(false, true);
                        }
                        if (roomUserByHabbo == null)
                        {
                            this.InteractingUser = 0;
                        }
                        break;

                    case InteractionType.loveshuffler:
                        if (!(this.ExtraData == "0"))
                        {
                            if (this.ExtraData != "-1")
                            {
                                this.ExtraData = "-1";
                            }
                        }
                        else
                        {
                            this.ExtraData = ButterflyEnvironment.GetRandomNumber(1, 4).ToString();
                            this.ReqUpdate(20, false);
                        }
                        this.UpdateState(false, true);
                        return;

                    case InteractionType.habbowheel:
                        this.ExtraData = ButterflyEnvironment.GetRandomNumber(1, 10).ToString();
                        this.UpdateState();
                        break;

                    case InteractionType.dice:
                        this.ExtraData = ButterflyEnvironment.GetRandomNumber(1, 6).ToString();
                        this.UpdateState();
                        break;

                    case InteractionType.bottle:
                        this.ExtraData = ButterflyEnvironment.GetRandomNumber(0, 7).ToString();
                        this.UpdateState();
                        break;

                    case InteractionType.teleport:
                    {
                        roomUserByHabbo = null;
                        user2 = null;
                        bool flag = false;
                        bool flag2 = false;
                        if (this.InteractingUser > 0)
                        {
                            roomUserByHabbo = this.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(this.InteractingUser);
                            if (roomUserByHabbo == null)
                            {
                                this.InteractingUser = 0;
                            }
                            else if (!(roomUserByHabbo.Coordinate == this.Coordinate))
                            {
                                if (roomUserByHabbo.Coordinate == this.SquareInFront)
                                {
                                    roomUserByHabbo.AllowOverride = true;
                                    flag = true;
                                    if (roomUserByHabbo.IsWalking && ((roomUserByHabbo.GoalX != this.mX) || (roomUserByHabbo.GoalY != this.mY)))
                                    {
                                        roomUserByHabbo.ClearMovement(true);
                                    }
                                    roomUserByHabbo.CanWalk = false;
                                    roomUserByHabbo.AllowOverride = true;
                                    roomUserByHabbo.MoveTo(this.Coordinate.X, this.Coordinate.Y, true);
                                }
                                else
                                {
                                    this.InteractingUser = 0;
                                }
                            }
                            else
                            {
                                roomUserByHabbo.AllowOverride = false;
                                if (!TeleHandler.IsTeleLinked(this.Id, this.mRoom))
                                {
                                    roomUserByHabbo.UnlockWalking();
                                    this.InteractingUser = 0;
                                }
                                else
                                {
                                    flag2 = true;
                                    uint linkedTele = TeleHandler.GetLinkedTele(this.Id, this.mRoom);
                                    uint teleRoomId = TeleHandler.GetTeleRoomId(linkedTele, this.mRoom);
                                    if (teleRoomId != this.RoomId)
                                    {
                                        if (((!roomUserByHabbo.IsBot && (roomUserByHabbo != null)) && ((roomUserByHabbo.GetClient() != null) && (roomUserByHabbo.GetClient().GetHabbo() != null))) && (roomUserByHabbo.GetClient().GetMessageHandler() != null))
                                        {
                                            roomUserByHabbo.GetClient().GetHabbo().IsTeleporting = true;
                                            roomUserByHabbo.GetClient().GetHabbo().TeleportingRoomID = teleRoomId;
                                            roomUserByHabbo.GetClient().GetHabbo().TeleporterId = linkedTele;
                                            roomUserByHabbo.GetClient().GetMessageHandler().PrepareRoomForUser(teleRoomId, "");
                                        }
                                    }
                                    else
                                    {
                                        RoomItem item = this.GetRoom().GetRoomItemHandler().GetItem(linkedTele);
                                        if (item != null)
                                        {
                                            roomUserByHabbo.SetPos(item.GetX, item.GetY, item.GetZ);
                                            roomUserByHabbo.SetRot(item.Rot, false);
                                            item.ExtraData = "2";
                                            item.UpdateState(false, true);
                                            item.InteractingUser2 = this.InteractingUser;
                                        }
                                        else
                                        {
                                            roomUserByHabbo.UnlockWalking();
                                        }
                                    }
                                    this.InteractingUser = 0;
                                }
                            }
                        }
                        if (this.InteractingUser2 > 0)
                        {
                            user2 = this.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(this.InteractingUser2);
                            if (user2 != null)
                            {
                                flag = true;
                                user2.UnlockWalking();
                                user2.MoveTo(this.SquareInFront);
                            }
                            this.InteractingUser2 = 0;
                        }
                        if (flag)
                        {
                            if (this.ExtraData != "1")
                            {
                                this.ExtraData = "1";
                                this.UpdateState(false, true);
                            }
                        }
                        else if (flag2)
                        {
                            if (this.ExtraData != "2")
                            {
                                this.ExtraData = "2";
                                this.UpdateState(false, true);
                            }
                        }
                        else if (this.ExtraData != "0")
                        {
                            this.ExtraData = "0";
                            this.UpdateState(false, true);
                        }
                        this.ReqUpdate(1, false);
                        return;
                    }
                    case InteractionType.banzaifloor:
                        if (this.value != 3)
                        {
                            break;
                        }
                        if (this.interactionCountHelper == 1)
                        {
                            this.interactionCountHelper = 0;
                            switch (this.team)
                            {
                                case Team.red:
                                    this.ExtraData = "5";
                                    break;

                                case Team.green:
                                    this.ExtraData = "8";
                                    break;

                                case Team.blue:
                                    this.ExtraData = "11";
                                    break;

                                case Team.yellow:
                                    this.ExtraData = "14";
                                    break;
                            }
                        }
                        else
                        {
                            this.ExtraData = "";
                            this.interactionCountHelper = (byte) (this.interactionCountHelper + 1);
                        }
                        this.UpdateState();
                        this.interactionCount = (byte) (this.interactionCount + 1);
                        if (this.interactionCount < 0x10)
                        {
                            this.UpdateCounter = 1;
                        }
                        else
                        {
                            this.UpdateCounter = 0;
                        }
                        return;
                }
            }
        }

        internal void refreshItem()
        {
            this.mBaseItem = null;
        }

        internal void ReqUpdate(int Cycles, bool setUpdate)
        {
            this.UpdateCounter = Cycles;
            if (setUpdate)
            {
                this.UpdateNeeded = true;
            }
        }

        internal void Serialize(ServerMessage Message, int UserId)
        {
            if (this.IsFloorItem)
            {
                Message.AppendInt32(this.Id);
                Message.AppendInt32(this.GetBaseItem().SpriteId);
                Message.AppendInt32(this.mX);
                Message.AppendInt32(this.mY);
                Message.AppendInt32(this.Rot);
                Message.AppendString(string.Format("{0:0.00}", TextHandling.GetString(this.mZ)));


                if (this.GetBaseItem().Name == "boutique_mannequin1")
                {
                    Message.AppendInt32(0);
                    Message.AppendInt32(1);
                    Message.AppendInt32(3);
                    Message.AppendString("GENDER");
                    Message.AppendString("m");
                    Message.AppendString("FIGURE");
                    Message.AppendString(this.ExtraData);
                    Message.AppendString("OUTFIT_NAME");
                    Message.AppendString("");
                }

                if (this.GetBaseItem().Name == "ads_mpu_720" || this.GetBaseItem().Name == "ads_background" || this.GetBaseItem().Name == "ads_mpu_300" || this.GetBaseItem().Name == "ads_mpu_160")
                {

                    Message.AppendInt32(0);
                    Message.AppendInt32(1);
                    if (ExtraData != "")
                    {
                        Message.AppendInt32(ExtraData.Split(Convert.ToChar(9)).Length / 2);

                        for (int i = 0; i <= ExtraData.Split(Convert.ToChar(9)).Length - 1; i++)
                        {
                            Message.AppendString(ExtraData.Split(Convert.ToChar(9))[i]);
                        }
                    }
                    else
                    {
                        Message.AppendInt32(0);
                    }

                }

                else if ((this.GetBaseItem().SpriteId >= 0xd2c) && (this.GetBaseItem().SpriteId < 0xd36))
                {
                    int i = 0;
                    if (this.ExtraData.Contains(Convert.ToChar(5).ToString()))
                    {
                        int num2 = int.Parse(this.ExtraData.Split(new char[] { '\x0005' })[1]);
                        int num3 = int.Parse(this.ExtraData.Split(new char[] { '\x0005' })[2]);
                        i = (num2 * 0x3e8) + num3;
                    }
                    Message.AppendInt32(i);
                    if (this.ExtraData.Contains(Convert.ToChar(5).ToString()))
                    {
                        Habbo habbo = ButterflyEnvironment.getHabboForId((uint)int.Parse(this.ExtraData.Split(new char[] { ';' })[0]));
                        if (habbo != null)
                        {
                            Message.AppendInt32(1);
                            Message.AppendInt32(6);
                            Message.AppendString("EXTRA_PARAM");
                            Message.AppendString("");
                            Message.AppendString("MESSAGE");
                            Message.AppendString(this.ExtraData.Split(new char[] { ';' })[1].Split(new char[] { '\x0005' })[0]);
                            Message.AppendString("PURCHASER_NAME");
                            Message.AppendString(habbo.Username);
                            Message.AppendString("PURCHASER_FIGURE");
                            Message.AppendString(habbo.Look);
                            Message.AppendString("PRODUCT_CODE");
                            Message.AppendString("");
                            Message.AppendString("state");
                            Message.AppendString(this.MagicRemove ? "1" : "0");
                        }
                        else
                        {
                            Message.AppendInt32(0);
                        }
                    }
                    else
                    {
                        Message.AppendInt32(0);
                    }
                }
                else
                {
                    Message.AppendInt32(0);
                    if (this.RareId > 0)
                    {
                        Message.AppendString("");
                        Message.AppendBoolean(true);
                        Message.AppendBoolean(false);
                    }
                    else if (this.mBaseItem.AllowGroupItem)
                    {
                        MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(int.Parse(this.Guilds_Data_String.Split(new char[] { ';' })[0]));
                        if (guild == null)
                        {
                            Message.AppendInt32(0);
                        }
                        else
                        {
                            Message.AppendInt32(2);
                            Message.AppendInt32(5);
                            Message.AppendString(this.ExtraData);
                            Message.AppendString(guild.Id.ToString());
                            Message.AppendString(guild.Image);
                            Message.AppendString(this.Guilds_Data_String.Split(new char[] { ';' })[1]);
                            Message.AppendString(this.Guilds_Data_String.Split(new char[] { ';' })[2]);
                        }
                    }
                    else
                    {
                        Message.AppendInt32(0);
                    }
                    if (this.mBaseItem.InteractionType == InteractionType.trophy)
                    {
                        Message.AppendString(this.ExtraData);
                    }
                    else if (!this.mBaseItem.AllowGroupItem)
                    {
                        Message.AppendString(this.ExtraData);
                    }
                    if (this.RareId > 0)
                    {
                        Message.AppendInt32(this.RareId);
                        Message.AppendInt32(this.GetRareCatalogItem((int)this.BaseItem).LimitedStack);
                    }
                }
                Message.AppendInt32(-1);
                Message.AppendInt32(1);
                Message.AppendInt32(UserId);
                
                if (!this.mRoom.MovedThinksObH && (this.GetBaseItem().InteractionType == InteractionType.obstacle_h))
                {
                    if ((this.Rot == 2) || (this.Rot == 6))
                    {
                        this.mX = this.GetX + 1;
                    }
                    else if ((this.Rot == 0) || (this.Rot == 4))
                    {
                        this.mY = this.GetY + 1;
                    }
                }
            }
            else if (this.IsWallItem)
            {
                Message.AppendString(this.Id + string.Empty);
                Message.AppendInt32(this.GetBaseItem().SpriteId);
                Message.AppendString(this.wallCoord.ToString());
                if (this.GetBaseItem().InteractionType == InteractionType.postit)
                {
                    Message.AppendString(this.ExtraData.Split(new char[] { ' ' })[0]);
                }
                else
                {
                    Message.AppendString(this.ExtraData);
                }
                Message.AppendInt32(1);
                Message.AppendInt32(UserId);
            }
        }

        internal void SetState(int pX, int pY, double pZ, Dictionary<int, ThreeDCoord> Tiles)
        {
            this.mX = pX;
            this.mY = pY;
            if (!double.IsInfinity(pZ))
            {
                this.mZ = pZ;
            }
            this.mAffectedPoints = Tiles;
        }

        internal void UpdateState()
        {
            this.UpdateState(true, true);
        }

        internal void UpdateState(bool inDb, bool inRoom)
        {
            if (this.GetRoom() != null)
            {
                if (inDb)
                {
                    this.GetRoom().GetRoomItemHandler().UpdateItem(this);
                }
                if (inRoom)
                {
                    ServerMessage message = new ServerMessage(0);
                    
                    if (this.IsFloorItem)
                    {
                        message.Init(Outgoing.UpdateFloorItemExtraData);
                        message.AppendString(this.Id.ToString());
                        message.AppendInt32(0);
                        message.AppendString(this.ExtraData);
                    }
                    else
                    {
                        message.Init(Outgoing.UpdateWallItemOnRoom);
                        this.Serialize(message, this.GetRoom().OwnerId);
                    }
                    this.GetRoom().SendMessage(message);
                }
            }
        }

        internal void UserWalksOffFurni(RoomUser user)
        {
            if (this.OnUserWalksOffFurni != null)
            {
                this.OnUserWalksOffFurni(this, new UserWalksOnArgs(user));
            }
        }

        internal void UserWalksOnFurni(RoomUser user)
        {
            if (this.OnUserWalksOnFurni != null)
            {
                this.OnUserWalksOnFurni(this, new UserWalksOnArgs(user));
            }
        }

        internal Point Coordinate
        {
            get
            {
                return new Point(this.mX, this.mY);
            }
        }

        internal Dictionary<int, ThreeDCoord> GetAffectedTiles
        {
            get
            {
                return this.mAffectedPoints;
            }
        }

        internal List<Point> GetCoords
        {
            get
            {
                List<Point> list = new List<Point> {
                    this.Coordinate
                };
                foreach (ThreeDCoord coord in this.mAffectedPoints.Values)
                {
                    list.Add(new Point(coord.X, coord.Y));
                }
                return list;
            }
        }

        internal int GetX
        {
            get
            {
                return this.mX;
            }
        }

        internal int GetY
        {
            get
            {
                return this.mY;
            }
        }

        internal double GetZ
        {
            get
            {
                return this.mZ;
            }
        }

        internal FurniInteractor Interactor
        {
            get
            {
                switch (this.GetBaseItem().InteractionType)
                {
                    case InteractionType.gate:
                        return new InteractorGate(this.GetBaseItem().Modes);
                    
                    case InteractionType.mannequin:
                        return new InteractorMannequin();
                    
                    case InteractionType.scoreboard:
                        return new InteractorScoreboard();

                    case InteractionType.vendingmachine:
                        return new InteractorVendor();

                    case InteractionType.alert:
                        return new InteractorAlert();

                    case InteractionType.onewaygate:
                        return new InteractorOneWayGate();

                    case InteractionType.gld_gate:
                        return new InteractorOneWayGate();

                    case InteractionType.loveshuffler:
                        return new InteractorLoveShuffler();

                    case InteractionType.habbowheel:
                        return new InteractorHabboWheel();

                    case InteractionType.dice:
                        return new InteractorDice();

                    case InteractionType.bottle:
                        return new InteractorSpinningBottle();

                    case InteractionType.teleport:
                        return new InteractorTeleport();

                    case InteractionType.football:
                        return new InteractorFootball();

                    case InteractionType.footballcountergreen:
                    case InteractionType.footballcounteryellow:
                    case InteractionType.footballcounterblue:
                    case InteractionType.footballcounterred:
                        return new InteractorScoreCounter();

                    case InteractionType.banzaifloor:
                        return new InteractorNone();

                    case InteractionType.banzaiscoreblue:
                    case InteractionType.banzaiscorered:
                    case InteractionType.banzaiscoreyellow:
                    case InteractionType.banzaiscoregreen:
                        return new InteractorBanzaiScoreCounter();

                    case InteractionType.banzaicounter:
                        return new InteractorBanzaiTimer();

                    case InteractionType.banzaipuck:
                        return new InteractorBanzaiPuck();

                    case InteractionType.freezetimer:
                        return new InteractorFreezeTimer();

                    case InteractionType.freezetileblock:
                    case InteractionType.freezetile:
                        return new InteractorFreezeTile();

                    case InteractionType.jukebox:
                        return new InteractorJukebox();

                    case InteractionType.triggertimer:
                    case InteractionType.triggerroomenter:
                    case InteractionType.triggergameend:
                    case InteractionType.triggergamestart:
                    case InteractionType.triggerrepeater:
                    case InteractionType.triggeronusersay:
                    case InteractionType.triggerscoreachieved:
                    case InteractionType.triggerstatechanged:
                    case InteractionType.triggerwalkonfurni:
                    case InteractionType.triggerwalkofffurni:
                    case InteractionType.actiongivescore:
                    case InteractionType.actionposreset:
                    case InteractionType.actionmoverotate:
                    case InteractionType.actionresettimer:
                    case InteractionType.actionshowmessage:
                    case InteractionType.actionteleportto:
                    case InteractionType.actiontogglestate:
                    case InteractionType.conditionfurnishaveusers:
                    case InteractionType.conditionstatepos:
                    case InteractionType.conditiontimelessthan:
                    case InteractionType.conditiontimemorethan:
                    case InteractionType.conditiontriggeronfurni:
                        return new WiredInteractor();

                    case InteractionType.wire:
                    case InteractionType.wireCenter:
                    case InteractionType.wireCorner:
                    case InteractionType.wireSplitter:
                    case InteractionType.wireStandard:
                        return new InteractorIgnore();
                }
                return new InteractorGenericSwitch(this.GetBaseItem().Modes);
            }
        }

        internal bool IsFloorItem
        {
            get
            {
                return this.mIsFloorItem;
            }
        }

        internal bool IsRoller
        {
            get
            {
                return this.mIsRoller;
            }
        }

        internal bool IsWallItem
        {
            get
            {
                return this.mIsWallItem;
            }
        }

        internal Point SquareBehind
        {
            get
            {
                Point point = new Point(this.mX, this.mY);
                if (this.Rot == 0)
                {
                    point.Y++;
                    return point;
                }
                if (this.Rot == 2)
                {
                    point.X--;
                    return point;
                }
                if (this.Rot == 4)
                {
                    point.Y--;
                    return point;
                }
                if (this.Rot == 6)
                {
                    point.X++;
                }
                return point;
            }
        }

        internal Point SquareInFront
        {
            get
            {
                Point point = new Point(this.mX, this.mY);
                if (this.Rot == 0)
                {
                    point.Y--;
                    return point;
                }
                if (this.Rot == 2)
                {
                    point.X++;
                    return point;
                }
                if (this.Rot == 4)
                {
                    point.Y++;
                    return point;
                }
                if (this.Rot == 6)
                {
                    point.X--;
                }
                return point;
            }
        }

        internal double TotalHeight
        {
            get
            {
                return (this.mZ + this.GetBaseItem().Height);
            }
        }

        internal bool UpdateNeeded
        {
            get
            {
                return this.updateNeeded;
            }
            set
            {
                if (value)
                {
                    this.GetRoom().GetRoomItemHandler().QueueRoomItemUpdate(this);
                }
                this.updateNeeded = value;
            }
        }
    }
}

RoomItemhandeling.cs
Code:
namespace Butterfly.HabboHotel.Rooms
{
    using Butterfly;
    using Butterfly.Collections;
    using Butterfly.Core;
    using Butterfly.HabboHotel.GameClients;
    using Butterfly.HabboHotel.Items;
    using Butterfly.HabboHotel.Pathfinding;
    using Butterfly.HabboHotel.Rooms.Wired;
    using Butterfly.Messages;
    using Butterfly.Util;
    using Database_Manager.Database;
    using Database_Manager.Database.Session_Details.Interfaces;
    using HabboEvents;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    

    internal class RoomItemHandling
    {
        private Hashtable mAddedItems;
        internal QueuedDictionary<uint, RoomItem> mFloorItems;
        private bool mGotRollers;
        private Hashtable mMovedItems;
        private Hashtable mRemovedItems;
        internal QueuedDictionary<uint, RoomItem> mRollers;
        private int mRollerSpeed;
        private int mRoolerCycle;
        internal QueuedDictionary<uint, RoomItem> mWallItems;
        private List<uint> rollerItemsMoved;
        private List<ServerMessage> rollerMessages;
        private List<uint> rollerUsersMoved;
        private Room room;
        private Queue roomItemUpdateQueue;

        public RoomItemHandling(Room room)
        {
            this.room = room;
            this.mRemovedItems = new Hashtable();
            this.mMovedItems = new Hashtable();
            this.mAddedItems = new Hashtable();
            this.mRollers = new QueuedDictionary<uint, RoomItem>();
            this.mWallItems = new QueuedDictionary<uint, RoomItem>();
            this.mFloorItems = new QueuedDictionary<uint, RoomItem>();
            this.roomItemUpdateQueue = new Queue();
            this.mGotRollers = false;
            this.mRoolerCycle = 0;
            this.mRollerSpeed = 4;
            this.rollerItemsMoved = new List<uint>();
            this.rollerUsersMoved = new List<uint>();
            this.rollerMessages = new List<ServerMessage>();
        }

        internal void AddItem(RoomItem item)
        {
            if (this.mRemovedItems.ContainsKey(item.Id))
            {
                this.mRemovedItems.Remove(item.Id);
            }
            if (!(this.mMovedItems.ContainsKey(item.Id) || this.mAddedItems.ContainsKey(item.Id)))
            {
                this.mAddedItems.Add(item.Id, item);
            }
        }

        private void ClearRollers()
        {
            this.mRollers.Clear();
        }

        private List<ServerMessage> CycleRollers()
        {
            this.mRollers.OnCycle();
            if (this.mGotRollers)
            {
                if ((this.mRoolerCycle >= this.mRollerSpeed) || (this.mRollerSpeed == 0))
                {
                    this.rollerItemsMoved.Clear();
                    this.rollerUsersMoved.Clear();
                    this.rollerMessages.Clear();
                    foreach (RoomItem item in this.mRollers.Values)
                    {
                        Point squareInFront = item.SquareInFront;
                        List<RoomItem> list = this.room.GetGameMap().GetRoomItemForSquare(item.GetX, item.GetY, item.GetZ);
                        RoomUser userForSquare = this.room.GetRoomUserManager().GetUserForSquare(item.GetX, item.GetY);
                        if ((list.Count > 0) || (userForSquare != null))
                        {
                            List<RoomItem> coordinatedItems = this.room.GetGameMap().GetCoordinatedItems(squareInFront);
                            double nextZ = 0.0;
                            int num2 = 0;
                            bool flag = false;
                            double totalHeight = 0.0;
                            bool flag2 = true;
                            foreach (RoomItem item2 in coordinatedItems)
                            {
                                if (item2.IsRoller)
                                {
                                    flag = true;
                                    if (item2.TotalHeight > totalHeight)
                                    {
                                        totalHeight = item2.TotalHeight;
                                    }
                                }
                            }
                            if (flag)
                            {
                                foreach (RoomItem item2 in coordinatedItems)
                                {
                                    if (item2.TotalHeight > totalHeight)
                                    {
                                        flag2 = false;
                                    }
                                }
                            }
                            else
                            {
                                totalHeight += this.room.GetGameMap().GetHeightForSquareFromData(squareInFront);
                            }
                            nextZ = totalHeight;
                            bool flag3 = num2 > 0;
                            if (this.room.GetRoomUserManager().GetUserForSquare(squareInFront.X, squareInFront.Y) != null)
                            {
                                flag3 = true;
                            }
                            foreach (RoomItem item2 in list)
                            {
                                double num4 = item2.GetZ - item.TotalHeight;
                                if (((!this.rollerItemsMoved.Contains(item2.Id) && this.room.GetGameMap().CanRollItemHere(squareInFront.X, squareInFront.Y)) && (flag2 && (item.GetZ < item2.GetZ))) && (this.room.GetRoomUserManager().GetUserForSquare(squareInFront.X, squareInFront.Y) == null))
                                {
                                    this.rollerMessages.Add(this.UpdateItemOnRoller(item2, squareInFront, item.Id, totalHeight + num4));
                                    this.rollerItemsMoved.Add(item2.Id);
                                }
                            }
                            if ((((((userForSquare != null) && !userForSquare.IsWalking) && (flag2 && !flag3)) && this.room.GetGameMap().CanRollItemHere(squareInFront.X, squareInFront.Y)) && (this.room.GetGameMap().GetFloorStatus(squareInFront) != 0)) && !this.rollerUsersMoved.Contains(userForSquare.HabboId))
                            {
                                this.rollerMessages.Add(this.UpdateUserOnRoller(userForSquare, squareInFront, item.Id, nextZ));
                                this.rollerUsersMoved.Add(userForSquare.HabboId);
                            }
                        }
                    }
                    this.mRoolerCycle = 0;
                    return this.rollerMessages;
                }
                this.mRoolerCycle++;
            }
            return new List<ServerMessage>();
        }

        internal void Destroy()
        {
            this.mFloorItems.Clear();
            this.mWallItems.Clear();
            this.mRemovedItems.Clear();
            this.mMovedItems.Clear();
            this.mAddedItems.Clear();
            this.roomItemUpdateQueue.Clear();
            this.room = null;
            this.mFloorItems = null;
            this.mWallItems = null;
            this.mRemovedItems = null;
            this.mMovedItems = null;
            this.mAddedItems = null;
            this.mWallItems = null;
            this.roomItemUpdateQueue = null;
        }

        internal RoomItem GetFurniObject(int X, int Y)
        {
            foreach (RoomItem item in this.room.GetRoomItemHandler().mFloorItems.Values)
            {
                if ((item.GetX == X) && (item.GetY == Y))
                {
                    return item;
                }
            }
            return null;
        }

        internal List<RoomItem> GetFurniObjects(int X, int Y)
        {
            return this.room.GetGameMap().GetCoordinatedItems(new Point(X, Y));
        }

        internal RoomItem GetItem(uint pId)
        {
            if (this.mFloorItems.ContainsKey(pId))
            {
                return this.mFloorItems.GetValue(pId);
            }
            if (this.mWallItems.ContainsKey(pId))
            {
                return this.mWallItems.GetValue(pId);
            }
            return null;
        }

        internal void LoadFurniture()
        {
            this.mFloorItems.Clear();
            this.mWallItems.Clear();
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (adapter.dbType == DatabaseType.MySQL)
                {
                    adapter.setQuery("CALL getroomitems(@roomid)");
                    adapter.addParameter("roomid", this.room.RoomId);
                }
                else
                {
                    adapter.setQuery("EXECUTE getroomitems " + this.room.RoomId);
                }
                DataTable table = adapter.getTable();
                foreach (DataRow row in table.Rows)
                {
                    string str;
                    RoomItem item;
                    uint id = Convert.ToUInt32(row[0]);
                    decimal num2 = Convert.ToDecimal(row[1]);
                    decimal num3 = Convert.ToDecimal(row[2]);
                    sbyte n = Convert.ToSByte(row[3]);
                    uint baseItem = Convert.ToUInt32(row[4]);
                    if (DBNull.Value.Equals(row[5]))
                    {
                        str = string.Empty;
                    }
                    else
                    {
                        str = (string) row[5];
                        
                    }
                    uint placedBy = Convert.ToUInt32(row[8]);
                    uint rareid = Convert.ToUInt32(row[6]);
                    string str2 = (string) row[7];
                    
                    if (n > 6)
                    {
                        WallCoordinate wallCoord = new WallCoordinate((double) num2, (double) num3, n);
                        item = new RoomItem(id, this.room.RoomId, baseItem, str, wallCoord, this.room, str2, rareid, placedBy);
                        if (!this.mWallItems.ContainsKey(id))
                        {
                            this.mWallItems.Inner.Add(id, item);
                        }
                    }
                    else
                    {
                        int num7;
                        int num8;
                        TextHandling.Split((double) num2, out num7, out num8);
                        item = new RoomItem(id, this.room.RoomId, baseItem, str, num7, num8, (double) num3, n, this.room, str2, rareid, placedBy);
                        if ((item.Id != 0) && !this.mFloorItems.ContainsKey(id))
                        {
                            this.mFloorItems.Inner.Add(id, item);
                        }
                    }
                }
                foreach (RoomItem item2 in this.mFloorItems.Values)
                {
                    if (item2.IsRoller)
                    {
                        this.mGotRollers = true;
                    }
                    else if (item2.GetBaseItem().InteractionType == InteractionType.dimmer)
                    {
                        if (this.room.MoodlightData == null)
                        {
                            this.room.MoodlightData = new MoodlightData(item2.Id);
                        }
                    }
                    else if (WiredUtillity.TypeIsWired(item2.GetBaseItem().InteractionType))
                    {
                        WiredLoader.LoadWiredItem(item2, this.room, adapter);
                        this.room.GetWiredHandler().AddWire(item2, item2.Coordinate, item2.Rot, item2.GetBaseItem().InteractionType);
                    }
                }

                
            }
        }

        internal void OnCycle()
        {
            if (this.mGotRollers)
            {
                try
                {
                    this.room.SendMessage(this.CycleRollers());
                }
                catch (Exception exception)
                {
                    Logging.LogThreadException(exception.ToString(), "rollers for room with ID " + this.room.RoomId);
                    this.mGotRollers = false;
                }
            }
            if (this.roomItemUpdateQueue.Count > 0)
            {
                List<RoomItem> list = new List<RoomItem>();
                lock (this.roomItemUpdateQueue.SyncRoot)
                {
                    while (this.roomItemUpdateQueue.Count > 0)
                    {
                        RoomItem item = (RoomItem) this.roomItemUpdateQueue.Dequeue();
                        item.ProcessUpdates();
                        if (item.IsTrans || (item.UpdateCounter > 0))
                        {
                            list.Add(item);
                        }
                    }
                    foreach (RoomItem item in list)
                    {
                        this.roomItemUpdateQueue.Enqueue(item);
                    }
                }
            }

            this.mFloorItems.OnCycle();
            this.mWallItems.OnCycle();
        }

        internal void QueueRoomItemUpdate(RoomItem item)
        {
            lock (this.roomItemUpdateQueue.SyncRoot)
            {
                this.roomItemUpdateQueue.Enqueue(item);
            }
        }

        internal List<RoomItem> RemoveAllFurniture(GameClient Session)
        {
            ServerMessage message;

            List<RoomItem> list = new List<RoomItem>();

            foreach (RoomItem item in this.mFloorItems.Values.ToArray<RoomItem>())
            {
                item.Interactor.OnRemove(Session, item);
                message = new ServerMessage(Outgoing.PickUpFloorItem);
                message.AppendString(item.Id + string.Empty);
                message.AppendInt32(0);
                message.AppendInt32(this.room.OwnerId);
                this.room.SendMessage(message);
                list.Add(item);                
            }

            foreach (RoomItem item in this.mWallItems.Values.ToArray<RoomItem>())
            {
                item.Interactor.OnRemove(Session, item);
                message = new ServerMessage(Outgoing.PickUpWallItem);
                message.AppendString(item.Id + string.Empty);
                message.AppendInt32(this.room.OwnerId);
                this.room.SendMessage(message);
                list.Add(item);
            }
            
            this.mWallItems.Clear();
            this.mFloorItems.Clear();
            this.mRemovedItems.Clear();
            this.mMovedItems.Clear();
            this.mAddedItems.Clear();            

            this.mRollers.QueueDelegate(new onCycleDoneDelegate(this.ClearRollers));
            
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.runFastQuery("DELETE FROM items_rooms WHERE room_id = " + this.room.RoomId);
            }
            
            this.room.GetGameMap().GenerateMaps(true);
            this.room.GetRoomUserManager().UpdateUserStatusses();
            
            if (this.room.GotWired())
            {
                this.room.GetWiredHandler().OnPickall();
            }
            
            return list;
        }

        internal void RemoveFurniture(GameClient Session, uint pId)
        {
            RoomItem item = this.GetItem(pId);
            if (item != null)
            {
                IQueryAdapter adapter;
                
                if (item.GetBaseItem().InteractionType == InteractionType.fbgate)
                {
                    this.room.GetSoccer().UnRegisterGate(item);
                }
                
                if (item.GetBaseItem().InteractionType != InteractionType.gift)
                {
                    item.Interactor.OnRemove(Session, item);
                }
                
                this.RemoveRoomItem(item);
                
                if (item.wiredHandler != null)
                {
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        item.wiredHandler.DeleteFromDatabase(adapter);
                        item.wiredHandler.Dispose();
                        this.room.GetWiredHandler().RemoveFurniture(item);
                    }
                    item.wiredHandler = null;
                }
                
                if (item.wiredCondition != null)
                {
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        item.wiredCondition.DeleteFromDatabase(adapter);
                        item.wiredCondition.Dispose();
                        this.room.GetWiredHandler().conditionHandler.ClearTile(item.Coordinate);
                    }
                    item.wiredCondition = null;
                }
            }
        }

        internal void RemoveItem(RoomItem item)
        {
            if (this.mAddedItems.ContainsKey(item.Id))
            {
                this.mAddedItems.Remove(item.Id);
            }
            if (this.mMovedItems.ContainsKey(item.Id))
            {
                this.mMovedItems.Remove(item.Id);
            }
            if (!this.mRemovedItems.ContainsKey(item.Id))
            {
                this.mRemovedItems.Add(item.Id, item);
            }
            this.mRollers.Remove(item.Id);
        }

        private void RemoveRoomItem(RoomItem Item)
        {
            ServerMessage message;
            if (Item.IsWallItem)
            {
                message = new ServerMessage(Outgoing.PickUpWallItem);
                message.AppendString(Item.Id + string.Empty);
                message.AppendInt32(Item.placedBy);
                this.room.SendMessage(message);
            }

            else if (Item.IsFloorItem)
            {
                message = new ServerMessage(Outgoing.PickUpFloorItem);
                message.AppendString(Item.Id + string.Empty);
                message.AppendInt32(0);
                message.AppendInt32(Item.placedBy);
                this.room.SendMessage(message);
            }

            if (Item.IsWallItem)
            {
                this.mWallItems.Remove(Item.Id);
            }

            else
            {
                this.mFloorItems.Remove(Item.Id);
                this.mFloorItems.OnCycle();
                this.room.GetGameMap().RemoveFromMap(Item);
            }

            this.RemoveItem(Item);
            this.room.GetRoomUserManager().UpdateUserStatusses();
            
            if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType))
            {
                this.room.GetWiredHandler().RemoveWiredItem(Item.Coordinate);
            }
        }

        internal void SaveFurniture(IQueryAdapter dbClient)
        {
            if (dbClient.dbType == DatabaseType.MSSQL)
            {
                this.SaveFurnitureToMSSQL(dbClient);
            }
            else
            {
                try
                {
                    if ((((this.mAddedItems.Count > 0) || (this.mRemovedItems.Count > 0)) || (this.mMovedItems.Count > 0)) || (this.room.GetRoomUserManager().PetCount > 0))
                    {
                        double num;
                        QueryChunk chunk = new QueryChunk();
                        QueryChunk chunk2 = new QueryChunk("REPLACE INTO items_rooms (item_id,room_id,x,y,n) VALUES ");
                        QueryChunk chunk3 = new QueryChunk("REPLACE INTO items_extradata (item_id,data) VALUES ");
                        foreach (RoomItem item in this.mRemovedItems.Values)
                        {
                            chunk.AddQuery(string.Concat(new object[] { "DELETE FROM items_rooms WHERE item_id = ", item.Id, " AND room_id = ", this.room.RoomId }));
                        }
                        if (this.mAddedItems.Count > 0)
                        {
                            foreach (RoomItem item in this.mAddedItems.Values)
                            {
                                if (!string.IsNullOrEmpty(item.ExtraData))
                                {
                                    chunk3.AddQuery(string.Concat(new object[] { "(", item.Id, ",@data_id", item.Id, ")" }));
                                    chunk3.AddParameter("@data_id" + item.Id, item.ExtraData);
                                }
                                if (item.IsFloorItem)
                                {
                                    num = TextHandling.Combine(item.GetX, item.GetY);
                                    chunk2.AddQuery(string.Concat(new object[] { "(", item.Id, ",", item.RoomId, ",", TextHandling.GetString(num), ",", TextHandling.GetString(item.GetZ), ",", item.Rot, ")" }));
                                }
                                else
                                {
                                    chunk2.AddQuery(string.Concat(new object[] { "(", item.Id, ",", item.RoomId, ",", TextHandling.GetString(item.wallCoord.GetXValue()), ",", TextHandling.GetString(item.wallCoord.GetYValue()), ",", item.wallCoord.n(), ")" }));
                                }
                            }
                        }
                        foreach (RoomItem item in this.mMovedItems.Values)
                        {
                            if (!string.IsNullOrEmpty(item.ExtraData))
                            {
                                chunk.AddQuery(string.Concat(new object[] { "UPDATE items_extradata SET data = @data", item.Id, " WHERE item_id = ", item.Id }));
                                chunk.AddParameter("data" + item.Id, item.ExtraData);
                            }
                            if (item.IsWallItem)
                            {
                                chunk.AddQuery(string.Concat(new object[] { "UPDATE items_rooms SET x=", TextHandling.GetString(item.wallCoord.GetXValue()), ", y=", TextHandling.GetString(item.wallCoord.GetYValue()), ", n=", item.wallCoord.n(), " WHERE item_id = ", item.Id }));
                            }
                            else
                            {
                                num = TextHandling.Combine(item.GetX, item.GetY);
                                chunk.AddQuery(string.Concat(new object[] { "UPDATE items_rooms SET x=", TextHandling.GetString(num), ", y=", TextHandling.GetString(item.GetZ), ", n=", item.Rot, " WHERE item_id = ", item.Id }));
                            }
                        }
                        this.room.GetRoomUserManager().AppendPetsUpdateString(dbClient);
                        this.mAddedItems.Clear();
                        this.mRemovedItems.Clear();
                        this.mMovedItems.Clear();
                        chunk.Execute(dbClient);
                        chunk2.Execute(dbClient);
                        chunk3.Execute(dbClient);
                        chunk.Dispose();
                        chunk2.Dispose();
                        chunk3.Dispose();
                        chunk = null;
                        chunk2 = null;
                        chunk3 = null;
                    }
                }
                catch (Exception exception)
                {
                    Logging.LogCriticalException(string.Concat(new object[] { "Error during saving furniture for room ", this.room.RoomId, ". Stack: ", exception.ToString() }));
                }
            }
        }

        internal void SaveFurnitureToMSSQL(IQueryAdapter dbClient)
        {
            try
            {
                if ((((this.mAddedItems.Count > 0) || (this.mRemovedItems.Count > 0)) || (this.mMovedItems.Count > 0)) || (this.room.GetRoomUserManager().PetCount > 0))
                {
                    double num;
                    QueryChunk chunk = new QueryChunk();
                    QueryChunk chunk2 = new QueryChunk();
                    QueryChunk chunk3 = new QueryChunk();
                    foreach (RoomItem item in this.mRemovedItems.Values)
                    {
                        chunk.AddQuery(string.Concat(new object[] { "DELETE FROM items_rooms WHERE item_id = ", item.Id, " AND room_id = ", this.room.RoomId }));
                    }
                    if (this.mAddedItems.Count > 0)
                    {
                        foreach (RoomItem item in this.mAddedItems.Values)
                        {
                            if (!string.IsNullOrEmpty(item.ExtraData))
                            {
                                chunk3.AddQuery("DELETE FROM items_extradata WHERE item_id = " + item.Id);
                                chunk3.AddQuery(string.Concat(new object[] { "INSERT INTO items_extradata (item_id,data) VALUES (", item.Id, ",@data_id", item.Id, ")" }));
                                chunk3.AddParameter("@data_id" + item.Id, item.ExtraData);
                            }
                            chunk2.AddQuery("DELETE FROM items_rooms WHERE item_id = " + item.Id);
                            if (item.IsFloorItem)
                            {
                                num = TextHandling.Combine(item.GetX, item.GetY);
                                chunk2.AddQuery(string.Concat(new object[] { "INSERT INTO items_rooms (item_id,room_id,x,y,n) VALUES (", item.Id, ",", item.RoomId, ",", TextHandling.GetString(num), ",", TextHandling.GetString(item.GetZ), ",", item.Rot, ")" }));
                            }
                            else
                            {
                                chunk2.AddQuery(string.Concat(new object[] { "INSERT INTO items_rooms (item_id,room_id,x,y,n) VALUES (", item.Id, ",", item.RoomId, ",", TextHandling.GetString(item.wallCoord.GetXValue()), ",", TextHandling.GetString(item.wallCoord.GetYValue()), ",", item.wallCoord.n(), ")" }));
                            }
                        }
                    }
                    foreach (RoomItem item in this.mMovedItems.Values)
                    {
                        if (!string.IsNullOrEmpty(item.ExtraData))
                        {
                            chunk.AddQuery(string.Concat(new object[] { "UPDATE items_extradata SET data = @data", item.Id, " WHERE item_id = ", item.Id }));
                            chunk.AddParameter("data" + item.Id, item.ExtraData);
                        }
                        if (item.IsWallItem)
                        {
                            chunk.AddQuery(string.Concat(new object[] { "UPDATE items_rooms SET x=", TextHandling.GetString(item.wallCoord.GetXValue()), ", y=", TextHandling.GetString(item.wallCoord.GetYValue()), ", n=", item.wallCoord.n(), " WHERE item_id = ", item.Id }));
                        }
                        else
                        {
                            num = TextHandling.Combine(item.GetX, item.GetY);
                            chunk.AddQuery(string.Concat(new object[] { "UPDATE items_rooms SET x=", TextHandling.GetString(num), ", y=", TextHandling.GetString(item.GetZ), ", n=", item.Rot, " WHERE item_id = ", item.Id }));
                        }
                    }
                    this.room.GetRoomUserManager().AppendPetsUpdateString(dbClient);
                    this.mAddedItems.Clear();
                    this.mRemovedItems.Clear();
                    this.mMovedItems.Clear();
                    chunk.Execute(dbClient);
                    chunk2.Execute(dbClient);
                    chunk3.Execute(dbClient);
                    chunk.Dispose();
                    chunk2.Dispose();
                    chunk3.Dispose();
                    chunk = null;
                    chunk2 = null;
                    chunk3 = null;
                }
            }
            catch (Exception exception)
            {
                Logging.LogCriticalException(string.Concat(new object[] { "Error during saving furniture for room ", this.room.RoomId, ". Stack: ", exception.ToString() }));
            }
        }

        internal bool SetFloorItem(RoomItem Item, int newX, int newY, double newZ)
        {
            this.room.GetGameMap().RemoveFromMap(Item);
            Item.SetState(newX, newY, newZ, Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, Item.Rot));
            this.UpdateItem(Item);
            this.room.GetGameMap().AddItemToMap(Item);
            return true;
        }

        internal bool SetFloorItem(GameClient Session, RoomItem Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage)
        {
            return this.SetFloorItem(Session, Item, newX, newY, newRot, newItem, OnRoller, sendMessage, true);
        }

        internal bool SetFloorItem(GameClient Session, RoomItem Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses)
        {
            ServerMessage message;
            bool flag = false;
            if (!newItem)
            {
                flag = this.room.GetGameMap().RemoveFromMap(Item);
            }
            Dictionary<int, ThreeDCoord> tiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);
            if (!this.room.GetGameMap().ValidTile(newX, newY) || (this.room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat))
            {
                if (flag)
                {
                    this.AddItem(Item);
                    this.room.GetGameMap().AddToMap(Item);
                }
                return false;
            }
            foreach (ThreeDCoord coord in tiles.Values)
            {
                if (!this.room.GetGameMap().ValidTile(coord.X, coord.Y) || (this.room.GetGameMap().SquareHasUsers(coord.X, coord.Y) && !Item.GetBaseItem().IsSeat))
                {
                    if (flag)
                    {
                        this.AddItem(Item);
                        this.room.GetGameMap().AddToMap(Item);
                    }
                    return false;
                }
            }
            double pZ = this.room.GetGameMap().Model.SqFloorHeight[newX, newY];
            if (!OnRoller)
            {
                if ((this.room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN) && !Item.GetBaseItem().IsSeat)
                {
                    if (flag)
                    {
                        this.AddItem(Item);
                        this.room.GetGameMap().AddToMap(Item);
                    }
                    return false;
                }
                foreach (ThreeDCoord coord in tiles.Values)
                {
                    if ((this.room.GetGameMap().Model.SqState[coord.X, coord.Y] != SquareState.OPEN) && !Item.GetBaseItem().IsSeat)
                    {
                        if (flag)
                        {
                            this.AddItem(Item);
                            this.room.GetGameMap().AddToMap(Item);
                        }
                        return false;
                    }
                }
                if (!Item.GetBaseItem().IsSeat && !Item.IsRoller)
                {
                    foreach (ThreeDCoord coord in tiles.Values)
                    {
                        if (this.room.GetGameMap().GetRoomUsers(new Point(coord.X, coord.Y)).Count > 0)
                        {
                            if (flag)
                            {
                                this.AddItem(Item);
                                this.room.GetGameMap().AddToMap(Item);
                            }
                            return false;
                        }
                    }
                }
            }
            List<RoomItem> furniObjects = this.GetFurniObjects(newX, newY);
            List<RoomItem> collection = new List<RoomItem>();
            List<RoomItem> list3 = new List<RoomItem>();
            foreach (ThreeDCoord coord in tiles.Values)
            {
                List<RoomItem> list4 = this.GetFurniObjects(coord.X, coord.Y);
                if (list4 != null)
                {
                    collection.AddRange(list4);
                }
            }
            list3.AddRange(furniObjects);
            list3.AddRange(collection);
            
            if (!OnRoller)
            {
                foreach (RoomItem item in list3)
                {
                    if ((((item != null) && (item.Id != Item.Id)) && (item.GetBaseItem() != null)) && !item.GetBaseItem().Stackable)
                    {
                        if (flag)
                        {
                            this.AddItem(Item);
                            this.room.GetGameMap().AddToMap(Item);
                         }
                        return false;
                    }
                }
            }
            if (((Item.Rot != newRot) && (Item.GetX == newX)) && (Item.GetY == newY))
            {
                if (Item.GetBaseItem().InteractionType == InteractionType.gld_wall)
                {
                    newRot++;
                }
                pZ = Item.GetZ;

            }
            foreach (RoomItem item in list3)
            {
                if ((item.Id != Item.Id) && (item.TotalHeight > pZ))
                {
                    pZ = item.TotalHeight;
                }
            }
            if (Item.GetBaseItem().Name != "boutique_mannequin1")
            {
                if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8)
                {
                    newRot = 0;
                }
            }
            else
            {
                if (newRot != 0 && newRot != 1 && newRot != 2 && newRot != 3 && newRot != 4 && newRot != 5 && newRot != 6 && newRot != 7 && newRot != 8 && newRot != 9 && newRot != 10 && newRot != 11 && newRot != 12) 
                {
                    newRot = 0;
                }
            }
            
            Item.Rot = newRot;
            int getX = Item.GetX;
            int getY = Item.GetY;
            Item.SetState(newX, newY, pZ, tiles);
            if (!(OnRoller || (Session == null)))
            {
                Item.Interactor.OnPlace(Session, Item);
            }
            if (newItem)
            {
                if (this.mFloorItems.ContainsKey(Item.Id))
                {
                    if (Session != null)
                    {
                        Session.SendNotif(LanguageLocale.GetValue("room.itemplaced"));
                    }
                    return true;
                }
                if (!(!Item.IsFloorItem || this.mFloorItems.ContainsKey(Item.Id)))
                {
                    this.mFloorItems.Add(Item.Id, Item);
                }
                else if (!(!Item.IsWallItem || this.mWallItems.ContainsKey(Item.Id)))
                {
                    this.mWallItems.Add(Item.Id, Item);
                }
                this.AddItem(Item);
                if (sendMessage)
                {
                    message = new ServerMessage(Outgoing.AddFloorItemToRoom);
                    Item.Serialize(message, (int)Item.placedBy);
                    message.AppendString(ButterflyEnvironment.GetGame().GetClientManager().GetNameById(Item.placedBy));
                    this.room.SendMessage(message);
                }
            }
            else
            {
                this.UpdateItem(Item);
                if (!(OnRoller || !sendMessage))
                {
                    message = new ServerMessage(Outgoing.UpdateItemOnRoom);
                    Item.Serialize(message, (int)Item.placedBy);
                    this.room.SendMessage(message);
                }
            }

            if (!newItem)
            {
                this.room.GetWiredHandler().RemoveWiredItem(new Point(getX, getY));
                if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType))
                {
                    this.room.GetWiredHandler().AddWire(Item, new Point(newX, newY), newRot, Item.GetBaseItem().InteractionType);
                }
            }

            else if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType))
            {
                this.room.GetWiredHandler().AddWire(Item, Item.Coordinate, newRot, Item.GetBaseItem().InteractionType);
            }
            this.room.GetGameMap().AddToMap(Item);
            if (Item.GetBaseItem().IsSeat)
            {
                updateRoomUserStatuses = true;
            }
            if (updateRoomUserStatuses)
            {
                this.room.GetRoomUserManager().UpdateUserStatusses();
            }
            if ((Item.GetBaseItem().InteractionType == InteractionType.obstacle_h) && ((Item.Rot == 2) || (Item.Rot == 6)))
            {
                if ((Item.GetX + 1) <= this.room.GetGameMap().StaticModel.MapSizeX)
                {
                    Item.SetState(Item.GetX + 1, Item.GetY, Item.GetZ, tiles);
                }
                else if (((Item.Rot == 0) || (Item.Rot == 4)) && ((Item.GetY + 1) <= this.room.GetGameMap().StaticModel.MapSizeY))
                {
                    Item.SetState(Item.GetX, Item.GetY + 1, Item.GetZ, tiles);
                }
            }
            return true;
        }

        internal void SetSpeed(int p)
        {
            this.mRollerSpeed = p;
        }

        internal bool SetWallItem(GameClient Session, RoomItem Item)
        {
            if (!(Item.IsWallItem && !this.mWallItems.ContainsKey(Item.Id)))
            {
                return false;
            }
            if (this.mFloorItems.ContainsKey(Item.Id))
            {
                Session.SendNotif(LanguageLocale.GetValue("room.itemplaced"));
                return true;
            }
            Item.Interactor.OnPlace(Session, Item);
            if ((Item.GetBaseItem().InteractionType == InteractionType.dimmer) && (this.room.MoodlightData == null))
            {
                this.room.MoodlightData = new MoodlightData(Item.Id);
                Item.ExtraData = this.room.MoodlightData.GenerateExtraData();
            }
            this.mWallItems.Add(Item.Id, Item);
            this.AddItem(Item);
            ServerMessage message = new ServerMessage(Outgoing.AddWallItemToRoom);
            Item.Serialize(message, (int)Item.placedBy);
            message.AppendString(ButterflyEnvironment.GetGame().GetClientManager().GetNameById(Item.placedBy));
            this.room.SendMessage(message);
            return true;
        }

        internal void UpdateItem(RoomItem item)
        {
            if (!this.mAddedItems.ContainsKey(item.Id))
            {
                if (this.mRemovedItems.ContainsKey(item.Id))
                {
                    this.mRemovedItems.Remove(item.Id);
                }
                if (!this.mMovedItems.ContainsKey(item.Id))
                {
                    this.mMovedItems.Add(item.Id, item);
                }
            }
        }

        private ServerMessage UpdateItemOnRoller(RoomItem pItem, Point NextCoord, uint pRolledID, double NextZ)
        {
            ServerMessage message = new ServerMessage();
            message.Init(Outgoing.ObjectOnRoller);
            message.AppendInt32(pItem.GetX);
            message.AppendInt32(pItem.GetY);
            message.AppendInt32(NextCoord.X);
            message.AppendInt32(NextCoord.Y);
            message.AppendInt32(1);
            message.AppendInt32(pItem.Id);
            message.AppendString(TextHandling.GetString(pItem.GetZ));
            message.AppendString(TextHandling.GetString(NextZ));
            message.AppendInt32(pRolledID);
            this.SetFloorItem(pItem, NextCoord.X, NextCoord.Y, NextZ);
            return message;
        }

        internal ServerMessage UpdateUserOnRoller(RoomUser pUser, Point pNextCoord, uint pRollerID, double NextZ)
        {
            ServerMessage message = new ServerMessage(0);
            message.Init(Outgoing.ObjectOnRoller);
            message.AppendInt32(pUser.X);
            message.AppendInt32(pUser.Y);
            message.AppendInt32(pNextCoord.X);
            message.AppendInt32(pNextCoord.Y);
            message.AppendInt32(0);
            message.AppendInt32(pRollerID);
            message.AppendInt32(2);
            message.AppendInt32(pUser.VirtualId);
            message.AppendString(TextHandling.GetString(pUser.Z));
            message.AppendString(TextHandling.GetString(NextZ));
            this.room.GetGameMap().UpdateUserMovement(new Point(pUser.X, pUser.Y), new Point(pNextCoord.X, pNextCoord.Y), pUser);
            this.room.GetGameMap().GameMap[pUser.X, pUser.Y] = 1;
            pUser.X = pNextCoord.X;
            pUser.Y = pNextCoord.Y;
            pUser.Z = NextZ;
            this.room.GetGameMap().GameMap[pUser.X, pUser.Y] = 0;
            return message;
        }

        internal bool GotRollers
        {
            get
            {
                return this.mGotRollers;
            }
            set
            {
                this.mGotRollers = value;
            }
        }
    }
}

SharedPacketlib.cs
Code:
namespace Butterfly.Messages.StaticMessageHandlers
{
    using Butterfly.Messages;
    using System;

    internal class SharedPacketLib
    {
        public static void AcceptMember(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("AcceptMember");
            Handler.AcceptMember();
        }

        internal static void AcceptRequest(GameClientMessageHandler handler)
        {
            //Console.WriteLine("AcceptRequest");
            handler.AcceptRequest();
        }

        internal static void AcceptTrade(GameClientMessageHandler handler)
        {
            handler.AcceptTrade();
        }

        internal static void AddFavorite(GameClientMessageHandler handler)
        {
            handler.AddFavorite();
        }

        public static void AddNewCdToJuke(GameClientMessageHandler Handler)
        {
            Handler.AddNewCdToJuke();
        }

        internal static void AddSaddle(GameClientMessageHandler handler)
        {
            handler.AddSaddle();
        }

        internal static void AnswerDoorbell(GameClientMessageHandler handler)
        {
            handler.AnswerDoorbell();
        }

        internal static void AnswerQuestion(GameClientMessageHandler handler)
        {
            handler.AnswerInfobusPoll();
        }

        internal static void ApplyEffect(GameClientMessageHandler handler)
        {
            handler.ApplyEffect();
        }

        internal static void ApplyRoomEffect(GameClientMessageHandler handler)
        {
            handler.ApplyRoomEffect();
        }
        
        internal static void BotsInventary(GameClientMessageHandler handler)
        {
            handler.BotsInventary();
        }

        internal static void BanUser(GameClientMessageHandler handler)
        {
            handler.BanUser();
        }

        public static void BuyGroup(GameClientMessageHandler Handler)
        {
            Handler.BuyGroup();
        }

        internal static void CanCreateRoom(GameClientMessageHandler handler)
        {
            handler.CanCreateRoom();
        }

        internal static void CanGift(GameClientMessageHandler handler)
        {
            handler.CanGift();
        }

        internal static void ChangeLook(GameClientMessageHandler handler)
        {
            handler.ChangeLook();
        }

        internal static void ChangeMotto(GameClientMessageHandler handler)
        {
            handler.ChangeMotto();
        }

        internal static void CheckHabboRelease(GameClientMessageHandler handler)
        {
            handler.CheckRelease();
        }

        internal static void CheckNameChange(GameClientMessageHandler handler)
        {
            handler.CheckNameToChange();
        }

        internal static void CheckPetName(GameClientMessageHandler handler)
        {
            handler.CheckPetName();
        }

        internal static void ClearRoomLoading(GameClientMessageHandler handler)
        {
            handler.ClearRoomLoading();
        }

        internal static void CommandsPet(GameClientMessageHandler handler)
        {
            handler.CommandsPet();
        }

        internal static void CompleteTrade(GameClientMessageHandler handler)
        {
            handler.CompleteTrade();
        }

        internal static void CreateRoom(GameClientMessageHandler handler)
        {
            handler.CreateRoom();
        }

        internal static void CreateStream(GameClientMessageHandler handler)
        {
            handler.CreateStream();
        }

        internal static void Dance(GameClientMessageHandler handler)
        {
            handler.Dance();
        }

        internal static void DeclineRequest(GameClientMessageHandler handler)
        {
            handler.DeclineRequest();
        }

        internal static void DeletePendingCFH(GameClientMessageHandler handler)
        {
            handler.DeletePendingCFH();
        }

        internal static void DeletePostit(GameClientMessageHandler handler)
        {
            handler.DeletePostit();
        }

        internal static void DeleteRoom(GameClientMessageHandler handler)
        {
            handler.DeleteRoom();
        }

        public static void EditAjustes(GameClientMessageHandler Handler)
        {
            Handler.EditAjustes();
        }

        public static void EditColores(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("EditColors");
            
            Handler.EditColores();
        }

        public static void EditGuild(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("Editguild");
            Handler.EditGuild();
        }

        public static void EditIdentidad(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("EditIdentidad");
            Handler.EditIdentidad();
        }

        public static void EditPlaca(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("EditPlaca");
            Handler.EditPlaca();
        }

        internal static void EnableEffect(GameClientMessageHandler handler)
        {
            handler.EnableEffect();
        }

        public static void EndConfirmBuy(GameClientMessageHandler Handler)
        {
            Handler.EndConfirmBuy();
        }

        public static void EndQuiz(GameClientMessageHandler Handler)
        {
            Handler.EndQuizQuestions();
        }

        internal static void EnterInfobus(GameClientMessageHandler handler)
        {
            handler.EnterInfobus();
        }

        internal static void EnterInquiredRoom(GameClientMessageHandler handler)
        {
            handler.EnterInquiredRoom();
        }

        internal static void enterOnRoom(GameClientMessageHandler handler)
        {
            handler.enterOnRoom();
        }

        public static void ExitGuild(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("ExitGuild");
            Handler.ExitGuild();
        }

        internal static void ExtraVipWindow(GameClientMessageHandler handler)
        {
            handler.ExtraVipWindow();
        }

        internal static void FollowBuddy(GameClientMessageHandler handler)
        {
            handler.FollowBuddy();
        }

        internal static void FriendsListUpdate(GameClientMessageHandler handler)
        {
            handler.FriendsListUpdate();
        }

        internal static void GetAchievements(GameClientMessageHandler handler)
        {
            handler.GetAchievements();
        }

        internal static void GetBadges(GameClientMessageHandler handler)
        {
            handler.GetBadges();
        }

        internal static void GetBalance(GameClientMessageHandler handler)
        {
            handler.GetBalance();
        }

        internal static void GetCataData1(GameClientMessageHandler handler)
        {
            handler.GetCataData1();
        }

        internal static void GetCataData2(GameClientMessageHandler handler)
        {
            handler.GetCataData2();
        }

        internal static void GetCatalogIndex(GameClientMessageHandler handler)
        {
            handler.GetCatalogIndex();
        }

        internal static void GetCatalogPage(GameClientMessageHandler handler)
        {
            handler.GetCatalogPage();
        }

        internal static void GetEvents(GameClientMessageHandler handler)
        {
            handler.GetEvents();
        }

        internal static void GetFavoriteRooms(GameClientMessageHandler handler)
        {
            handler.GetFavoriteRooms();
        }

        internal static void GetFlatCats(GameClientMessageHandler handler)
        {
            handler.GetFlatCats();
        }

        internal static void GetFriendsRooms(GameClientMessageHandler handler)
        {
            handler.GetFriendsRooms();
        }

        public static void GetGame(GameClientMessageHandler Handler)
        {
            Handler.GetGame();
        }

        public static void GetGames(GameClientMessageHandler Handler)
        {
            Handler.GetGames();
        }

        public static void GetGuildFavorite(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("GetGuildFavorite");
            Handler.GetGuildFavorite();
        }

        internal static void GetHelpCategories(GameClientMessageHandler handler)
        {
            handler.GetHelpCategories();
        }

        internal static void GetHighRatedRooms(GameClientMessageHandler handler)
        {
            handler.GetHighRatedRooms();
        }

        internal static void GetInventory(GameClientMessageHandler handler)
        {
            handler.GetInventory();
        }

        internal static void GetMoodlight(GameClientMessageHandler handler)
        {
            handler.GetMoodlight();
        }

        public static void GetMusicData(GameClientMessageHandler Handler)
        {
            Handler.GetMusicData();
        }

        internal static void GetOwnRooms(GameClientMessageHandler handler)
        {
            handler.GetOwnRooms();
        }

        internal static void GetPetInfo(GameClientMessageHandler handler)
        {
            handler.GetPetInfo();
        }

        internal static void GetPetsInventory(GameClientMessageHandler handler)
        {
            handler.GetPetsInventory();
        }

        internal static void GetPopularRooms(GameClientMessageHandler handler)
        {
            handler.GetPopularRooms();
        }

        internal static void GetPopularTags(GameClientMessageHandler handler)
        {
            handler.GetPopularTags();
        }

        internal static void GetPubs(GameClientMessageHandler handler)
        {
            handler.GetPubs();
        }

        internal static void GetRecentRooms(GameClientMessageHandler handler)
        {
            handler.GetRecentRooms();
        }

        internal static void GetRecyclerRewards(GameClientMessageHandler handler)
        {
            handler.GetRecyclerRewards();
        }

        internal static void GetRoomData2(GameClientMessageHandler handler)
        {
            handler.GetRoomData2();
        }

        internal static void GetRoomData3(GameClientMessageHandler handler)
        {
            handler.GetRoomData3();
        }

        internal static void GetRoomEditData(GameClientMessageHandler handler)
        {
            handler.GetRoomEditData();
        }

        internal static void GetRoomInfo(GameClientMessageHandler handler)
        {
            handler.GetRoomInfo();
        }

        internal static void GetRoomsWithFriends(GameClientMessageHandler handler)
        {
            handler.GetRoomsWithFriends();
        }

        internal static void GetSubscriptionData(GameClientMessageHandler handler)
        {
            handler.GetSubscriptionData();
        }

        internal static void GetTopicsInCategory(GameClientMessageHandler handler)
        {
            handler.GetTopicsInCategory();
        }

        internal static void GetTrainerPanel(GameClientMessageHandler handler)
        {
            handler.GetTrainerPanel();
        }

        internal static void GetUserBadges(GameClientMessageHandler handler)
        {
            handler.GetUserBadges();
        }

        internal static void GetUserInfo(GameClientMessageHandler handler)
        {
            handler.GetUserInfo();
        }

        internal static void GetUserTags(GameClientMessageHandler handler)
        {
            handler.GetUserTags();
        }

        internal static void GetWardrobe(GameClientMessageHandler handler)
        {
            handler.GetWardrobe();
        }

        internal static void GiveHanditem(GameClientMessageHandler handler)
        {
            handler.GiveHanditem();
        }

        internal static void GiveRespect(GameClientMessageHandler handler)
        {
            handler.GiveRespect();
        }

        internal static void GiveRights(GameClientMessageHandler handler)
        {
            handler.GiveRights();
        }

        internal static void GoToHotelView(GameClientMessageHandler handler)
        {
            handler.GoToHotelView();
        }

        internal static void HandlePurchase(GameClientMessageHandler handler)
        {
            handler.HandlePurchase();
        }

        internal static void IgnoreUser(GameClientMessageHandler handler)
        {
            handler.IgnoreUser();
        }

        internal static void InitCrypto(GameClientMessageHandler handler)
        {
            handler.InitCrypto();
        }

        internal static void InitHelpTool(GameClientMessageHandler handler)
        {
            handler.InitHelpTool();
        }

        internal static void InitTrade(GameClientMessageHandler handler)
        {
            handler.InitTrade();
        }

        internal static void KickBot(GameClientMessageHandler handler)
        {
            handler.KickBot();
        }

        internal static void KickUser(GameClientMessageHandler handler)
        {
            handler.KickUser();
        }

        public static void LeaveGame(GameClientMessageHandler Handler)
        {
            Handler.LeaveGame();
        }

        public static void LoadInvSongs(GameClientMessageHandler Handler)
        {
            Handler.LoadInvSongs();
        }

        public static void LoadJukeSongs(GameClientMessageHandler Handler)
        {
            Handler.LoadJukeSongs();
        }

        public static void LoadMembersPetitions(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("LoadMembersPetition");
            Handler.LoadMembersPetitions();
        }

        public static void RejectGuildMember(GameClientMessageHandler handler)
        {
            //Console.WriteLine("RejectGuildMember");
            handler.RejectGuildMember();
        }

        internal static void LoadProfile(GameClientMessageHandler handler)
        {
            //Console.WriteLine("LoadProfile");
            handler.LoadProfile();
        }

        internal static void LoadTalents(GameClientMessageHandler handler)
        {
            handler.LoadTalents();
        }

        internal static void LoadUser2(GameClientMessageHandler Handler)
        {
            Handler.LoadUser2();
        }

        internal static void LookAt(GameClientMessageHandler handler)
        {
            handler.LookAt();
        }

        internal static void MarketplaceCanSell(GameClientMessageHandler handler)
        {
            handler.MarketplaceCanSell();
        }

        internal static void MarketplaceClaimCredits(GameClientMessageHandler handler)
        {
            handler.MarketplaceClaimCredits();
        }

        internal static void MarketplaceGetOffers(GameClientMessageHandler handler)
        {
            handler.MarketplaceGetOffers();
        }

        internal static void MarketplaceGetOwnOffers(GameClientMessageHandler handler)
        {
            handler.MarketplaceGetOwnOffers();
        }

        internal static void MarketplacePostItem(GameClientMessageHandler handler)
        {
            handler.MarketplacePostItem();
        }

        internal static void MarketplacePurchase(GameClientMessageHandler handler)
        {
            handler.MarketplacePurchase();
        }

        internal static void MarketplaceTakeBack(GameClientMessageHandler handler)
        {
            handler.MarketplaceTakeBack();
        }

        internal static void ModBanUser(GameClientMessageHandler handler)
        {
            handler.ModBanUser();
        }

        internal static void ModCloseTicket(GameClientMessageHandler handler)
        {
            handler.ModCloseTicket();
        }

        internal static void ModGetRoomChatlog(GameClientMessageHandler handler)
        {
            handler.ModGetRoomChatlog();
        }

        internal static void ModGetRoomTool(GameClientMessageHandler handler)
        {
            handler.ModGetRoomTool();
        }

        internal static void ModGetRoomVisits(GameClientMessageHandler handler)
        {
            handler.ModGetRoomVisits();
        }

        internal static void ModGetTicketChatlog(GameClientMessageHandler handler)
        {
            handler.ModGetTicketChatlog();
        }

        internal static void ModGetUserChatlog(GameClientMessageHandler handler)
        {
            handler.ModGetUserChatlog();
        }

        internal static void ModGetUserInfo(GameClientMessageHandler handler)
        {
            handler.ModGetUserInfo();
        }

        internal static void ModKickUser(GameClientMessageHandler handler)
        {
            handler.ModKickUser();
        }

        internal static void ModPerformRoomAction(GameClientMessageHandler handler)
        {
            handler.ModPerformRoomAction();
        }

        internal static void ModPickTicket(GameClientMessageHandler handler)
        {
            handler.ModPickTicket();
        }

        internal static void ModReleaseTicket(GameClientMessageHandler handler)
        {
            handler.ModReleaseTicket();
        }

        internal static void ModSendRoomAlert(GameClientMessageHandler handler)
        {
            handler.ModSendRoomAlert();
        }

        internal static void ModSendUserCaution(GameClientMessageHandler handler)
        {
            handler.ModSendUserCaution();
        }

        internal static void ModSendUserMessage(GameClientMessageHandler handler)
        {
            handler.ModSendUserMessage();
        }

        internal static void Move(GameClientMessageHandler handler)
        {
            handler.Move();
        }

        internal static void MoveItem(GameClientMessageHandler handler)
        {
            handler.MoveItem();
        }

        internal static void MoveWallItem(GameClientMessageHandler handler)
        {
            handler.MoveWallItem();
        }

        internal static void OfferTradeItem(GameClientMessageHandler handler)
        {
            handler.OfferTradeItem();
        }

        internal static void OnRoomUserAdd(GameClientMessageHandler handler)
        {
            handler.OnRoomUserAdd();
        }

        internal static void OpenFlat(GameClientMessageHandler handler)
        {
            handler.OpenFlat();
        }

        public static void OpenGuildPage(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("OpenGuildPage");
            Handler.OpenGuildPage();
        }

        internal static void OpenPostit(GameClientMessageHandler handler)
        {
            handler.OpenPostit();
        }

        internal static void OpenPresent(GameClientMessageHandler handler)
        {
            handler.OpenPresent();
        }

        internal static void OpenQuests(GameClientMessageHandler handler)
        {
            handler.OpenQuests();
        }

        internal static void PerformSearch(GameClientMessageHandler handler)
        {
            handler.PerformSearch();
        }

        internal static void PerformSearch2(GameClientMessageHandler handler)
        {
            handler.PerformSearch2();
        }

        internal static void PetRaces(GameClientMessageHandler handler)
        {
            handler.PetRaces();
        }

        internal static void PickUpPet(GameClientMessageHandler handler)
        {
            handler.PickUpPet();
        }

        internal static void Ping(GameClientMessageHandler handler)
        {
            handler.Ping();
        }

        internal static void PlaceItem(GameClientMessageHandler handler)
        {
            handler.PlaceItem();
        }

        internal static void PlacePet(GameClientMessageHandler handler)
        {
            handler.PlacePet();
        }

        internal static void PlacePostIt(GameClientMessageHandler handler)
        {
            handler.PlacePostIt();
        }

        internal static void Pong(GameClientMessageHandler handler)
        {
            handler.Pong();
        }

        public static void PopularGuilds(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("PopularGuilds");
            Handler.PopularGuilds();
        }

        internal static void PurchaseGift(GameClientMessageHandler handler)
        {
            handler.PurchaseGift();
        }

        internal static void RateRoom(GameClientMessageHandler handler)
        {
            handler.RateRoom();
        }

        internal static void RecycleItems(GameClientMessageHandler handler)
        {
            handler.RecycleItems();
        }

        internal static void RedeemExchangeFurni(GameClientMessageHandler handler)
        {
            handler.RedeemExchangeFurni();
        }

        internal static void RedeemVoucher(GameClientMessageHandler handler)
        {
            handler.RedeemVoucher();
        }

        internal static void RemoveBuddy(GameClientMessageHandler handler)
        {
            handler.RemoveBuddy();
        }

        public static void RemoveCdToJuke(GameClientMessageHandler Handler)
        {
            Handler.RemoveCdToJuke();
        }

        internal static void RemoveFavorite(GameClientMessageHandler handler)
        {
            handler.RemoveFavorite();
        }

        public static void RemoveGuildFavorite(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("RemoveGuildFavorite");
            Handler.RemoveGuildFavorite();
        }

        internal static void RemoveHanditem(GameClientMessageHandler handler)
        {
            handler.RemoveHanditem();
        }

        internal static void RemoveSaddle(GameClientMessageHandler handler)
        {
            handler.RemoveSaddle();
        }

        internal static void ReqLoadRoomForUser(GameClientMessageHandler handler)
        {
            handler.ReqLoadRoomForUser();
        }

        internal static void RequestBuddy(GameClientMessageHandler handler)
        {
            handler.RequestBuddy();
        }

        internal static void RespectPet(GameClientMessageHandler handler)
        {
            handler.RespectPet();
        }

        internal static void Ride(GameClientMessageHandler handler)
        {
            handler.MountOnPet();
        }

        internal static void SaveMannequin(GameClientMessageHandler handler)
        {
            handler.SaveMannequin();
        }

        internal static void SaveNameChange(GameClientMessageHandler handler)
        {
            handler.SaveNameToChange();
        }

        internal static void SavePostit(GameClientMessageHandler handler)
        {
            handler.SavePostit();
        }

        internal static void SaveRoomData(GameClientMessageHandler handler)
        {
            handler.SaveRoomData();
        }

        internal static void SaveWardrobe(GameClientMessageHandler handler)
        {
            handler.SaveWardrobe();
        }

        internal static void SaveWired(GameClientMessageHandler handler)
        {
            handler.SaveWired();
        }

        internal static void SaveWiredCondition(GameClientMessageHandler handler)
        {
            handler.SaveWiredConditions();
        }

        internal static void SearchHabbo(GameClientMessageHandler handler)
        {
            handler.SearchHabbo();
        }

        internal static void SearchHelpTopics(GameClientMessageHandler handler)
        {
            handler.SearchHelpTopics();
        }

        internal static void SecretKey(GameClientMessageHandler handler)
        {
            handler.InitSecretKey();
        }

        public static void SendFurniGuild(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("SendFurniGuild");
            Handler.SendFurniGuild();
        }

        internal static void SendInstantInvite(GameClientMessageHandler handler)
        {
            handler.SendInstantInvite();
        }

        internal static void SendInstantMessenger(GameClientMessageHandler handler)
        {
            handler.SendInstantMessenger();
        }

        public static void SendRequestGuild(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("SendRequestGuild");
            Handler.SendRequestGuild();
        }

        internal static void SetHomeRoom(GameClientMessageHandler handler)
        {
            handler.SetHomeRoom();
        }

        internal static void SetLookTransfer(GameClientMessageHandler handler)
        {
            handler.SetLookTransfer();
        }

        internal static void setUniqueId(GameClientMessageHandler handler)
        {
            handler.setUniqueIDToClient();
        }

        internal static void setVars(GameClientMessageHandler handler)
        {
            handler.setClientVars();
        }

        internal static void Shout(GameClientMessageHandler handler)
        {
            handler.Shout();
        }

        internal static void Sign(GameClientMessageHandler handler)
        {
            handler.Sign();
        }

        internal static void Sit(GameClientMessageHandler handler)
        {
            handler.Sit();
        }

        internal static void SSOLogin(GameClientMessageHandler handler)
        {
            handler.SSOLogin();
        }

        internal static void StartEndedQuest(GameClientMessageHandler handler)
        {
            handler.ActiveEndedQuest();
        }

        public static void StartPanel(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("StartPanel");
            Handler.StartPanel();
        }

        public static void stageReadyMessage(GameClientMessageHandler handler)
        {
            handler.stageReadyMessage();
        }

        internal static void StartQuest(GameClientMessageHandler handler)
        {
            handler.StartQuest();
        }

        public static void StartQuiz(GameClientMessageHandler Handler)
        {
            Handler.StartQuiz();
        }

        internal static void StartTyping(GameClientMessageHandler handler)
        {
            handler.StartTyping();
        }

        internal static void StopQuest(GameClientMessageHandler handler)
        {
            handler.StopQuest();
        }

        internal static void StopTrade(GameClientMessageHandler handler)
        {
            handler.StopTrade();
        }

        internal static void StopTyping(GameClientMessageHandler handler)
        {
            handler.StopTyping();
        }

        internal static void Stream(GameClientMessageHandler handler)
        {
            handler.InitStream();
        }

        internal static void StreamLike(GameClientMessageHandler handler)
        {
            handler.StreamLike();
        }

        internal static void SubmitHelpTicket(GameClientMessageHandler handler)
        {
            handler.SubmitHelpTicket();
        }

        internal static void SwitchMoodlightStatus(GameClientMessageHandler handler)
        {
            handler.SwitchMoodlightStatus();
        }

        internal static void TakeAllRights(GameClientMessageHandler handler)
        {
            handler.TakeAllRights();
        }

        internal static void TakeBackTradeItem(GameClientMessageHandler handler)
        {
            handler.TakeBackTradeItem();
        }

        internal static void TakeItem(GameClientMessageHandler handler)
        {
            handler.TakeItem();
        }

        internal static void TakeRights(GameClientMessageHandler handler)
        {
            handler.TakeRights();
        }

        internal static void Talk(GameClientMessageHandler handler)
        {
            handler.Talk();
        }

        public static void TalkGame(GameClientMessageHandler Handler)
        {
            Handler.TalkGame();
        }

        internal static void TriggerItem(GameClientMessageHandler handler)
        {
            handler.TriggerItem();
        }

        internal static void TriggerItemDiceSpecial(GameClientMessageHandler handler)
        {
            handler.TriggerItemDiceSpecial();
        }

        internal static void UnacceptTrade(GameClientMessageHandler handler)
        {
            handler.UnacceptTrade();
        }

        internal static void UnignoreUser(GameClientMessageHandler handler)
        {
            handler.UnignoreUser();
        }

        internal static void Unride(GameClientMessageHandler handler)
        {
            handler.CancelMountOnPet();
        }

        internal static void UpdateAllMount(GameClientMessageHandler handler)
        {
            handler.UpdateAllMount();
        }

        internal static void UpdateBadges(GameClientMessageHandler handler)
        {
            handler.UpdateBadges();
        }

        internal static void UpdateMoodlight(GameClientMessageHandler handler)
        {
            handler.UpdateMoodlight();
        }

        public static void UpdateUserToRankGuild(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("UpdateUserToRankGuild");
            Handler.UpdateUserToRankGuild();
        }

        public static void UpdateUserFromRankGuild(GameClientMessageHandler Handler)
        {
            //Console.WriteLine("UpdateUserFromRank");
            Handler.UpdateUserFromRankGuild();
        }

        internal static void ViewHelpTopic(GameClientMessageHandler handler)
        {
            handler.ViewHelpTopic();
        }

        public static void WalkGame(GameClientMessageHandler Handler)
        {
            Handler.WalkGame();
        }

        internal static void Wave(GameClientMessageHandler handler)
        {
            handler.Wave();
        }

        internal static void Whisper(GameClientMessageHandler handler)
        {
            handler.Whisper();
        }
        
        public static void EjectFurni(GameClientMessageHandler handler)
        {
            handler.EjectFurni();
        }
        
        public static void volumeControl(GameClientMessageHandler handler)
        {
            handler.volumeControl();
        }

        public static void unknown(GameClientMessageHandler handler)
        {
            handler.unknown();
        }
    }
}

StaticClientMessageHandler.cs
Code:
namespace Butterfly.Messages.StaticMessageHandlers
{
    using Butterfly.Core;
    using Butterfly.Messages;
    using HabboEvents;
    using System;
    using System.Collections;
    using System.Runtime.CompilerServices;

    internal class StaticClientMessageHandler
    {
        private static Hashtable handlers;

        internal static void HandlePacket(GameClientMessageHandler handler, ClientMessage message)
        {
            bool flag = false;

            //Console.WriteLine("Recieved message " + message.Header);

            if (handlers.ContainsKey(message.Id))
            {
                if (flag)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" \x00bb Contains: Handle Packet => " + message.Id);
                    Console.ResetColor();
                }
                StaticRequestHandler handler2 = (StaticRequestHandler) handlers[message.Id];
                handler2(handler);
            }
            else if (flag)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(" \x00bb Error: Handle Packet => " + message.Id);
                Console.ResetColor();
            }
        }

        internal static void Initialize()
        {
            handlers = new Hashtable(200);
            RegisterPacketLibary();
        }

        internal static void RegisterPacketLibary()
        {
            handlers.Add(Incoming.CheckReleaseMessageEvent, new StaticRequestHandler(SharedPacketLib.CheckHabboRelease));
            handlers.Add(Incoming.InitCrypto, new StaticRequestHandler(SharedPacketLib.InitCrypto));
            handlers.Add(Incoming.SecretKey, new StaticRequestHandler(SharedPacketLib.SecretKey));
            handlers.Add(Incoming.ClientVars, new StaticRequestHandler(SharedPacketLib.setVars));
            handlers.Add(Incoming.UniqueMachineID, new StaticRequestHandler(SharedPacketLib.setUniqueId));
            handlers.Add(Incoming.OpenCatalog, new StaticRequestHandler(SharedPacketLib.GetCatalogIndex));
            handlers.Add(Incoming.OpenCatalogPage, new StaticRequestHandler(SharedPacketLib.GetCatalogPage));
            handlers.Add(Incoming.RedeemVoucher, new StaticRequestHandler(SharedPacketLib.RedeemVoucher));
            handlers.Add(Incoming.PurchaseCatalogItem, new StaticRequestHandler(SharedPacketLib.HandlePurchase));
            handlers.Add(Incoming.PurchaseGift, new StaticRequestHandler(SharedPacketLib.PurchaseGift));
            handlers.Add(Incoming.StartQuiz, new StaticRequestHandler(SharedPacketLib.StartQuiz));
            handlers.Add(Incoming.EndQuiz, new StaticRequestHandler(SharedPacketLib.EndQuiz));
            handlers.Add(Incoming.LoadTalents, new StaticRequestHandler(SharedPacketLib.LoadTalents));
            handlers.Add(Incoming.LoadUser2, new StaticRequestHandler(SharedPacketLib.LoadUser2));
            handlers.Add(Incoming.ExtraVipWindow, new StaticRequestHandler(SharedPacketLib.ExtraVipWindow));
            handlers.Add(Incoming.AnswerQuestion, new StaticRequestHandler(SharedPacketLib.AnswerQuestion));
            handlers.Add(Incoming.CatalogData1, new StaticRequestHandler(SharedPacketLib.GetCataData1));
            handlers.Add(Incoming.CatalogData2, new StaticRequestHandler(SharedPacketLib.GetCataData2));
            handlers.Add(Incoming.BotsInventary, new StaticRequestHandler(SharedPacketLib.BotsInventary));
            
            handlers.Add(Incoming.CheckPetName, new StaticRequestHandler(SharedPacketLib.CheckPetName));
            handlers.Add(Incoming.UpdateAllMount, new StaticRequestHandler(SharedPacketLib.UpdateAllMount));
            handlers.Add(Incoming.CatalogGetRace, new StaticRequestHandler(SharedPacketLib.PetRaces));
            handlers.Add(Incoming.Pong, new StaticRequestHandler(SharedPacketLib.Pong));
            handlers.Add(Incoming.Ping, new StaticRequestHandler(SharedPacketLib.Ping));
            handlers.Add(Incoming.SSOTicket, new StaticRequestHandler(SharedPacketLib.SSOLogin));
            handlers.Add(Incoming.OpenHelpTool, new StaticRequestHandler(SharedPacketLib.InitHelpTool));
            handlers.Add(Incoming.CreateTicket, new StaticRequestHandler(SharedPacketLib.SubmitHelpTicket));
            handlers.Add(Incoming.SendRoomAlert, new StaticRequestHandler(SharedPacketLib.ModSendRoomAlert));
            handlers.Add(Incoming.PickIssue, new StaticRequestHandler(SharedPacketLib.ModPickTicket));
            handlers.Add(Incoming.ReleaseIssue, new StaticRequestHandler(SharedPacketLib.ModReleaseTicket));
            handlers.Add(Incoming.CloseIssue, new StaticRequestHandler(SharedPacketLib.ModCloseTicket));
            handlers.Add(Incoming.ToolForUser, new StaticRequestHandler(SharedPacketLib.ModGetUserInfo));
            handlers.Add(Incoming.UserChatlog, new StaticRequestHandler(SharedPacketLib.ModGetUserChatlog));
            handlers.Add(Incoming.OpenRoomChatlog, new StaticRequestHandler(SharedPacketLib.ModGetRoomChatlog));
            handlers.Add(Incoming.IssueChatlog, new StaticRequestHandler(SharedPacketLib.ModGetTicketChatlog));
            handlers.Add(Incoming.GetRoomVisits, new StaticRequestHandler(SharedPacketLib.ModGetRoomVisits));
            handlers.Add(Incoming.ToolForThisRoom, new StaticRequestHandler(SharedPacketLib.ModGetRoomTool));
            handlers.Add(Incoming.PerformRoomAction, new StaticRequestHandler(SharedPacketLib.ModPerformRoomAction));
            handlers.Add(Incoming.SendUserMessage, new StaticRequestHandler(SharedPacketLib.ModSendUserCaution));
            handlers.Add(Incoming.SendMessageByTemplate, new StaticRequestHandler(SharedPacketLib.ModSendUserMessage));
            handlers.Add(Incoming.ModActionKickUser, new StaticRequestHandler(SharedPacketLib.ModKickUser));
            handlers.Add(Incoming.ModActionMuteUser, new StaticRequestHandler(SharedPacketLib.ModKickUser));
            handlers.Add(Incoming.ModActionBanUser, new StaticRequestHandler(SharedPacketLib.ModBanUser));
            handlers.Add(Incoming.UpdateFriendsState, new StaticRequestHandler(SharedPacketLib.FriendsListUpdate));
            handlers.Add(Incoming.DeleteFriend, new StaticRequestHandler(SharedPacketLib.RemoveBuddy));
            handlers.Add(Incoming.SearchFriend, new StaticRequestHandler(SharedPacketLib.SearchHabbo));
            handlers.Add(Incoming.SendInstantMessenger, new StaticRequestHandler(SharedPacketLib.SendInstantMessenger));
            handlers.Add(Incoming.AcceptRequest, new StaticRequestHandler(SharedPacketLib.AcceptRequest));
            handlers.Add(Incoming.DeclineRequest, new StaticRequestHandler(SharedPacketLib.DeclineRequest));
            handlers.Add(Incoming.FriendRequest, new StaticRequestHandler(SharedPacketLib.RequestBuddy));
            handlers.Add(Incoming.FollowFriend, new StaticRequestHandler(SharedPacketLib.FollowBuddy));
            handlers.Add(Incoming.InviteFriendsToMyRoom, new StaticRequestHandler(SharedPacketLib.SendInstantInvite));
            handlers.Add(Incoming.AddFavourite, new StaticRequestHandler(SharedPacketLib.AddFavorite));
            handlers.Add(Incoming.RemoveFavourite, new StaticRequestHandler(SharedPacketLib.RemoveFavorite));
            handlers.Add(Incoming.GoToHotelView, new StaticRequestHandler(SharedPacketLib.GoToHotelView));
            handlers.Add(Incoming.LoadCategorys, new StaticRequestHandler(SharedPacketLib.GetFlatCats));
            handlers.Add(Incoming.LoadFeaturedRooms, new StaticRequestHandler(SharedPacketLib.GetPubs));
            handlers.Add(Incoming.LoadAllRooms, new StaticRequestHandler(SharedPacketLib.GetPopularRooms));
            handlers.Add(Incoming.HighRatedRooms, new StaticRequestHandler(SharedPacketLib.GetHighRatedRooms));
            handlers.Add(Incoming.RoomsOfMyFriends, new StaticRequestHandler(SharedPacketLib.GetFriendsRooms));
            handlers.Add(Incoming.RoomsWhereMyFriends, new StaticRequestHandler(SharedPacketLib.GetRoomsWithFriends));
            handlers.Add(Incoming.LoadMyRooms, new StaticRequestHandler(SharedPacketLib.GetOwnRooms));
            handlers.Add(Incoming.MyFavs, new StaticRequestHandler(SharedPacketLib.GetFavoriteRooms));
            handlers.Add(Incoming.RecentRooms, new StaticRequestHandler(SharedPacketLib.GetRecentRooms));
            handlers.Add(Incoming.LoadPopularTags, new StaticRequestHandler(SharedPacketLib.GetPopularTags));
            handlers.Add(Incoming.SearchRoomByName, new StaticRequestHandler(SharedPacketLib.PerformSearch));
            handlers.Add(Incoming.LoadHeightMap, new StaticRequestHandler(SharedPacketLib.GetRoomData2));
            handlers.Add(Incoming.AddUserToRoom, new StaticRequestHandler(SharedPacketLib.GetRoomData3));
            handlers.Add(Incoming.AddUserToRoom2, new StaticRequestHandler(SharedPacketLib.GetRoomData3));
            handlers.Add(Incoming.Talk, new StaticRequestHandler(SharedPacketLib.Talk));
            handlers.Add(Incoming.Shout, new StaticRequestHandler(SharedPacketLib.Shout));
            handlers.Add(Incoming.Whisp, new StaticRequestHandler(SharedPacketLib.Whisper));
            handlers.Add(Incoming.Move, new StaticRequestHandler(SharedPacketLib.Move));
            handlers.Add(Incoming.CanCreateRoom, new StaticRequestHandler(SharedPacketLib.CanCreateRoom));
            handlers.Add(Incoming.CreateRoom, new StaticRequestHandler(SharedPacketLib.CreateRoom));
            handlers.Add(Incoming.LoadFirstRoomData, new StaticRequestHandler(SharedPacketLib.enterOnRoom));
            handlers.Add(Incoming.GetRoomData, new StaticRequestHandler(SharedPacketLib.GetRoomEditData));
            handlers.Add(Incoming.SaveRoomData, new StaticRequestHandler(SharedPacketLib.SaveRoomData));
            handlers.Add(Incoming.GiveRights, new StaticRequestHandler(SharedPacketLib.GiveRights));
            handlers.Add(Incoming.RemoveRightsFrom, new StaticRequestHandler(SharedPacketLib.TakeRights));
            handlers.Add(Incoming.RemoveAllRights, new StaticRequestHandler(SharedPacketLib.TakeAllRights));
            handlers.Add(Incoming.KickUserOfRoom, new StaticRequestHandler(SharedPacketLib.KickUser));
            handlers.Add(Incoming.BanUserOfRoom, new StaticRequestHandler(SharedPacketLib.BanUser));
            handlers.Add(Incoming.StartTrade, new StaticRequestHandler(SharedPacketLib.InitTrade));
            handlers.Add(Incoming.SetHome, new StaticRequestHandler(SharedPacketLib.SetHomeRoom));
            handlers.Add(Incoming.RemoveRoom, new StaticRequestHandler(SharedPacketLib.DeleteRoom));
            handlers.Add(Incoming.LookTo, new StaticRequestHandler(SharedPacketLib.LookAt));
            handlers.Add(Incoming.StartTyping, new StaticRequestHandler(SharedPacketLib.StartTyping));
            handlers.Add(Incoming.StopTyping, new StaticRequestHandler(SharedPacketLib.StopTyping));
            handlers.Add(Incoming.IgnoreUser, new StaticRequestHandler(SharedPacketLib.IgnoreUser));
            handlers.Add(Incoming.UnignoreUser, new StaticRequestHandler(SharedPacketLib.UnignoreUser));
            handlers.Add(Incoming.ApplyAction, new StaticRequestHandler(SharedPacketLib.Wave));
            handlers.Add(Incoming.ApplySign, new StaticRequestHandler(SharedPacketLib.Sign));
            handlers.Add(Incoming.Sit, new StaticRequestHandler(SharedPacketLib.Sit));
            handlers.Add(Incoming.GetUserTags, new StaticRequestHandler(SharedPacketLib.GetUserTags));
            handlers.Add(Incoming.GetUserBadges, new StaticRequestHandler(SharedPacketLib.GetUserBadges));
            handlers.Add(Incoming.GiveRoomScore, new StaticRequestHandler(SharedPacketLib.RateRoom));
            handlers.Add(Incoming.ApplyDance, new StaticRequestHandler(SharedPacketLib.Dance));
            handlers.Add(Incoming.RemoveHanditem, new StaticRequestHandler(SharedPacketLib.RemoveHanditem));
            handlers.Add(Incoming.GiveObject, new StaticRequestHandler(SharedPacketLib.GiveHanditem));
            handlers.Add(Incoming.AnswerDoorBell, new StaticRequestHandler(SharedPacketLib.AnswerDoorbell));
            handlers.Add(Incoming.ReqLoadByDoorBell, new StaticRequestHandler(SharedPacketLib.ReqLoadRoomForUser));
            handlers.Add(Incoming.ApplySpace, new StaticRequestHandler(SharedPacketLib.ApplyRoomEffect));
            handlers.Add(Incoming.AddFloorItem, new StaticRequestHandler(SharedPacketLib.PlaceItem));
            handlers.Add(Incoming.PickupItem, new StaticRequestHandler(SharedPacketLib.TakeItem));
            handlers.Add(Incoming.MoveOrRotate, new StaticRequestHandler(SharedPacketLib.MoveItem));
            handlers.Add(Incoming.MoveWall, new StaticRequestHandler(SharedPacketLib.MoveWallItem));
            handlers.Add(Incoming.HandleItem, new StaticRequestHandler(SharedPacketLib.TriggerItem));
            handlers.Add(Incoming.OpenDice, new StaticRequestHandler(SharedPacketLib.TriggerItem));
            handlers.Add(Incoming.RunDice, new StaticRequestHandler(SharedPacketLib.TriggerItemDiceSpecial));
            handlers.Add(Incoming.HandleWallItem, new StaticRequestHandler(SharedPacketLib.TriggerItem));
            handlers.Add(Incoming.OpenPostIt, new StaticRequestHandler(SharedPacketLib.OpenPostit));
            handlers.Add(Incoming.SavePostIt, new StaticRequestHandler(SharedPacketLib.SavePostit));
            handlers.Add(Incoming.DeletePostIt, new StaticRequestHandler(SharedPacketLib.DeletePostit));
            handlers.Add(Incoming.OpenGift, new StaticRequestHandler(SharedPacketLib.OpenPresent));
            handlers.Add(Incoming.StartMoodlight, new StaticRequestHandler(SharedPacketLib.GetMoodlight));
            handlers.Add(Incoming.ApplyMoodlightChanges, new StaticRequestHandler(SharedPacketLib.UpdateMoodlight));
            handlers.Add(Incoming.TurnOnMoodlight, new StaticRequestHandler(SharedPacketLib.SwitchMoodlightStatus));
            handlers.Add(Incoming.SendOffer, new StaticRequestHandler(SharedPacketLib.OfferTradeItem));
            handlers.Add(Incoming.CancelOffer, new StaticRequestHandler(SharedPacketLib.TakeBackTradeItem));
            handlers.Add(Incoming.CancelTrade, new StaticRequestHandler(SharedPacketLib.StopTrade));
            handlers.Add(Incoming.AcceptTrade, new StaticRequestHandler(SharedPacketLib.AcceptTrade));
            handlers.Add(Incoming.UnacceptTrade, new StaticRequestHandler(SharedPacketLib.UnacceptTrade));
            handlers.Add(Incoming.ConfirmTrade, new StaticRequestHandler(SharedPacketLib.CompleteTrade));
            handlers.Add(Incoming.SendRespects, new StaticRequestHandler(SharedPacketLib.GiveRespect));
            handlers.Add(Incoming.StartEffect, new StaticRequestHandler(SharedPacketLib.ApplyEffect));
            handlers.Add(Incoming.EnableEffect, new StaticRequestHandler(SharedPacketLib.EnableEffect));
            handlers.Add(Incoming.RedeemExchangeFurni, new StaticRequestHandler(SharedPacketLib.RedeemExchangeFurni));
            handlers.Add(Incoming.PlacePet, new StaticRequestHandler(SharedPacketLib.PlacePet));
            handlers.Add(Incoming.PetInfo, new StaticRequestHandler(SharedPacketLib.GetPetInfo));
            handlers.Add(Incoming.PickupPet, new StaticRequestHandler(SharedPacketLib.PickUpPet));
            handlers.Add(Incoming.RespetPet, new StaticRequestHandler(SharedPacketLib.RespectPet));
            handlers.Add(Incoming.AddPostIt, new StaticRequestHandler(SharedPacketLib.PlacePostIt));
            handlers.Add(Incoming.AddSaddleToPet, new StaticRequestHandler(SharedPacketLib.AddSaddle));
            handlers.Add(Incoming.RemoveSaddle, new StaticRequestHandler(SharedPacketLib.RemoveSaddle));
            handlers.Add(Incoming.MountOnPet, new StaticRequestHandler(SharedPacketLib.Ride));
            handlers.Add(Incoming.SaveWiredEffect, new StaticRequestHandler(SharedPacketLib.SaveWired));
            handlers.Add(Incoming.SaveWiredTrigger, new StaticRequestHandler(SharedPacketLib.SaveWired));
            handlers.Add(Incoming.UserInformation, new StaticRequestHandler(SharedPacketLib.GetUserInfo));
            handlers.Add(Incoming.LoadProfile, new StaticRequestHandler(SharedPacketLib.LoadProfile));
            handlers.Add(Incoming.SerializeClub, new StaticRequestHandler(SharedPacketLib.GetSubscriptionData));
            handlers.Add(Incoming.BadgesInventary, new StaticRequestHandler(SharedPacketLib.GetBadges));
            handlers.Add(Incoming.ApplyBadge, new StaticRequestHandler(SharedPacketLib.UpdateBadges));
            handlers.Add(Incoming.OpenAchievements, new StaticRequestHandler(SharedPacketLib.GetAchievements));
            handlers.Add(Incoming.ChangeLook, new StaticRequestHandler(SharedPacketLib.ChangeLook));
            handlers.Add(Incoming.ChangeMotto, new StaticRequestHandler(SharedPacketLib.ChangeMotto));
            handlers.Add(Incoming.GetWardrobe, new StaticRequestHandler(SharedPacketLib.GetWardrobe));
            handlers.Add(Incoming.SaveWardrobe, new StaticRequestHandler(SharedPacketLib.SaveWardrobe));
            handlers.Add(Incoming.OpenInventory, new StaticRequestHandler(SharedPacketLib.GetInventory));
            handlers.Add(Incoming.PetInventary, new StaticRequestHandler(SharedPacketLib.GetPetsInventory));
            handlers.Add(Incoming.TrainPet, new StaticRequestHandler(SharedPacketLib.GetTrainerPanel));
            handlers.Add(Incoming.SaveConditional, new StaticRequestHandler(SharedPacketLib.SaveWiredCondition));
            handlers.Add(Incoming.OpenQuests, new StaticRequestHandler(SharedPacketLib.OpenQuests));
            handlers.Add(Incoming.ActiveQuests, new StaticRequestHandler(SharedPacketLib.StartQuest));
            handlers.Add(Incoming.CancelQuests, new StaticRequestHandler(SharedPacketLib.StopQuest));
            handlers.Add(Incoming.ActiveEndedQuest, new StaticRequestHandler(SharedPacketLib.StartEndedQuest));
            handlers.Add(Incoming.CheckNameChange, new StaticRequestHandler(SharedPacketLib.CheckNameChange));
            handlers.Add(Incoming.SaveNameChange, new StaticRequestHandler(SharedPacketLib.SaveNameChange));
            handlers.Add(Incoming.MarketplaceCanSell, new StaticRequestHandler(SharedPacketLib.MarketplaceCanSell));
            handlers.Add(Incoming.MarketplacePostItem, new StaticRequestHandler(SharedPacketLib.MarketplacePostItem));
            handlers.Add(Incoming.MarketplaceGetOwnOffers, new StaticRequestHandler(SharedPacketLib.MarketplaceGetOwnOffers));
            handlers.Add(Incoming.MarketplaceTakeBack, new StaticRequestHandler(SharedPacketLib.MarketplaceTakeBack));
            handlers.Add(Incoming.MarketplaceClaimCredits, new StaticRequestHandler(SharedPacketLib.MarketplaceClaimCredits));
            handlers.Add(Incoming.MarketplaceGetOffers, new StaticRequestHandler(SharedPacketLib.MarketplaceGetOffers));
            handlers.Add(Incoming.MarketplacePurchase, new StaticRequestHandler(SharedPacketLib.MarketplacePurchase));
            handlers.Add(Incoming.ListenPreview, new StaticRequestHandler(SharedPacketLib.GetMusicData));
            handlers.Add(Incoming.LoadInvSongs, new StaticRequestHandler(SharedPacketLib.LoadInvSongs));
            handlers.Add(Incoming.LoadJukeSongs, new StaticRequestHandler(SharedPacketLib.LoadJukeSongs));
            handlers.Add(Incoming.AddNewCdToJuke, new StaticRequestHandler(SharedPacketLib.AddNewCdToJuke));
            handlers.Add(Incoming.RemoveCdToJuke, new StaticRequestHandler(SharedPacketLib.RemoveCdToJuke));
            handlers.Add(Incoming.InitStream, new StaticRequestHandler(SharedPacketLib.Stream));
            handlers.Add(Incoming.CreateStream, new StaticRequestHandler(SharedPacketLib.CreateStream));
            handlers.Add(Incoming.StreamLike, new StaticRequestHandler(SharedPacketLib.StreamLike));
            handlers.Add(Incoming.SearchStream, new StaticRequestHandler(SharedPacketLib.Stream));
            handlers.Add(Incoming.OpenGuildPage, new StaticRequestHandler(SharedPacketLib.OpenGuildPage));
            handlers.Add(Incoming.BuyGroup, new StaticRequestHandler(SharedPacketLib.BuyGroup));
            handlers.Add(Incoming.EndConfirmBuy, new StaticRequestHandler(SharedPacketLib.EndConfirmBuy));
            handlers.Add(Incoming.EditGuild, new StaticRequestHandler(SharedPacketLib.EditGuild));
            handlers.Add(Incoming.EditIdentidad, new StaticRequestHandler(SharedPacketLib.EditIdentidad));
            handlers.Add(Incoming.EditPlaca, new StaticRequestHandler(SharedPacketLib.EditPlaca));
            handlers.Add(Incoming.EditColores, new StaticRequestHandler(SharedPacketLib.EditColores));
            handlers.Add(Incoming.EditAjustes, new StaticRequestHandler(SharedPacketLib.EditAjustes));
            handlers.Add(Incoming.PopularGuilds, new StaticRequestHandler(SharedPacketLib.PopularGuilds));
            handlers.Add(Incoming.ExitGuild, new StaticRequestHandler(SharedPacketLib.ExitGuild));
            handlers.Add(Incoming.SendRequestGuild, new StaticRequestHandler(SharedPacketLib.SendRequestGuild));
            handlers.Add(Incoming.LoadMembersPetitions, new StaticRequestHandler(SharedPacketLib.LoadMembersPetitions));
            handlers.Add(Incoming.RejectGuildMember, new StaticRequestHandler(SharedPacketLib.RejectGuildMember));
            handlers.Add(Incoming.AcceptMember, new StaticRequestHandler(SharedPacketLib.AcceptMember));
            handlers.Add(Incoming.UpdateUserToRankGuild, new StaticRequestHandler(SharedPacketLib.UpdateUserToRankGuild));
            handlers.Add(Incoming.UpdateUserFromRankGuild, new StaticRequestHandler(SharedPacketLib.UpdateUserToRankGuild));
            handlers.Add(Incoming.SendFurniGuild, new StaticRequestHandler(SharedPacketLib.SendFurniGuild));
            handlers.Add(Incoming.GetGuildFavorite, new StaticRequestHandler(SharedPacketLib.GetGuildFavorite));
            handlers.Add(Incoming.RemoveGuildFavorite, new StaticRequestHandler(SharedPacketLib.RemoveGuildFavorite));
            handlers.Add(Incoming.GetGames, new StaticRequestHandler(SharedPacketLib.GetGames));
            handlers.Add(Incoming.GetGame, new StaticRequestHandler(SharedPacketLib.GetGame));
            handlers.Add(Incoming.StartPanel, new StaticRequestHandler(SharedPacketLib.StartPanel));
            handlers.Add(Incoming.Game2LeaveGameMessageComposer, new StaticRequestHandler(SharedPacketLib.LeaveGame));
            handlers.Add(Incoming.Game2GameChatMessageComposer, new StaticRequestHandler(SharedPacketLib.TalkGame));
            handlers.Add(Incoming.Game2LoadStageReadyMessageComposer, new StaticRequestHandler(SharedPacketLib.stageReadyMessage));
            handlers.Add(Incoming.Game2SetUserMoveTargetMessageComposer, new StaticRequestHandler(SharedPacketLib.WalkGame));
            handlers.Add(Incoming.Mannequinshit, new StaticRequestHandler(SharedPacketLib.SaveMannequin)); 
            handlers.Add(Incoming.EjectFurni, new StaticRequestHandler(SharedPacketLib.EjectFurni));
            handlers.Add(Incoming.volumeControl, new StaticRequestHandler(SharedPacketLib.volumeControl));
            handlers.Add(Incoming.unknown, new StaticRequestHandler(SharedPacketLib.unknown));

            Logging.WriteLine("Logged " + handlers.Count + " packet handler(s)!");
        }

        private delegate void StaticRequestHandler(GameClientMessageHandler handler);
    }
}

UserDataFactory.cs
Code:
namespace Butterfly.HabboHotel.Users.UserDataManagement
{
    using Butterfly;
    using Butterfly.HabboHotel.Achievements;
    using Butterfly.HabboHotel.Catalogs;
    using Butterfly.HabboHotel.Habbo.Users;
    using Butterfly.HabboHotel.Items;
    using Butterfly.HabboHotel.Pets;
    using Butterfly.HabboHotel.Rooms;
    using Butterfly.HabboHotel.Users.Authenticator;
    using Butterfly.HabboHotel.Users.Badges;
    using Butterfly.HabboHotel.Users.Inventory;
    using Butterfly.HabboHotel.Users.Messenger;
    using Butterfly.HabboHotel.Users.Subscriptions;
    using Database_Manager.Database;
    using Database_Manager.Database.Session_Details.Interfaces;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Runtime.InteropServices;

    internal class UserDataFactory
    {
        internal static UserData GetUserData(int UserId)
        {
            DataRow row;
            DataRow group = null;
            uint num;
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                adapter.setQuery("SELECT users.* FROM users WHERE users.id = @id");
                adapter.addParameter("id", UserId);
                row = adapter.getRow();
                if (row == null)
                {
                    return null;
                }
                num = Convert.ToUInt32(row["id"]);
                if (ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num) != null)
                {
                    return null;
                }
                if (ButterflyEnvironment.groupsEnabled)
                {
                    adapter.setQuery("SELECT groups_memberships.*, groups_details.* FROM groups_memberships LEFT JOIN groups_details ON groups_memberships.groupid = groups_details.id WHERE groups_memberships.userid = " + num + " AND groups_memberships.is_current = '1'");
                    group = adapter.getRow();
                }
            }
            Dictionary<string, UserAchievement> achievements = new Dictionary<string, UserAchievement>();
            List<uint> favouritedRooms = new List<uint>();
            List<uint> ignores = new List<uint>();
            List<string> tags = new List<string>();
            Dictionary<string, Subscription> subscriptions = new Dictionary<string, Subscription>();
            List<Badge> badges = new List<Badge>();
            List<UserItem> inventory = new List<UserItem>();
            List<AvatarEffect> effects = new List<AvatarEffect>();
            Dictionary<uint, MessengerBuddy> friends = new Dictionary<uint, MessengerBuddy>();
            string str = (string) row["username"];
            Dictionary<uint, MessengerRequest> requests = new Dictionary<uint, MessengerRequest>();
            List<RoomData> rooms = new List<RoomData>();
            Dictionary<uint, Pet> pets = new Dictionary<uint, Pet>();
            Dictionary<uint, int> quests = new Dictionary<uint, int>();
            Hashtable inventorySongs = new Hashtable();
            Habbo user = HabboFactory.GenerateHabbo(row, group);
            row = null;
            return new UserData(num, achievements, favouritedRooms, ignores, tags, subscriptions, badges, inventory, effects, friends, requests, rooms, pets, quests, inventorySongs, user);
        }

        internal static UserData GetUserData(string sessionTicket, string ip, out byte errorCode)
        {
            DataRow row;
            DataTable table;
            DataTable table2;
            DataTable table3;
            DataTable table4;
            DataTable table5;
            DataTable table6;
            DataTable table7;
            DataTable table8;
            DataTable table9;
            DataTable table10;
            DataTable table11;
            DataTable table12;
            DataTable table13;
            DataRow group = null;
            uint num;
            using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (ButterflyEnvironment.useSSO)
                {
                    adapter.setQuery("SELECT * " +
                                        "FROM users " +
                                        "WHERE auth_ticket = @sso ");
                }
                else
                {
                    adapter.setQuery("SELECT * " +
                                        "FROM users " +
                                        "WHERE auth_ticket = @sso ");
                }

                adapter.addParameter("sso", sessionTicket);

                row = adapter.getRow();     
                if (row == null)
                {
                    errorCode = 1;
                    return null;
                }
                num = Convert.ToUInt32(row["id"]);
                if (ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num) != null)
                {
                    errorCode = 2;
                    return null;
                }
                string str = (string) row["lastdailycredits"];
                string str2 = DateTime.Today.ToString("MM/dd");
                if (str != str2)
                {
                    adapter.runFastQuery(string.Concat(new object[] { "UPDATE users SET credits = credits + 3000, daily_respect_points = 3, lastdailycredits = '", str2, "' WHERE id = ", num }));
                    row["credits"] = ((int) row["credits"]) + 0xbb8;
                }
                adapter.setQuery("SELECT * FROM user_achievement WHERE userid = " + num);
                table = adapter.getTable();
                adapter.setQuery("SELECT room_id FROM user_favorites WHERE user_id = " + num);
                table2 = adapter.getTable();
                adapter.setQuery("SELECT ignore_id FROM user_ignores WHERE user_id = " + num);
                table3 = adapter.getTable();
                adapter.setQuery("SELECT tag FROM user_tags WHERE user_id = " + num);
                table4 = adapter.getTable();
                adapter.setQuery("SELECT * FROM user_subscriptions WHERE user_id = " + num);
                table5 = adapter.getTable();
                adapter.setQuery("SELECT * FROM user_badges WHERE user_id = " + num);
                table6 = adapter.getTable();
                if (adapter.dbType == DatabaseType.MySQL)
                {
                    adapter.setQuery("CALL getuseritems(" + num + ")");
                }
                else
                {
                    adapter.setQuery("EXECUTE getuseritems " + num);
                }
                table7 = adapter.getTable();
                adapter.setQuery("SELECT * FROM user_effects WHERE user_id =  " + num);
                table8 = adapter.getTable();
                adapter.setQuery(string.Concat(new object[] { "SELECT users.id,users.username,users.motto,users.look,users.last_online FROM users JOIN messenger_friendships ON users.id = messenger_friendships.sender WHERE messenger_friendships.receiver = ", num, " UNION ALL SELECT users.id,users.username,users.motto,users.look,users.last_online FROM users JOIN messenger_friendships ON users.id = messenger_friendships.receiver WHERE messenger_friendships.sender = ", num, " LIMIT 500" }));
                table9 = adapter.getTable();
                adapter.setQuery("SELECT messenger_requests.sender,messenger_requests.receiver,users.username FROM users JOIN messenger_requests ON users.id = messenger_requests.sender WHERE messenger_requests.receiver = " + num + " LIMIT 150");
                table10 = adapter.getTable();
                adapter.setQuery("SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE owner = @name");
                adapter.addParameter("name", (string) row["username"]);
                table11 = adapter.getTable();
                adapter.setQuery("SELECT * FROM user_pets WHERE user_id = " + num + " AND room_id = 0");
                table12 = adapter.getTable();
                adapter.setQuery("SELECT * FROM user_quests WHERE user_id = " + num);
                table13 = adapter.getTable();
                if (ButterflyEnvironment.groupsEnabled)
                {
                    adapter.setQuery("SELECT groups_memberships.*, groups_details.* FROM groups_memberships LEFT JOIN groups_details ON groups_memberships.groupid = groups_details.id WHERE groups_memberships.userid = " + num + " AND groups_memberships.is_current = '1'");
                    group = adapter.getRow();
                }
                adapter.setQuery(string.Concat(new object[] { "UPDATE users SET ip_last = @ip WHERE id = ", num, "; UPDATE user_info SET login_timestamp = '", ButterflyEnvironment.GetUnixTimestamp(), "' WHERE user_id = ", num, " ; " }));
                adapter.addParameter("ip", ip);
                adapter.runQuery();
                if (adapter.dbType == DatabaseType.MySQL)
                {
                    adapter.runFastQuery("REPLACE INTO user_online VALUES (" + num + ")");
                }
                else
                {
                    adapter.runFastQuery(string.Concat(new object[] { "IF NOT EXISTS (SELECT userid FROM user_online WHERE userid = ", num, ") INSERT INTO user_online VALUES (", num, ")" }));
                }
            }
            Dictionary<string, UserAchievement> achievements = new Dictionary<string, UserAchievement>();
            foreach (DataRow row3 in table.Rows)
            {
                string achievementGroup = (string) row3["groupname"];
                int level = (int) row3["level"];
                int progress = (int) row3["progress"];
                UserAchievement achievement = new UserAchievement(achievementGroup, level, progress);
                achievements.Add(achievementGroup, achievement);
            }
            List<uint> favouritedRooms = new List<uint>();
            foreach (DataRow row3 in table2.Rows)
            {
                uint item = Convert.ToUInt32(row3["room_id"]);
                favouritedRooms.Add(item);
            }
            List<uint> ignores = new List<uint>();
            foreach (DataRow row3 in table3.Rows)
            {
                uint num5 = Convert.ToUInt32(row3["ignore_id"]);
                ignores.Add(num5);
            }
            List<string> tags = new List<string>();
            foreach (DataRow row3 in table4.Rows)
            {
                string str4 = (string) row3["tag"];
                tags.Add(str4);
            }
            Dictionary<string, Subscription> subscriptions = new Dictionary<string, Subscription>();
            foreach (DataRow row3 in table5.Rows)
            {
                string key = (string) row3["subscription_id"];
                int timeExpire = (int) row3["timestamp_expire"];
                subscriptions.Add(key, new Subscription(key, timeExpire));
            }
            List<Badge> badges = new List<Badge>();
            foreach (DataRow row3 in table6.Rows)
            {
                string code = (string) row3["badge_id"];
                int slot = (int) row3["badge_slot"];
                badges.Add(new Badge(code, slot));
            }
            List<UserItem> inventory = new List<UserItem>();
            foreach (DataRow row3 in table7.Rows)
            {
                string str7;
                uint id = Convert.ToUInt32(row3[0]);
                uint baseItem = Convert.ToUInt32(row3[1]);
                if (!DBNull.Value.Equals(row3[2]))
                {
                    str7 = (string) row3[2];
                }
                else
                {
                    str7 = string.Empty;
                }
                uint rareid = Convert.ToUInt32(row3[3]);
                string groupstring = (string) row3[4];
                inventory.Add(new UserItem(id, baseItem, str7, rareid, groupstring, num));
            }
            List<AvatarEffect> effects = new List<AvatarEffect>();
            foreach (DataRow row3 in table8.Rows)
            {
                int effectId = (int) row3["effect_id"];
                int totalDuration = (int) row3["total_duration"];
                bool activated = ButterflyEnvironment.EnumToBool((string) row3["is_activated"]);
                double activateTimestamp = (double) row3["activated_stamp"];
                effects.Add(new AvatarEffect(effectId, totalDuration, activated, activateTimestamp));
            }
            Dictionary<uint, MessengerBuddy> friends = new Dictionary<uint, MessengerBuddy>();
            string str9 = (string) row["username"];
            foreach (DataRow row3 in table9.Rows)
            {
                uint num14 = Convert.ToUInt32(row3["id"]);
                string pUsername = (string) row3["username"];
                string pLook = (string) row3["look"];
                string pMotto = (string) row3["motto"];
                string pLastOnline = (string) row3["last_online"];
                if ((num14 != num) && !friends.ContainsKey(num14))
                {
                    friends.Add(num14, new MessengerBuddy(num14, pUsername, pLook, pMotto, pLastOnline));
                }
            }
            Dictionary<uint, MessengerRequest> requests = new Dictionary<uint, MessengerRequest>();
            foreach (DataRow row3 in table10.Rows)
            {
                uint num15 = Convert.ToUInt32(row3["sender"]);
                uint num16 = Convert.ToUInt32(row3["receiver"]);
                string str14 = (string) row3["username"];
                if (num15 != num)
                {
                    if (!requests.ContainsKey(num15))
                    {
                        requests.Add(num15, new MessengerRequest(num, num15, str14));
                    }
                }
                else if (!requests.ContainsKey(num16))
                {
                    requests.Add(num16, new MessengerRequest(num, num16, str14));
                }
            }
            List<RoomData> rooms = new List<RoomData>();
            foreach (DataRow row3 in table11.Rows)
            {
                uint roomId = Convert.ToUInt32(row3["id"]);
                rooms.Add(ButterflyEnvironment.GetGame().GetRoomManager().FetchRoomData(roomId, row3));
            }
            Dictionary<uint, Pet> pets = new Dictionary<uint, Pet>();
            foreach (DataRow row3 in table12.Rows)
            {
                Pet pet = Catalog.GeneratePetFromRow(row3);
                pets.Add(pet.PetId, pet);
            }
            Dictionary<uint, int> quests = new Dictionary<uint, int>();
            foreach (DataRow row3 in table13.Rows)
            {
                uint num18 = Convert.ToUInt32(row3["quest_id"]);
                int num19 = (int) row3["progress"];
                quests.Add(num18, num19);
            }
            Hashtable inventorySongs = new Hashtable();
            Habbo user = HabboFactory.GenerateHabbo(row, group);
            row = null;
            table = null;
            table2 = null;
            table3 = null;
            table4 = null;
            table5 = null;
            table6 = null;
            table7 = null;
            table8 = null;
            table9 = null;
            table10 = null;
            table11 = null;
            table12 = null;
            errorCode = 0;
            return new UserData(num, achievements, favouritedRooms, ignores, tags, subscriptions, badges, inventory, effects, friends, requests, rooms, pets, quests, inventorySongs, user);
        }
    }
}

UserItem.cs
Code:
namespace Butterfly.HabboHotel.Items
{
    using Butterfly;
    using Butterfly.HabboHotel.Catalogs;
    using Butterfly.HabboHotel.Habbo.Guilds;
    using Butterfly.Messages;
    using System;
    using System.Collections.Generic;

    internal class UserItem
    {
        internal uint BaseItem;
        internal string ExtraData;
        internal string Group_data;
        internal List<string> Guilds_Data = new List<string>();
        internal uint Id;
        internal bool isWallItem;
        private Item mBaseItem;
        internal uint RareId;
        internal uint placedBy;
        
        internal UserItem(uint Id, uint BaseItem, string ExtraData, uint rareid, string groupstring, uint placedBy)
        {
            this.Id = Id;
            this.placedBy = placedBy;
            this.BaseItem = BaseItem;
            this.ExtraData = ExtraData;
            this.mBaseItem = this.GetBaseItem();
            if (this.mBaseItem == null)
            {
            }
            this.isWallItem = this.mBaseItem.Type == 'i';
            this.RareId = rareid;
            this.Group_data = groupstring;

            if (this.Group_data.Length > 0)
            {
                foreach (string str in this.Group_data.Split(new char[] { ';' }))
                {
                    this.Guilds_Data.Add(str);
                }
            }
        }

        internal Item GetBaseItem()
        {
            return ButterflyEnvironment.GetGame().GetItemManager().GetItem(this.BaseItem);
        }

        internal CatalogItem GetRareCatalogItem(uint ItemId)
        {
            return ButterflyEnvironment.GetGame().GetCatalog().RaresItems[ItemId];
        }

        internal void SerializeFloor(ServerMessage Message, bool Inventory)
        {
            Message.AppendInt32(this.Id);
            Message.AppendString(this.mBaseItem.Type.ToString().ToUpper());
            Message.AppendInt32(this.Id);
            Message.AppendInt32(this.GetBaseItem().SpriteId);
            if (this.mBaseItem.AllowGroupItem)
            {
                Message.AppendInt32(0x11);
            }
            else if (this.mBaseItem.InteractionType == InteractionType.musicdisc)
            {
                Message.AppendInt32(8);
            }
            else
            {
                Message.AppendInt32(1);
            }
            if (this.RareId > 0)
            {
                Message.AppendString("");
                Message.AppendBoolean(true);
                Message.AppendBoolean(false);
            }
            else if (this.mBaseItem.AllowGroupItem)
            {
                try
                {
                    MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(int.Parse(this.Guilds_Data[0]));
                    if (guild == null)
                    {
                        Message.AppendInt32(0);
                    }
                    else
                    {
                        Message.AppendInt32(2);
                        Message.AppendInt32(5);
                        Message.AppendString("0");
                        Message.AppendString(guild.Id.ToString());
                        Message.AppendString(guild.Image);
                        Message.AppendString(this.Guilds_Data[1]);
                        Message.AppendString(this.Guilds_Data[2]);
                    }
                }
                catch
                {
                    Message.AppendInt32(0);
                }


            }
            else
            {
                Message.AppendInt32(0);
            }
            if (this.mBaseItem.InteractionType == InteractionType.musicdisc)
            {
                Message.AppendString("");
            }
            else if (!this.mBaseItem.AllowGroupItem)
            {
                Message.AppendString(this.ExtraData);
            }
            if (this.RareId > 0)
            {
                Message.AppendInt32(this.RareId);
                Message.AppendInt32(this.GetRareCatalogItem(this.BaseItem).LimitedStack);
            }
            Message.AppendBoolean(this.GetBaseItem().AllowRecycle);
            Message.AppendBoolean(this.GetBaseItem().AllowTrade);
            if (this.RareId > 0)
            {
                Message.AppendBoolean(false);
            }
            else
            {
                Message.AppendBoolean(this.GetBaseItem().AllowInventoryStack);
            }
            Message.AppendBoolean(Marketplace.CanSellItem(this));
            Message.AppendInt32(-1);
            Message.AppendString("");
            Message.AppendInt32(0);

            
        }


        internal void SerializeWall(ServerMessage Message, bool Inventory)
        {
            Message.AppendInt32(this.Id);
            Message.AppendString(this.mBaseItem.Type.ToString().ToUpper());
            Message.AppendInt32(this.Id);
            Message.AppendInt32(this.GetBaseItem().SpriteId);
            if (this.GetBaseItem().Name.Contains("a2"))
            {
                Message.AppendInt32(3);
            }
            else if (this.GetBaseItem().Name.Contains("wallpaper"))
            {
                Message.AppendInt32(2);
            }
            else if (this.GetBaseItem().Name.Contains("landscape"))
            {
                Message.AppendInt32(4);
            }
            else
            {
                Message.AppendInt32(1);
            }
            int i = 0;
            if ((this.GetBaseItem().InteractionType == InteractionType.gift) && this.ExtraData.Contains(Convert.ToChar(5).ToString()))
            {
                int num2 = int.Parse(this.ExtraData.Split(new char[] { '\x0005' })[1]);
                int num3 = int.Parse(this.ExtraData.Split(new char[] { '\x0005' })[2]);
                i = (num2 * 0x3e8) + num3;
            }
            Message.AppendInt32(i);
            Message.AppendString(this.ExtraData);
            Message.AppendBoolean(this.GetBaseItem().AllowRecycle);
            Message.AppendBoolean(this.GetBaseItem().AllowTrade);
            Message.AppendBoolean(this.GetBaseItem().AllowInventoryStack);
            Message.AppendBoolean(Marketplace.CanSellItem(this));
            Message.AppendInt32(-1);
        }
    }
}

I did try to make this as much as I possibly could into parts, couldn't go further than this, enjoy.
 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
Here is a little fix that will prevent DC when sending a pm to an offline user.

In GameClientMessageHandler find:

PHP:
internal void SendInstantMessenger()

Replace that whole method with:
PHP:
internal void SendInstantMessenger()
        {
            if (!ButterflyEnvironment.SystemMute)
            {
                uint toId = this.Request.PopWiredUInt();
                string message = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                Habbo habbo = ButterflyEnvironment.getHabboForId(toId);
                
                if ((this.Session.GetHabbo().GetMessenger() != null) && (habbo.GetClient() != null))
                {
                    this.Session.GetHabbo().GetMessenger().SendInstantMessage(toId, message);
                }
            }
        }
 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
Here is the fix to prevent people from picking up your furni by holding the ctrl key.

In room.cs find
PHP:
internal bool checkGroupRights(GameClient Session)

Replace the whole method with:
PHP:
internal bool checkGroupRights(GameClient Session)
        {
            try
            {

                if ((Session == null) || (Session.GetHabbo() == null))
                {
                    return false;
                }

                if (this.guildRoom != null)
                {
                    MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(this.guildRoom.Id);

                    if (!guild.Members.Contains((int)Session.GetHabbo().Id))
                    {
                        return false;
                    }

                    if ((guild.Members.Contains((int)Session.GetHabbo().Id)) && (guild.RightsType == 0))
                    {
                        return true;
                    }

                    if ((guild.Members.Contains((int)Session.GetHabbo().Id)) && (guild.GuildRanks[(int)Session.GetHabbo().Id] < 2) && (guild.RightsType == 1))
                    {
                        return true;
                    }
                }

                else return false;
            }

            catch (Exception exception)
            {
                Logging.HandleException(exception, "Room.CheckRights");
            }

            return false;
        }

In GameCientMessageHandler.cs find:
PHP:
internal void TakeItem()

Replace the method with this:
PHP:
internal void TakeItem()
        {
            int num = this.Request.PopWiredInt32();
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && (room.CheckRights(this.Session, true)))
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                
                if ((item != null) && (item.GetBaseItem().InteractionType != InteractionType.postit))
                {
                    room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                    this.Session.GetHabbo().GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, true, true, item.RareId, item.Guilds_Data_String, 0);
                    this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                }
            }
        }

In GameClientMessageHandle find:
PHP:
internal void EjectFurni()

Replace the whole method with:
PHP:
internal void EjectFurni()
        {
            try
            {
                int num = this.Request.PopWiredInt32();
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                if ((room != null) && ((room.CheckRights(this.Session, true)) || (room.checkGroupRights(this.Session))))
                {
                    RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());
                    Habbo habbo = ButterflyEnvironment.getHabboForId(item.placedBy);

                    if ((item != null) && (item.GetBaseItem().InteractionType != InteractionType.postit) && (item.placedBy != room.OwnerId) && (item.placedBy != 0))
                    {
                        if (habbo.GetClient() == null)
                        {
                            IQueryAdapter adapter;
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                if (adapter.dbType == DatabaseType.MSSQL)
                                {
                                    adapter.setQuery("DELETE FROM items_users WHERE item_id = " + item.Id);
                                    adapter.setQuery(string.Concat(new object[] { "INSERT INTO items_users VALUES (", item.Id, ",", item.placedBy, ")" }));
                                }
                                else
                                {
                                    adapter.runFastQuery(string.Concat(new object[] { "REPLACE INTO items_users VALUES (", item.Id, ",", item.placedBy, ")" }));
                                }
                            }

                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                        }

                        else
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                            room.GetRoomItemHandler().RemoveFurniture(habbo.GetClient(), item.Id);
                            habbo.GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, true, true, item.RareId, item.Guilds_Data_String, 0);
                            habbo.GetInventoryComponent().UpdateItems(false);
                        }
                    }
                }
            }

            catch (Exception exception)
            {
                Logging.HandleException(exception, "Room.CheckRights");
            }
        }

That should fix it.

The download in this thread has been updated with the above fixes
 
Last edited:
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
Here is another permissions related fix.

Make sure you use the above fix before this one.

This fix fixes 3 problems.
1. When you give someone right to your room and the place furni then they will be able to pick it up now.

2. When the room owner pick up the furni that belongs to someone else it will go to the furni owners inventory.

3. When you are using an older database with existing fruni then the PlacedBy column will have a "0" meaning you would not be able to pick it up. after this fix you can. the furni will now belong to the room owner.

In GameClientMessageHandler.cs find
PHP:
internal void TakeItem()

Replace that method with this.
PHP:
internal void TakeItem()
        {
            try
            {
                int num = this.Request.PopWiredInt32();
                Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                RoomItem item = room.GetRoomItemHandler().GetItem(this.Request.PopWiredUInt());

                if ((room != null) && ((room.CheckRights(this.Session, true)) || (item.placedBy == this.Session.GetHabbo().Id)))
                {
                    if (item.placedBy == 0) item.placedBy = this.Session.GetHabbo().Id;

                    Habbo habbo = ButterflyEnvironment.getHabboForId(item.placedBy);

                    if ((item != null) && (item.GetBaseItem().InteractionType != InteractionType.postit))
                    {
                        if (habbo.GetClient() == null)
                        {
                            IQueryAdapter adapter;
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                if (adapter.dbType == DatabaseType.MSSQL)
                                {
                                    adapter.setQuery("DELETE FROM items_users WHERE item_id = " + item.Id);
                                    adapter.setQuery(string.Concat(new object[] { "INSERT INTO items_users VALUES (", item.Id, ",", item.placedBy, ")" }));
                                }
                                else
                                {
                                    adapter.runFastQuery(string.Concat(new object[] { "REPLACE INTO items_users VALUES (", item.Id, ",", item.placedBy, ")" }));
                                }
                            }

                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                        }

                        else
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                            room.GetRoomItemHandler().RemoveFurniture(habbo.GetClient(), item.Id);
                            habbo.GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, true, true, item.RareId, item.Guilds_Data_String, 0);
                            habbo.GetInventoryComponent().UpdateItems(false);
                        }
                    }
                }
            }
            
            catch 
            {
                
            }
        }


The download has been updated with this fix.



EDIT:
You should add a fix for someone talking to a friend who just deleted him :)

Here is the fix that prevents DC when talking to a ex-friend through the messenger.

In GameClientMessageHandler.cs find:
PHP:
internal void SendInstantMessenger()

Replace that method with:
PHP:
internal void SendInstantMessenger()
        {
            try
            {
                if (!ButterflyEnvironment.SystemMute)
                {
                    uint toId = this.Request.PopWiredUInt();
                    string message = ButterflyEnvironment.FilterInjectionChars(this.Request.PopFixedString());
                    Habbo habbo = ButterflyEnvironment.getHabboForId(toId);

                    if ((this.Session.GetHabbo().GetMessenger() != null) && (habbo.GetClient() != null))
                    {
                        if (this.Session.GetHabbo().GetMessenger().FriendshipExists(toId))
                        {
                            this.Session.GetHabbo().GetMessenger().SendInstantMessage(toId, message);
                        }
                        else this.Session.SendNotif("You are no longer friends with " + habbo.Username + ".");
                    }
                }
            }
            catch 
            {
            
            }
        }
 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
i found the reason of this error:
PHP:
Error in packet [1923] BODY: [0][0][0]?[0][0][0][0][0][0][0][0][0]: 
TokenID: 0System.NullReferenceException: Object reference not set to an instance of an object.
   at Butterfly.Messages.GameClientMessageHandler.LoadMembersPetitions(Int32 num, Int32 guildid, Int32 numb2, String st) in C:\Users\root\Desktop\BcStorm\Butterfly\Messages\GameClientMessageHandler.cs:line 3540
   at Butterfly.Messages.StaticMessageHandlers.SharedPacketLib.LoadMembersPetitions(GameClientMessageHandler Handler) in C:\Users\root\Desktop\BcStorm\Butterfly\Messages\StaticMessageHandlers\SharedPacketLib.cs:line 510
   at Butterfly.Messages.StaticMessageHandlers.StaticClientMessageHandler.HandlePacket(GameClientMessageHandler handler, ClientMessage message) in C:\Users\root\Desktop\BcStorm\Butterfly\Messages\StaticMessageHandlers\StaticClientMessageHandler.cs:line 29
   at Butterfly.Messages.GameClientMessageHandler.HandleRequest(ClientMessage request) in C:\Users\root\Desktop\BcStorm\Butterfly\Messages\GameClientMessageHandler.cs:line 3042
   at Butterfly.HabboHotel.GameClients.GameClient.parser_onNewPacket(ClientMessage Message) in C:\Users\root\Desktop\BcStorm\Butterfly\HabboHotel\GameClients\GameClient.cs:line 136

It's if you touch this:
leenster - BcStorm - Leensters edition - Fixes Thread. - RaGEZONE Forums


Can you fix it leenster?

I fixed that last night, have not tested it yet.


That said: please do not post anything other than fixes in this thread.

 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
When a brand new user tries to create a group without having a room the create_group window would not open.

This will fix that.

In GameClientMessageHandler.cs find
PHP:
public void OpenGuildPage()

Replace that method with:
PHP:
public void OpenGuildPage()
        {
            Habbo habbo = this.Session.GetHabbo();
            ServerMessage message = new ServerMessage(Outgoing.SendGuildParts);
            message.AppendInt32(10);
            message.AppendInt32((int)(habbo.UsersRooms.Count - this.GetMyRoomsGuilds()));
            foreach (RoomData data in habbo.UsersRooms)
            {
                if (data.GroupId == 0)
                {
                    message.AppendInt32(data.Id);
                    message.AppendString(data.Name);
                    message.AppendBoolean(false);
                }
            }
            message.AppendInt32(5);
            message.AppendInt32(10);
            message.AppendInt32(3);
            message.AppendInt32(4);
            message.AppendInt32(0x19);
            message.AppendInt32(0x11);
            message.AppendInt32(5);
            message.AppendInt32(0x19);
            message.AppendInt32(0x11);
            message.AppendInt32(3);
            message.AppendInt32(0x1d);
            message.AppendInt32(11);
            message.AppendInt32(4);
            message.AppendInt32(0);
            message.AppendInt32(0);
            message.AppendInt32(0);
            this.Session.SendMessage(message);
            this.Session.SendMessage(ButterflyEnvironment.GetGame().GetCatalog().mGuildPageBuy);
            this.Session.GetHabbo().ColorsSended = true;
        }
 
Skilled Illusionist
Joined
Jul 4, 2009
Messages
363
Reaction score
65
Fix for 'already loggged in'

In UserDataFactory.cs find:

PHP:
 if (ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num) != null)
                {
                    errorCode = 2;
                    return null;
                }


And replace it with:

PHP:
 if (ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num) != null)
                {


                    ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num).Disconnect();

                }
 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
Here is a fix for the paging error while viewing the admins or the pending members if there are more then 14 in the list.

This fix also contains the search feature where you can search for members/admins or pending members. You can search by part of their name.

In GameClientMessageHandler.cs find:
PHP:
public void LoadMembersPetitions(int num=4, int guildid=0, int numb2=0, string st ="")

Replace that method with:
PHP:
public void LoadMembersPetitions(int num=4, int guildid=0, int numb2=0, string st ="")
        {
            int guildId;
            int num2;
            int num3;
            string str;
            
            if (num == 4)
            {
                guildId = this.Request.PopWiredInt32();
                num2 = this.Request.PopWiredInt32();
                str = this.Request.PopFixedString();            
                num3 = this.Request.PopWiredInt32();
            }
            else
            {
                guildId = guildid;
                num2 = numb2;
                str = st;       
                num3 = num;
            }

            MyGuild guild = ButterflyEnvironment.GetGame().GetGuilds().GetGuild(guildId);
            if (guild != null)
            {
                ServerMessage message;
                Habbo habbo;
                int memberCounter = 0;
                int results;
                if (num3 == 0)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        results = 0;
                        foreach (int num4 in guild.Members)
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if (habbo.Username.ToLower().Contains(str.ToLower()))
                                results++;   
                        }
                    }

                    else
                        results = guild.Members.Count();

                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(results);
                    
                    if(num2==0)
                        message.AppendInt32(results);
                    else 
                        message.AppendInt32(results - (num2*14));     
           
                    foreach (int num4 in guild.Members)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if(habbo.Username.ToLower().Contains(str.ToLower()))
                            {
                                if (memberCounter >= ((num2) * 14))
                                {
                                    if (guild.OwnerId == habbo.Id)
                                    {
                                        message.AppendInt32(0);
                                    }
                                    else
                                    {
                                        message.AppendInt32(guild.GuildRanks[num4]);
                                    }
                                    message.AppendInt32(num4);
                                    message.AppendString(habbo.Username);
                                    message.AppendString(habbo.Look);
                                    message.AppendString(guild.JoinDates[memberCounter]);                                        
                                }
                            memberCounter++;
                            }
                        }

                        else
                        {
                            if (memberCounter >= (num2 * 14))
                            {
                                habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                                if (guild.OwnerId == habbo.Id)
                                {
                                    message.AppendInt32(0);
                                }
                                else
                                {
                                    message.AppendInt32(guild.GuildRanks[num4]);
                                }
                                message.AppendInt32(num4);
                                message.AppendString(habbo.Username);
                                message.AppendString(habbo.Look);
                                message.AppendString(guild.JoinDates[memberCounter]);
                            }
                            memberCounter++;
                        }
                    }

                    if(this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                    {
                        if (guild.GuildRanks[(int)this.Session.GetHabbo().Id]<2)
                            message.AppendBoolean(true);
                        else message.AppendBoolean(false);
                    }

                    else message.AppendBoolean(false);
                    message.AppendInt32(14);
                    message.AppendInt32(num2);
                    message.AppendInt32(0);
                    message.AppendString(str);
                    this.Session.SendMessage(message);
                }
                else if (num3 == 1)
                {
                    int admins = 0;
                    
                    foreach (int num4 in guild.Members)
                    {
                        if (guild.GuildRanks[num4] < 2) admins++;
                    }

                    if (!string.IsNullOrEmpty(str))
                    {
                        results = 0;
                        foreach (int num4 in guild.Members)
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if ((habbo.Username.ToLower().Contains(str.ToLower())) && ((guild.GuildRanks[num4] < 2)))
                                results++;
                        }
                    }

                    else
                        results = admins;

                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(results);

                    if (num2 == 0)
                        message.AppendInt32(results);

                    else message.AppendInt32(results - (num2 * 14));
                    memberCounter = 0;
                    foreach (int num4 in guild.Members)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if (habbo.Username.ToLower().Contains(str.ToLower()))
                            {
                                if (guild.GuildRanks[(int)num4] < 2)
                                {
                                    if (memberCounter >= ((num2) * 14))
                                    {
                                        if (guild.OwnerId == habbo.Id)
                                        {
                                            message.AppendInt32(0);
                                        }
                                        else
                                        {
                                            message.AppendInt32(guild.GuildRanks[num4]);
                                        }
                                        message.AppendInt32(num4);
                                        message.AppendString(habbo.Username);
                                        message.AppendString(habbo.Look);
                                        message.AppendString(guild.JoinDates[memberCounter]);
                                    }
                                }
                                memberCounter++;
                            }
                        }

                        else
                        {
                            if (memberCounter >= (num2 * 14))
                            {
                                habbo = ButterflyEnvironment.getHabboForId((uint)num4);

                                if (guild.GuildRanks[(int)num4] < 2)
                                {
                                    if (guild.OwnerId == habbo.Id)
                                    {
                                        message.AppendInt32(0);
                                    }
                                    else
                                    {
                                        message.AppendInt32(guild.GuildRanks[num4]);
                                    }
                                    message.AppendInt32(num4);
                                    message.AppendString(habbo.Username);
                                    message.AppendString(habbo.Look);
                                    message.AppendString(guild.JoinDates[memberCounter]);
                                }
                            }
                            memberCounter++;
                        }
                    }
                    if (this.Session.GetHabbo().ImGuilds.Contains(guild.Id))
                    {
                        if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                            message.AppendBoolean(true);
                        else message.AppendBoolean(false);
                    }
                    else message.AppendBoolean(false);
                    message.AppendInt32(14);
                    message.AppendInt32(num2);
                    message.AppendInt32(1);
                    message.AppendString(str);
                    this.Session.SendMessage(message);
                }

                else if (num3 == 2)
                {
                    if (!string.IsNullOrEmpty(str))
                    {
                        results = 0;
                        foreach (int num4 in guild.Petitions)
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if (habbo.Username.ToLower().Contains(str.ToLower()))
                                results++;
                        }
                    }

                    else
                        results = guild.Petitions.Count();

                    message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                    message.AppendInt32(guild.Id);
                    message.AppendString(guild.Name);
                    message.AppendInt32(guild.RoomId);
                    message.AppendString(guild.Image);
                    message.AppendInt32(results);
                    if (num2 == 0)
                        message.AppendInt32(results);

                    else message.AppendInt32(results - (num2 * 14));
                    memberCounter = 0;
                    foreach (int num4 in guild.Petitions)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                            if (habbo.Username.ToLower().Contains(str.ToLower()))
                            {
                                if (memberCounter >= ((num2) * 14))
                                {
                                    message.AppendInt32(3);
                                    message.AppendInt32(num4);
                                    message.AppendString(habbo.Username);
                                    message.AppendString(habbo.Look);
                                    message.AppendString("");
                                }
                                memberCounter++;
                            }
                        }

                        else
                        {
                            if (memberCounter >= (num2 * 14))
                            {
                                habbo = ButterflyEnvironment.getHabboForId((uint)num4);
                                message.AppendInt32(3);
                                message.AppendInt32(num4);
                                message.AppendString(habbo.Username);
                                message.AppendString(habbo.Look);
                                message.AppendString("");
                            }
                            memberCounter++;
                        }
                    }
                    if (guild.GuildRanks[(int)this.Session.GetHabbo().Id] < 2)
                        message.AppendBoolean(true);
                    else message.AppendBoolean(false);
                    message.AppendInt32(14);
                    message.AppendInt32(num2);
                    message.AppendInt32(2);
                    message.AppendString(str);
                    this.Session.SendMessage(message);
                }
            }
        }








Here is a little fix that will prevent you of getting a packet error when you accept a member that is offline.

In GameClientMessageHandler.cs (acceptmember()) find
PHP:
ServerMessage message7 = new ServerMessage(Outgoing.SendAdvGroupInit);
                        message7.AppendInt32(guild.Id);
                        message7.AppendBoolean(true);
                        message7.AppendInt32(guild.Type);
                        message7.AppendString(guild.Name);
                        message7.AppendString(guild.Description);
                        message7.AppendString(guild.Image);
                        message7.AppendInt32(data.Id);
                        message7.AppendString(data.Name);
                        if (guild.Petitions.Contains((int)habbo.Id))
                        {
                            message7.AppendInt32(2);
                        }
                        else if (!habbo.ImGuilds.Contains(guild.Id))
                        {
                            message7.AppendInt32(0);
                        }
                        else if (habbo.ImGuilds.Contains(guild.Id))
                        {
                            message7.AppendInt32(1);
                        }
                        message7.AppendInt32(guild.Members.Count);
                        message7.AppendBoolean(false);
                        message7.AppendString(guild.DateCreated);

                        message7.AppendBoolean(habbo.Id == guild.OwnerId);

                        if (habbo.ImGuilds.Contains(guild.Id))
                        {
                            if (guild.GuildRanks[(int)habbo.Id] < 2)
                                message7.AppendBoolean(true);
                            else message7.AppendBoolean(false);
                        }
                        else message7.AppendBoolean(false);
                        message7.AppendString(guild.OwnerName);
                        message7.AppendBoolean(true);
                        message7.AppendBoolean(true);
                        message7.AppendInt32(guild.Members.Contains((int)habbo.Id) ? guild.Petitions.Count : 0);
                        habbo.GetClient().SendMessage(message7);
Replace that with:
PHP:
if (ButterflyEnvironment.GetGame().GetClientManager().GetClient(habbo.Id) != null)
                    {
                        ServerMessage message7 = new ServerMessage(Outgoing.SendAdvGroupInit);
                        message7.AppendInt32(guild.Id);
                        message7.AppendBoolean(true);
                        message7.AppendInt32(guild.Type);
                        message7.AppendString(guild.Name);
                        message7.AppendString(guild.Description);
                        message7.AppendString(guild.Image);
                        message7.AppendInt32(data.Id);
                        message7.AppendString(data.Name);
                        if (guild.Petitions.Contains((int)habbo.Id))
                        {
                            message7.AppendInt32(2);
                        }
                        else if (!habbo.ImGuilds.Contains(guild.Id))
                        {
                            message7.AppendInt32(0);
                        }
                        else if (habbo.ImGuilds.Contains(guild.Id))
                        {
                            message7.AppendInt32(1);
                        }
                        message7.AppendInt32(guild.Members.Count);
                        message7.AppendBoolean(false);
                        message7.AppendString(guild.DateCreated);

                        message7.AppendBoolean(habbo.Id == guild.OwnerId);

                        if (habbo.ImGuilds.Contains(guild.Id))
                        {
                            if (guild.GuildRanks[(int)habbo.Id] < 2)
                                message7.AppendBoolean(true);
                            else message7.AppendBoolean(false);
                        }
                        else message7.AppendBoolean(false);
                        message7.AppendString(guild.OwnerName);
                        message7.AppendBoolean(true);
                        message7.AppendBoolean(true);
                        message7.AppendInt32(guild.Members.Contains((int)habbo.Id) ? guild.Petitions.Count : 0);
                        habbo.GetClient().SendMessage(message7);
                    }

The download in this thread had been updated with all the latest fixes.

Please do not reply in this thread. If you have bug reports you can post them <here>
 
Last edited:
Banned
Banned
Joined
May 6, 2009
Messages
531
Reaction score
165
So, i'll contribute with a little fix...

#Fix for Sign...

Search in "RoomUserManager.cs" for:
Code:
foreach (RoomUser user in list)

And put after:
Code:
user.SerializeStatus(message);

this:
Code:
user.RemoveStatus("sign");

And now when you talk the sign will not appear anymore!
Maybe i'll release more fixs for you guys ;)
 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
When you gift someone a Trophy there will be no Name or Writting included, users complain quite a bit about that.

In GameClientMessageHandler.cs find:
PHP:
internal void OpenPresent()

Replace that method with this one:
PHP:
internal void OpenPresent()
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
            if ((room != null) && room.CheckRights(this.Session, true))
            {
                uint pId = this.Request.PopWiredUInt();
                RoomItem item = room.GetRoomItemHandler().GetItem(pId);
                if (item != null)
                {
                    IQueryAdapter adapter;
                    item.MagicRemove = true;
                    ServerMessage message = new ServerMessage(Outgoing.UpdateItemOnRoom);
                    item.Serialize(message, room.OwnerId);
                    room.SendMessage(message);
                    DataRow row = null;
                    using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        adapter.setQuery("SELECT base_id,amount,extra_data FROM user_presents WHERE item_id = " + item.Id);
                        row = adapter.getRow();
                        
                    }
                    if (row == null)
                    {
                        room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                    }
                    else
                    {
                        Item item2 = ButterflyEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(row["base_id"]));
                        if (item2 == null)
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                        }
                        else if (item2.Type.ToString().ToLower().Equals("s") && (item2.InteractionType != InteractionType.teleport))
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                            
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery(string.Concat(new object[] { "UPDATE items SET base_id = '", row["base_id"], "' WHERE item_id = ", item.Id }));
                                
                                adapter.setQuery(string.Concat(new object[] { "UPDATE items_extradata SET data = '@extradata' WHERE item_id = " + item.Id }));
                                adapter.addParameter("extradata", row["extra_data"]);
                                adapter.runQuery();
                                
                                adapter.runFastQuery("DELETE FROM user_presents WHERE item_id = " + item.Id);
                            }

                            string s = item.GetBaseItem().Type.ToString().ToLower();
                            string extraData = row["extra_data"].ToString();
                            item.BaseItem = Convert.ToUInt32(row["base_id"]);
                            item.refreshItem();
                            item.ExtraData = extraData;
                            if (!room.GetRoomItemHandler().SetFloorItem(this.Session, item, item.GetX, item.GetY, item.Rot, true, false, true))
                            {
                                this.Session.SendNotif("Failed to create your gift!");
                            }
                            else
                            {
                                this.Response.Init(Outgoing.OpenGift);
                                this.Response.AppendString(item2.Type.ToString());
                                this.Response.AppendInt32(item2.SpriteId);
                                this.Response.AppendString(item2.Name);
                                this.Response.AppendInt32(item.Id);
                                this.Response.AppendString(s);
                                this.Response.AppendBoolean(true);
                                this.Response.AppendString(extraData);
                                this.SendResponse();
                            }
                        }
                        else
                        {
                            room.GetRoomItemHandler().RemoveFurniture(this.Session, item.Id);
                            using (adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                adapter.runFastQuery("DELETE FROM user_presents WHERE item_id = " + item.Id);
                            }
                            this.Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert);
                            this.Session.GetMessageHandler().GetResponse().AppendInt32(1);
                            int i = 2;
                            if (item2.Type.ToString().ToLower().Equals("s"))
                            {
                                if (item2.InteractionType == InteractionType.pet)
                                {
                                    i = 3;
                                }
                                else
                                {
                                    i = 1;
                                }
                            }
                            this.Session.GetMessageHandler().GetResponse().AppendInt32(i);
                            List<UserItem> list = ButterflyEnvironment.GetGame().GetCatalog().DeliverItems(this.Session, item2, (int)row["amount"], (string)row["extra_data"], 0, 0);
                            this.Session.GetMessageHandler().GetResponse().AppendInt32(list.Count);
                            foreach (UserItem item3 in list)
                            {
                                this.Session.GetMessageHandler().GetResponse().AppendInt32(item3.Id);
                            }
                            this.Session.GetMessageHandler().SendResponse();
                            this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                        }
                    }
                }
            }
        }
 
Developer
Joined
Nov 26, 2011
Messages
509
Reaction score
81
how do i fix this because i cant make information for everyone who registers :p

Yeah you can.
If you have experience of php you can make easy a mysql code for everybody. You can do this with while function.
 
Status
Not open for further replies.
Back
Top