public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            foreach (uint UserId in Room.UsersWithRights)
            {
                RoomUser User = Room.GetRoomUserByHabbo(UserId);

                if (User != null && !User.IsBot)
                {
                    User.GetClient().SendPacket(new ServerPacket(43));
                }

                ServerPacket packet = new ServerPacket(511);
                packet.AppendUInt(Room.RoomId);
                packet.AppendUInt(UserId);
                Session.SendPacket(packet);
            }

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("DELETE FROM room_rights WHERE room_id = '" + Room.RoomId + "'");
            }

            Room.UsersWithRights.Clear();
        }
Beispiel #2
0
        public Trade(uint UserOneId, uint UserTwoId, uint RoomId)
        {
            this.oneId = UserOneId;
            this.twoId = UserTwoId;

            this.Users = new List<TradeUser>(2);
            this.Users.Add(new TradeUser(UserOneId, RoomId));
            this.Users.Add(new TradeUser(UserTwoId, RoomId));
            this.TradeStage = 1;
            this.RoomId = RoomId;

            foreach (TradeUser User in Users)
            {
                if (!User.GetRoomUser().Statusses.ContainsKey("trd"))
                {
                    User.GetRoomUser().AddStatus("trd", "");
                    User.GetRoomUser().UpdateNeeded = true;
                }
            }

            ServerPacket Message = new ServerPacket(104);
            Message.AppendUInt(UserOneId);
            Message.AppendBoolean(true);
            Message.AppendUInt(UserTwoId);
            Message.AppendBoolean(true);
            SendMessageToUsers(Message);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            ServerPacket packet = new ServerPacket(267);
            packet.AppendBoolean(Session.GetHabbo().HasFuse("fuse_use_wardrobe"));

            if (Session.GetHabbo().HasFuse("fuse_use_wardrobe"))
            {
                DataTable WardrobeData = null;

                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("userid", Session.GetHabbo().Id);
                    WardrobeData = dbClient.ReadDataTable("SELECT * FROM user_wardrobe WHERE user_id = @userid");
                }

                if (WardrobeData == null)
                {
                    packet.AppendInt32(0);
                }
                else
                {
                    packet.AppendInt32(WardrobeData.Rows.Count);

                    foreach (DataRow Row in WardrobeData.Rows)
                    {
                        packet.AppendUInt((uint)Row["slot_id"]);
                        packet.AppendStringWithBreak((string)Row["look"]);
                        packet.AppendStringWithBreak((string)Row["gender"]);
                    }
                }
            }
            Session.SendPacket(packet);
        }
 public void DeliverInstantMessage(string Message, uint ConversationId)
 {
     ServerPacket InstantMessage = new ServerPacket(134);
     InstantMessage.AppendUInt(ConversationId);
     InstantMessage.AppendString(Message);
     GetClient().SendPacket(InstantMessage);
 }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserByHabbo(Packet.PopWiredUInt());

            if (User == null || User.IsBot)
            {
                return;
            }
            ServerPacket packet = new ServerPacket(228);
            packet.AppendUInt(User.GetClient().GetHabbo().Id);
            packet.AppendInt32(User.GetClient().GetHabbo().GetBadgeComponent().EquippedCount);

            foreach (Badge Badge in User.GetClient().GetHabbo().GetBadgeComponent().BadgeList)
            {
                if (Badge.Slot <= 0)
                {
                    continue;
                }

                packet.AppendInt32(Badge.Slot);
                packet.AppendStringWithBreak(Badge.Code);
            }

            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Session.GetHabbo().GetBadgeComponent().ResetSlots();

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("UPDATE user_badges SET badge_slot = '0' WHERE user_id = '" + Session.GetHabbo().Id + "'");
            }

            while (Packet.RemainingLength > 0)
            {
                int Slot = Packet.PopWiredInt32();
                string Badge = Packet.PopFixedString();

                if (Badge.Length == 0)
                {
                    continue;
                }

                if (!Session.GetHabbo().GetBadgeComponent().HasBadge(Badge) || Slot < 1 || Slot > 5)
                {
                    // zomg haxx0r
                    return;
                }

                Session.GetHabbo().GetBadgeComponent().GetBadge(Badge).Slot = Slot;

                using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("slotid", Slot);
                    dbClient.AddParamWithValue("badge", Badge);
                    dbClient.AddParamWithValue("userid", Session.GetHabbo().Id);
                    dbClient.ExecuteQuery("UPDATE user_badges SET badge_slot = @slotid WHERE badge_id = @badge AND user_id = @userid LIMIT 1");
                }
            }

            ServerPacket Message = new ServerPacket(228);
            Message.AppendUInt(Session.GetHabbo().Id);
            Message.AppendInt32(Session.GetHabbo().GetBadgeComponent().EquippedCount);

            foreach (Badge Badge in Session.GetHabbo().GetBadgeComponent().BadgeList)
            {
                if (Badge.Slot <= 0)
                {
                    continue;
                }

                Message.AppendInt32(Badge.Slot);
                Message.AppendStringWithBreak(Badge.Code);
            }

            if (Session.GetHabbo().InRoom && UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId) != null)
            {
                UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId).SendMessage(Message);
            }
            else
            {
                Session.SendPacket(Message);
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || Session.GetHabbo().DailyRespectPoints <= 0)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserByHabbo(Packet.PopWiredUInt());

            if (User == null || User.GetClient().GetHabbo().Id == Session.GetHabbo().Id || User.IsBot)
            {
                return;
            }

            Session.GetHabbo().DailyRespectPoints--;
            User.GetClient().GetHabbo().Respect++;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("UPDATE users SET respect = respect + 1 WHERE id = '" + User.GetClient().GetHabbo().Id + "' LIMIT 1");
                dbClient.ExecuteQuery("UPDATE users SET daily_respect_points = daily_respect_points - 1 WHERE id = '" + Session.GetHabbo().Id + "' LIMIT 1");
            }

            // FxkqUzYP_
            ServerPacket Message = new ServerPacket(440);
            Message.AppendUInt(User.GetClient().GetHabbo().Id);
            Message.AppendInt32(User.GetClient().GetHabbo().Respect);
            Room.SendMessage(Message);
        }
        public void Serialize(ServerPacket Message)
        {
            // PMYoNktchn_stovesKHI[bKIM

            if (IsDeal)
            {
                // 8 328 deal01 [] 5 0 2 s [] 26 [] 3 -1
                // PBXRAdeal01QAHJsRFKMsQEIM

                throw new NotImplementedException("Multipile item ids set for catalog item #" + Id + ", but this is usupported at this point");
            }
            else
            {
                Message.AppendUInt(Id);
                Message.AppendStringWithBreak(Name);
                Message.AppendInt32(CreditsCost);
                Message.AppendInt32(PixelsCost);
                Message.AppendInt32(0); // R63 fix
                Message.AppendInt32(1);
                Message.AppendStringWithBreak(GetBaseItem().Type);
                Message.AppendInt32(GetBaseItem().SpriteId);
                Message.AppendStringWithBreak("");
                Message.AppendInt32(Amount);
                Message.AppendInt32(-1);
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserByHabbo(Packet.PopWiredUInt());

            if (User == null || User.IsBot)
            {
                return;
            }

            ServerPacket packet = new ServerPacket(350);
            packet.AppendUInt(User.GetClient().GetHabbo().Id);
            packet.AppendInt32(User.GetClient().GetHabbo().Tags.Count);

            foreach (string Tag in User.GetClient().GetHabbo().Tags)
            {
                packet.AppendStringWithBreak(Tag);
            }

            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            int count = Packet.PopWiredInt32();

            List<uint> UserIds = new List<uint>();

            for (int i = 0; i < count; i++)
            {
                UserIds.Add(Packet.PopWiredUInt());
            }

            string message = UberEnvironment.FilterInjectionChars(Packet.PopFixedString(), true);

            ServerPacket Message = new ServerPacket(135);
            Message.AppendUInt(Session.GetHabbo().Id);
            Message.AppendStringWithBreak(message);

            foreach (uint Id in UserIds)
            {
                if (!Session.GetHabbo().GetMessenger().FriendshipExists(Session.GetHabbo().Id, Id))
                {
                    continue;
                }

                GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Id);

                if (Client == null)
                {
                    return;
                }

                Client.SendPacket(Message);
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint Id = Packet.PopWiredUInt();

            RoomData Data = UberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id);

            if (Data == null || Session.GetHabbo().FavoriteRooms.Count >= 30 || Session.GetHabbo().FavoriteRooms.Contains(Id) || Data.Type == "public")
            {
                ServerPacket packet = new ServerPacket(33);
                packet.AppendInt32(-9001);
                Session.SendPacket(packet);

                return;
            }

            ServerPacket _packet = new ServerPacket(459);
            _packet.AppendUInt(Id);
            _packet.AppendBoolean(true);
            Session.SendPacket(_packet);

            Session.GetHabbo().FavoriteRooms.Add(Id);

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("INSERT INTO user_favorites (user_id,room_id) VALUES ('" + Session.GetHabbo().Id + "','" + Id + "')");
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint _id = Packet.PopWiredUInt();
            DataRow Row = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                Row = dbClient.ReadDataRow("SELECT * FROM catalog_marketplace_offers WHERE offer_id = '" + _id + "' LIMIT 1");
            }

            if (Row == null || (uint)Row["user_id"] != Session.GetHabbo().Id || (string)Row["state"] != "1")
            {
                return;
            }

            Item Item = UberEnvironment.GetGame().GetItemManager().GetItem((uint)Row["item_id"]);

            if (Item == null)
            {
                return;
            }

            UberEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (string)Row["extra_data"]);

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("DELETE FROM catalog_marketplace_offers WHERE offer_id = '" + _id + "' LIMIT 1");
            }

            ServerPacket packet = new ServerPacket(614);
            packet.AppendUInt((uint)Row["offer_id"]);
            packet.AppendBoolean(true);
            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint Id = Packet.PopWiredUInt();

            RoomData Data = UberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id);

            if (Data == null || Data.Type != "public")
            {
                return;
            }

            ServerPacket packet = new ServerPacket(453);
            packet.AppendUInt(Data.Id);
            packet.AppendStringWithBreak(Data.CCTs);
            packet.AppendUInt(Data.Id);
            Session.SendPacket(packet);
        }
        public void Serialize(ServerPacket Request)
        {
            // BDhqu@UMeth0d1322033860

            Request.AppendUInt(FromUser);
            Request.AppendStringWithBreak(SenderUsername);
            Request.AppendStringWithBreak(FromUser.ToString());
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            ServerPacket packet = new ServerPacket(506);
            packet.AppendInt32(5);

            for (uint i = 5; i >= 1; i--)
            {
                packet.AppendUInt(i);

                if (i <= 1)
                {
                    packet.AppendInt32(0);
                }
                else if (i == 2)
                {
                    packet.AppendInt32(4);
                }
                else if (i == 3)
                {
                    packet.AppendInt32(40);
                }
                else if (i == 4)
                {
                    packet.AppendInt32(200);
                }
                else if (i >= 5)
                {
                    packet.AppendInt32(2000);
                }

                List<EcotronReward> Rewards = UberEnvironment.GetGame().GetCatalog().GetEcotronRewardsForLevel(i);

                packet.AppendInt32(Rewards.Count);

                foreach (EcotronReward Reward in Rewards)
                {
                    packet.AppendStringWithBreak(Reward.GetBaseItem().Type.ToLower());
                    packet.AppendUInt(Reward.DisplayId);
                }
            }

            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            StringBuilder DeleteParams = new StringBuilder();

            int Amount = Packet.PopWiredInt32();

            for (int i = 0; i < Amount; i++)
            {
                if (i > 0)
                {
                    DeleteParams.Append(" OR ");
                }

                uint UserId = Packet.PopWiredUInt();
                Room.UsersWithRights.Remove(UserId);
                DeleteParams.Append("room_id = '" + Room.RoomId + "' AND user_id = '" + UserId + "'");

                RoomUser User = Room.GetRoomUserByHabbo(UserId);

                if (User != null && !User.IsBot)
                {
                    User.GetClient().SendPacket(new ServerPacket(43));
                }

                ServerPacket packet = new ServerPacket(511);
                packet.AppendUInt(Room.RoomId);
                packet.AppendUInt(UserId);
                Session.SendPacket(packet);
            }

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("DELETE FROM room_rights WHERE " + DeleteParams.ToString());
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            RoomItem Present = Room.GetItem(Packet.PopWiredUInt());

            if (Present == null)
            {
                return;
            }

            DataRow Data = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                Data = dbClient.ReadDataRow("SELECT base_id,amount,extra_data FROM user_presents WHERE item_id = '" + Present.Id + "' LIMIT 1");
            }

            if (Data == null)
            {
                return;
            }

            Item BaseItem = UberEnvironment.GetGame().GetItemManager().GetItem((uint)Data["base_id"]);

            if (BaseItem == null)
            {
                return;
            }

            Room.RemoveFurniture(Session, Present.Id);

            ServerPacket packet = new ServerPacket(219);
            packet.AppendUInt(Present.Id);
            Session.SendPacket(packet);

            packet = new ServerPacket(129);
            packet.AppendStringWithBreak(BaseItem.Type);
            packet.AppendInt32(BaseItem.SpriteId);
            packet.AppendStringWithBreak(BaseItem.Name);
            Session.SendPacket(packet);

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("DELETE FROM user_presents WHERE item_id = '" + Present.Id + "' LIMIT 1");
            }

            UberEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (string)Data["extra_data"]);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            ServerPacket packet = new ServerPacket(465);
            packet.AppendUInt(Room.RoomId);
            packet.AppendStringWithBreak(Room.Name);
            packet.AppendStringWithBreak(Room.Description);
            packet.AppendInt32(Room.State);
            packet.AppendInt32(Room.Category);
            packet.AppendInt32(Room.UsersMax);
            packet.AppendInt32(25);
            packet.AppendInt32(Room.TagCount);

            foreach (string Tag in Room.Tags)
            {
                packet.AppendStringWithBreak(Tag);
            }

            packet.AppendInt32(Room.UsersWithRights.Count); // users /w rights count

            foreach (uint UserId in Room.UsersWithRights)
            {
                packet.AppendUInt(UserId);
                packet.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId));
            }

            packet.AppendInt32(Room.UsersWithRights.Count); // users /w rights count

            packet.AppendBoolean(Room.AllowPets); // allows pets in room - pet system lacking, so always off
            packet.AppendBoolean(Room.AllowPetsEating); // allows pets to eat your food - pet system lacking, so always off
            packet.AppendBoolean(Room.AllowWalkthrough);
            packet.AppendBoolean(Room.Hidewall);

            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint ItemId = Packet.PopWiredUInt();
            DataRow Row = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                Row = dbClient.ReadDataRow("SELECT * FROM catalog_marketplace_offers WHERE offer_id = '" + ItemId + "' LIMIT 1");
            }

            if (Row == null || (string)Row["state"] != "1" || (double)Row["timestamp"] <= UberEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestamp())
            {
                Session.SendNotif("Sorry, this offer has expired.");
                return;
            }

            Item Item = UberEnvironment.GetGame().GetItemManager().GetItem((uint)Row["item_id"]);

            if (Item == null)
            {
                return;
            }

            if ((int)Row["total_price"] >= 1)
            {
                Session.GetHabbo().Credits -= (int)Row["total_price"];
                Session.GetHabbo().UpdateCreditsBalance(true);
            }

            UberEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (string)Row["extra_data"]);

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("UPDATE catalog_marketplace_offers SET state = '2' WHERE offer_id = '" + ItemId + "' LIMIT 1");
            }

            ServerPacket packet = new ServerPacket(67);
            packet.AppendUInt(Item.ItemId);
            packet.AppendStringWithBreak(Item.Name);
            packet.AppendInt32(0);
            packet.AppendInt32(0);
            packet.AppendInt32(1);
            packet.AppendStringWithBreak(Item.Type.ToLower());
            packet.AppendInt32(Item.SpriteId);
            packet.AppendStringWithBreak("");
            packet.AppendInt32(1);
            packet.AppendInt32(-1);
            packet.AppendStringWithBreak("");
            Session.SendPacket(packet);

            Session.SendPacket(UberEnvironment.GetGame().GetCatalog().GetMarketplace().SerializeOffers(-1, -1, "", 1));
        }
Beispiel #20
0
        public void Serialize(ServerPacket Message, Boolean Inventory)
        {
            Message.AppendUInt(Id);
            Message.AppendInt32(0);
            Message.AppendStringWithBreak(GetBaseItem().Type.ToUpper());
            Message.AppendUInt(Id);
            Message.AppendInt32(GetBaseItem().SpriteId);

            if (GetBaseItem().Name.Contains("a2"))
            {
                Message.AppendInt32(3);
            }
            else if (GetBaseItem().Name.Contains("wallpaper"))
            {
                Message.AppendInt32(2);
            }
            else if (GetBaseItem().Name.Contains("landscape"))
            {
                Message.AppendInt32(4);
            }
            else
            {
                Message.AppendInt32(0);
            }

            Message.AppendStringWithBreak(ExtraData);
            Message.AppendBoolean(GetBaseItem().AllowRecycle);
            Message.AppendBoolean(GetBaseItem().AllowTrade);
            Message.AppendBoolean(GetBaseItem().AllowInventoryStack);
            Message.AppendBoolean(UberEnvironment.GetGame().GetCatalog().GetMarketplace().CanSellItem(this));
            Message.AppendInt32(-1);

            if (GetBaseItem().Type.ToLower() == "s")
            {
                Message.AppendStringWithBreak("");
                Message.AppendInt32(-1);
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint UserId = Packet.PopWiredUInt();

            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
            RoomUser RoomUser = Room.GetRoomUserByHabbo(UserId);

            if (Room == null || !Room.CheckRights(Session, true) || RoomUser == null || RoomUser.IsBot)
            {
                return;
            }

            if (Room.UsersWithRights.Contains(UserId))
            {
                // todo: fix silly bug
                Session.SendNotif("User already has rights! (There appears to be a bug with the rights button, we are looking into it - for now rely on 'Advanced settings')");
                return;
            }

            Room.UsersWithRights.Add(UserId);

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("INSERT INTO room_rights (room_id,user_id) VALUES ('" + Room.RoomId + "','" + UserId + "')");
            }

            ServerPacket packet = new ServerPacket(510);
            packet.AppendUInt(Room.RoomId);
            packet.AppendUInt(UserId);
            packet.AppendStringWithBreak(RoomUser.GetClient().GetHabbo().Username);
            Session.SendPacket(packet);

            RoomUser.AddStatus("flatcrtl", "");
            RoomUser.UpdateNeeded = true;

            RoomUser.GetClient().SendPacket(new ServerPacket(42));
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint Id = Packet.PopWiredUInt();

            Session.GetHabbo().FavoriteRooms.Remove(Id);

            ServerPacket packet = new ServerPacket(459);
            packet.AppendUInt(Id);
            packet.AppendBoolean(false);
            Session.SendPacket(packet);

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("DELETE FROM user_favorites WHERE user_id = '" + Session.GetHabbo().Id + "' AND room_id = '" + Id + "' LIMIT 1");
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint Id = Packet.PopWiredUInt();

            CatalogItem Item = UberEnvironment.GetGame().GetCatalog().FindItem(Id);

            if (Item == null)
            {
                return;
            }

            ServerPacket packet = new ServerPacket(622);
            packet.AppendUInt(Item.Id);
            packet.AppendBoolean(Item.GetBaseItem().AllowGift);
            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            string RoomName = UberEnvironment.FilterInjectionChars(Packet.PopFixedString());
            string ModelName = Packet.PopFixedString();
            string RoomState = Packet.PopFixedString(); // unused, room open by default on creation. may be added in later build of Habbo?

            RoomData NewRoom = UberEnvironment.GetGame().GetRoomManager().CreateRoom(Session, RoomName, ModelName);

            if (NewRoom != null)
            {
                ServerPacket packet = new ServerPacket(59);
                packet.AppendUInt(NewRoom.Id);
                packet.AppendStringWithBreak(NewRoom.Name);
                Session.SendPacket(packet);
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            int itemCount = Packet.PopWiredInt32();

            if (itemCount != 5)
            {
                return;
            }

            for (int i = 0; i < itemCount; i++)
            {
                UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(Packet.PopWiredUInt());

                if (Item != null && Item.GetBaseItem().AllowRecycle)
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);
                }
                else
                {
                    return;
                }
            }

            uint newItemId = UberEnvironment.GetGame().GetCatalog().GenerateItemId();
            EcotronReward Reward = UberEnvironment.GetGame().GetCatalog().GetRandomEcotronReward();

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("INSERT INTO user_items (id,user_id,base_item,extra_data) VALUES ('" + newItemId + "','" + Session.GetHabbo().Id + "','1478','" + DateTime.Now.ToLongDateString() + "')");
                dbClient.ExecuteQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES ('" + newItemId + "','" + Reward.BaseId + "','1','')");
            }

            Session.GetHabbo().GetInventoryComponent().UpdateItems(true);

            ServerPacket packet = new ServerPacket(508);
            packet.AppendBoolean(true);
            packet.AppendUInt(newItemId);
            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            uint BuddyId = Packet.PopWiredUInt();

            GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(BuddyId);

            if (Client == null || Client.GetHabbo() == null || !Client.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Client.GetHabbo().CurrentRoomId);

            if (Room == null)
            {
                return;
            }

            // D^HjTX]X
            ServerPacket packet = new ServerPacket(286);
            packet.AppendBoolean(Room.IsPublic);
            packet.AppendUInt(Client.GetHabbo().CurrentRoomId);
            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            int Junk = Packet.PopWiredInt32(); // always 3

            Dictionary<int, int> Items = new Dictionary<int, int>();

            int Background = Packet.PopWiredInt32();
            int TopLayer = Packet.PopWiredInt32();
            int AmountOfItems = Packet.PopWiredInt32();

            for (int i = 0; i < AmountOfItems; i++)
            {
                int Pos = Packet.PopWiredInt32();
                int Item = Packet.PopWiredInt32();

                if (Pos < 0 || Pos > 10)
                {
                    return;
                }

                if (Item < 1 || Item > 27)
                {
                    return;
                }

                if (Items.ContainsKey(Pos))
                {
                    return;
                }

                Items.Add(Pos, Item);
            }

            if (Background < 1 || Background > 24)
            {
                return;
            }

            if (TopLayer < 0 || TopLayer > 11)
            {
                return;
            }

            StringBuilder FormattedItems = new StringBuilder();
            int j = 0;

            foreach (KeyValuePair<int, int> Item in Items)
            {
                if (j > 0)
                {
                    FormattedItems.Append("|");
                }

                FormattedItems.Append(Item.Key + "," + Item.Value);

                j++;
            }

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("UPDATE rooms SET icon_bg = '" + Background + "', icon_fg = '" + TopLayer + "', icon_items = '" + FormattedItems.ToString() + "' WHERE id = '" + Room.RoomId + "' LIMIT 1");
            }

            Room.Icon = new RoomIcon(Background, TopLayer, Items);

            ServerPacket packet = new ServerPacket(457);
            packet.AppendUInt(Room.RoomId);
            packet.AppendBoolean(true);
            Session.SendPacket(packet);

            packet = new ServerPacket(456);
            packet.AppendUInt(Room.RoomId);
            Session.SendPacket(packet);

            RoomData Data = new RoomData();
            Data.Fill(Room);

            ServerPacket _packet = new ServerPacket(454);
            _packet.AppendBoolean(false);
            Data.Serialize(_packet, false);
            _packet.AppendBoolean(false);
            _packet.AppendBoolean(false);
            Session.SendPacket(_packet);
        }
        public ServerPacket SerializeUserInfo(uint UserId)
        {
            DataRow User = null;
            DataRow Info = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                User = dbClient.ReadDataRow("SELECT * FROM users WHERE id = '" + UserId + "' LIMIT 1");
                Info = dbClient.ReadDataRow("SELECT * FROM user_info WHERE user_id = '" + UserId + "' LIMIT 1");
            }

            if (User == null)
            {
                throw new ArgumentException();
            }

            ServerPacket Message = new ServerPacket(533);

            Message.AppendUInt((uint)User["id"]);
            Message.AppendStringWithBreak((string)User["username"]);

            if (Info != null)
            {
                Message.AppendInt32((int)Math.Ceiling((UberEnvironment.GetUnixTimestamp() - (Double)Info["reg_timestamp"]) / 60));
                Message.AppendInt32((int)Math.Ceiling((UberEnvironment.GetUnixTimestamp() - (Double)Info["login_timestamp"]) / 60));
            }
            else
            {
                Message.AppendInt32(0);
                Message.AppendInt32(0);
            }

            if (User["online"].ToString() == "1")
            {
                Message.AppendBoolean(true);
            }
            else
            {
                Message.AppendBoolean(false);
            }

            if (Info != null)
            {
                Message.AppendInt32((int)Info["cfhs"]);
                Message.AppendInt32((int)Info["cfhs_abusive"]);
                Message.AppendInt32((int)Info["cautions"]);
                Message.AppendInt32((int)Info["bans"]);
            }
            else
            {
                Message.AppendInt32(0); // cfhs
                Message.AppendInt32(0); // abusive cfhs
                Message.AppendInt32(0); // cautions
                Message.AppendInt32(0); // bans
            }

            return Message;
        }
        public ServerPacket SerializeUserChatlog(uint UserId)
        {
            DataTable Visits = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                Visits = dbClient.ReadDataTable("SELECT room_id,entry_timestamp,exit_timestamp FROM user_roomvisits WHERE user_id = '" + UserId + "' ORDER BY entry_timestamp DESC LIMIT 5");
            }

            ServerPacket Message = new ServerPacket(536);
            Message.AppendUInt(UserId);
            Message.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId));

            if (Visits != null)
            {
                Message.AppendInt32(Visits.Rows.Count);

                foreach (DataRow Visit in Visits.Rows)
                {
                    DataTable Chatlogs = null;

                    if ((Double)Visit["exit_timestamp"] <= 0.0)
                    {
                        Visit["exit_timestamp"] = UberEnvironment.GetUnixTimestamp();
                    }

                    using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
                    {
                        Chatlogs = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + (uint)Visit["room_id"] + "' AND timestamp > '" + (Double)Visit["entry_timestamp"] + "' AND timestamp < '" + (Double)Visit["exit_timestamp"] + "' ORDER BY timestamp DESC");
                    }

                    RoomData RoomData = UberEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData((uint)Visit["room_id"]);

                    Message.AppendBoolean(RoomData.IsPublicRoom);
                    Message.AppendUInt(RoomData.Id);
                    Message.AppendStringWithBreak(RoomData.Name);

                    if (Chatlogs != null)
                    {
                        Message.AppendInt32(Chatlogs.Rows.Count);

                        foreach (DataRow Log in Chatlogs.Rows)
                        {
                            Message.AppendInt32((int)Log["hour"]);
                            Message.AppendInt32((int)Log["minute"]);
                            Message.AppendUInt((uint)Log["user_id"]);
                            Message.AppendStringWithBreak((string)Log["user_name"]);
                            Message.AppendStringWithBreak((string)Log["message"]);
                        }
                    }
                    else
                    {
                        Message.AppendInt32(0);
                    }
                }
            }
            else
            {
                Message.AppendInt32(0);
            }

            return Message;
        }
        public ServerPacket SerializeTool()
        {
            ServerPacket Message = new ServerPacket(531);
            Message.AppendInt32(-1);
            Message.AppendInt32(UserMessagePresets.Count);

            foreach (string Preset in UserMessagePresets)
            {
                Message.AppendStringWithBreak(Preset);
            }

            Message.AppendUInt(6); // Amount of Mod Actions

            Message.AppendStringWithBreak("Room Problems"); // modaction Cata
            Message.AppendUInt(8); // ModAction Count
            Message.AppendStringWithBreak("Door Blocking"); // mod action Cata
            Message.AppendStringWithBreak("Please stop blocking the doors."); // Msg
            Message.AppendStringWithBreak("Ban Last Warning"); // Mod Action Cata
            Message.AppendStringWithBreak("This is your last warning or you will be banned."); // Msg
            Message.AppendStringWithBreak("Player Support Issue");// Mod Action Cata
            Message.AppendStringWithBreak("Please contact player support for this issue, thank you."); // Msg
            Message.AppendStringWithBreak("Filter Bypass"); // Mod Cata
            Message.AppendStringWithBreak("Please stop bypassing the filter, this is your only warning."); // Msg
            Message.AppendStringWithBreak("Kick Abuse"); // Mod Cata
            Message.AppendStringWithBreak("Please stop kicking users without a valid reason, thank you."); // Msg
            Message.AppendStringWithBreak("Ban Room"); // Mod Cata
            Message.AppendStringWithBreak("Please stop banning people without a good reason"); // Msg
            Message.AppendStringWithBreak("Unacceptable Room Name"); // Mod Cata
            Message.AppendStringWithBreak("Your room name is unacceptable, please change it or expect further action."); // Msg
            Message.AppendStringWithBreak("Items not loading"); // Mod Cata
            Message.AppendStringWithBreak("Please contact an administrator for this issue."); // Msg

            Message.AppendStringWithBreak("Player Support");// modaction Cata
            Message.AppendUInt(8); // ModAction Count
            Message.AppendStringWithBreak("Bug Report"); // mod action Cata
            Message.AppendStringWithBreak("Thanks for reporting this bug, we appreciate your help."); // Msg
            Message.AppendStringWithBreak("Login Problem"); // Mod Action Cata
            Message.AppendStringWithBreak("We will contact an administrator and work on fixing your issue."); // Msg
            Message.AppendStringWithBreak("Help Support");// Mod Action Cata
            Message.AppendStringWithBreak("Please Contact The Player Support For this problem"); // Msg
            Message.AppendStringWithBreak("Call for Help Misuse"); // Mod Cata
            Message.AppendStringWithBreak("Please do not abuse the Call for Help, it is for genuine use only."); // Msg
            Message.AppendStringWithBreak("Privacy"); // Mod Cata
            Message.AppendStringWithBreak("Please do not give out your personal details."); // Msg
            Message.AppendStringWithBreak("Technical Issue"); // Mod Cata
            Message.AppendStringWithBreak("Please contact an administrator with your technical issue."); // Msg
            Message.AppendStringWithBreak("Cache Issue"); // Mod Cata
            Message.AppendStringWithBreak("Please reload your client and try again, thank you."); // Msg
            Message.AppendStringWithBreak("Other Issues"); // Mod Cata
            Message.AppendStringWithBreak("Please reload your client and try again, thank you."); // Msg

            Message.AppendStringWithBreak("Users Problems");// modaction Cata
            Message.AppendUInt(8); // ModAction Count
            Message.AppendStringWithBreak("Scamming"); // mod action Cata
            Message.AppendStringWithBreak("We cannot monitor scamming within the hotel, please becareful next time."); // Msg
            Message.AppendStringWithBreak("Trading Scam"); // Mod Action Cata
            Message.AppendStringWithBreak("We cannot monitor trading within the hotel, please becareful next time."); // Msg
            Message.AppendStringWithBreak("Disconnection");// Mod Action Cata
            Message.AppendStringWithBreak("Please contact an administrator with your issue."); // Msg
            Message.AppendStringWithBreak("Room Blocking"); // Mod Cata
            Message.AppendStringWithBreak("Please send a Call for Help with the users name, thank you."); // Msg
            Message.AppendStringWithBreak("Freezing"); // Mod Cata
            Message.AppendStringWithBreak("Please reload the client and try again, thank you."); // Msg
            Message.AppendStringWithBreak("Website Issue"); // Mod Cata
            Message.AppendStringWithBreak("Please contact an administrator with the error, thank you."); // Msg
            Message.AppendStringWithBreak("Login Issue"); // Mod Cata
            Message.AppendStringWithBreak("Please say the users name and we will look into it, thank you."); // Msg
            Message.AppendStringWithBreak("Updates"); // Mod Cata
            Message.AppendStringWithBreak("We always try to maintain the best updates."); // Msg

            Message.AppendStringWithBreak("Debug Problems");// modaction Cata
            Message.AppendUInt(8); // ModAction Count
            Message.AppendStringWithBreak("Lag"); // mod action Cata
            Message.AppendStringWithBreak("We are now looking into this issue, thank you."); // Msg
            Message.AppendStringWithBreak("Disconnection"); // Mod Action Cata
            Message.AppendStringWithBreak("What happens and how happens please explain us"); // Msg
            Message.AppendStringWithBreak("SSO Problem");// Mod Action Cata
            Message.AppendStringWithBreak("Please logout of the website and then log back in, thank you."); // Msg
            Message.AppendStringWithBreak("Char Filter"); // Mod Cata
            Message.AppendStringWithBreak("Can you say the users name and explain to us what happens."); // Msg
            Message.AppendStringWithBreak("System check"); // Mod Cata
            Message.AppendStringWithBreak("We are already looking into this issue, thank you."); // Msg
            Message.AppendStringWithBreak("Missing Feature"); // Mod Cata
            Message.AppendStringWithBreak("We are working on this feature sometime into the near future, thank you."); // Msg
            Message.AppendStringWithBreak("Feature Error"); // Mod Cata
            Message.AppendStringWithBreak("We are working on fixing this issue, thank you."); // Msg
            Message.AppendStringWithBreak("Flash Player Issue"); // Mod Cata
            Message.AppendStringWithBreak("We recommend you try installing flash player again, thank you."); // Msg

            Message.AppendStringWithBreak("Unused Category"); // Category
            Message.AppendUInt(8); // Amount of Sub-category
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message

            Message.AppendStringWithBreak("Unused Category"); // Category
            Message.AppendUInt(8); // Amount of Sub-category
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message
            Message.AppendStringWithBreak("Example Category"); // Sub-category
            Message.AppendStringWithBreak("This is an example message."); // Preset message

            Message.AppendStringWithBreak("");
            Message.AppendStringWithBreak("");
            Message.AppendStringWithBreak("");
            Message.AppendStringWithBreak("");
            Message.AppendStringWithBreak("");
            Message.AppendStringWithBreak("");
            Message.AppendStringWithBreak("");

            Message.AppendInt32(RoomMessagePresets.Count);

            foreach (string Preset in RoomMessagePresets)
            {
                Message.AppendStringWithBreak(Preset);
            }
            Message.AppendStringWithBreak("");
            return Message;
        }