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 parse(GameClient Session, ClientPacket Packet)
        {
            if (Session.GetHabbo().MutantPenalty)
            {
                Session.SendNotif("Because of a penalty or restriction on your account, you are not allowed to change your look.");
                return;
            }

            string Gender = Packet.PopFixedString().ToUpper();
            string Look = UberEnvironment.FilterInjectionChars(Packet.PopFixedString());

            if (!AntiMutant.ValidateLook(Look, Gender))
            {
                return;
            }

            Session.GetHabbo().Look = Look;
            Session.GetHabbo().Gender = Gender.ToLower();

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.AddParamWithValue("look", Look);
                dbClient.AddParamWithValue("gender", Gender);
                dbClient.ExecuteQuery("UPDATE users SET look = @look, gender = @gender WHERE id = '" + Session.GetHabbo().Id + "' LIMIT 1");
            }

            UberEnvironment.GetGame().GetAchievementManager().UnlockAchievement(Session, 1, 1);

            ServerPacket packet = new ServerPacket(266);
            packet.AppendInt32(-1);
            packet.AppendStringWithBreak(Session.GetHabbo().Look);
            packet.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
            packet.AppendStringWithBreak(Session.GetHabbo().Motto);
            Session.SendPacket(packet);

            if (Session.GetHabbo().InRoom)
            {
                Room Room = Session.GetHabbo().CurrentRoom;

                if (Room == null)
                {
                    return;
                }

                RoomUser User = Room.GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (User == null)
                {
                    return;
                }

                ServerPacket RoomUpdate = new ServerPacket(266);
                RoomUpdate.AppendInt32(User.VirtualId);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Look);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Motto);
                Room.SendMessage(RoomUpdate);
            }
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

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

            UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(Packet.PopWiredUInt());

            if (Item == null)
            {
                return;
            }

            string type = "floor";

            if (Item.GetBaseItem().Name.ToLower().Contains("wallpaper"))
            {
                type = "wallpaper";
            }
            else if (Item.GetBaseItem().Name.ToLower().Contains("landscape"))
            {
                type = "landscape";
            }

            switch (type)
            {
                case "floor":

                    Room.Floor = Item.ExtraData;
                    break;

                case "wallpaper":

                    Room.Wallpaper = Item.ExtraData;
                    break;

                case "landscape":

                    Room.Landscape = Item.ExtraData;
                    break;
            }

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("UPDATE rooms SET " + type + " = '" + Item.ExtraData + "' WHERE id = '" + Room.RoomId + "' LIMIT 1");
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);

            ServerPacket Message = new ServerPacket(46);
            Message.AppendStringWithBreak(type);
            Message.AppendStringWithBreak(Item.ExtraData);
            Room.SendMessage(Message);
        }
        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)
        {
            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));
        }
        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)
            {
                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)
        {
            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)
        {
            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 Serialize(ServerPacket Request)
        {
            // BDhqu@UMeth0d1322033860

            Request.AppendUInt(FromUser);
            Request.AppendStringWithBreak(SenderUsername);
            Request.AppendStringWithBreak(FromUser.ToString());
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            string Motto = UberEnvironment.FilterInjectionChars(Packet.PopFixedString());

            if (Motto == Session.GetHabbo().Motto) // Prevents spam?
            {
                return;
            }

            Session.GetHabbo().Motto = Motto;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                dbClient.AddParamWithValue("motto", Motto);
                dbClient.ExecuteQuery("UPDATE users SET motto = @motto WHERE id = '" + Session.GetHabbo().Id + "' LIMIT 1");
            }

            ServerPacket packet = new ServerPacket(484);
            packet.AppendInt32(-1);
            packet.AppendStringWithBreak(Session.GetHabbo().Motto);
            Session.SendPacket(packet);
            if (Session.GetHabbo().InRoom)
            {
                Room Room = Session.GetHabbo().CurrentRoom;

                if (Room == null)
                {
                    return;
                }

                RoomUser User = Room.GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (User == null)
                {
                    return;
                }

                ServerPacket RoomUpdate = new ServerPacket(266);
                RoomUpdate.AppendInt32(User.VirtualId);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Look); // Need this to reload User or they will be invisible
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower()); // Need this to reload User or they will be invisible
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Motto); // Update The User Motto
                Room.SendMessage(RoomUpdate);
            }
        }
        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)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null)
            {
                return;
            }

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

            if (Item == null || Item.GetBaseItem().InteractionType.ToLower() != "postit")
            {
                return;
            }

            ServerPacket packet = new ServerPacket(48);
            packet.AppendStringWithBreak(Item.Id.ToString());
            packet.AppendStringWithBreak(Item.ExtraData);
            Session.SendPacket(packet);
        }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            RoomAdvertisement Ad = UberEnvironment.GetGame().GetAdvertisementManager().GetRandomRoomAdvertisement();

            ServerPacket packet = new ServerPacket(258);

            if (Ad == null)
            {
                packet.AppendStringWithBreak("");
                packet.AppendStringWithBreak("");
            }
            else
            {
                packet.AppendStringWithBreak(Ad.AdImage);
                packet.AppendStringWithBreak(Ad.AdLink);

                Ad.OnView();
            }

            Session.SendPacket(packet);
        }
Beispiel #15
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)
        {
            Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

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

            Room.Event = null;

            ServerPacket Message = new ServerPacket(370);
            Message.AppendStringWithBreak("-1");
            Room.SendMessage(Message);
        }
        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)
        {
            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 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)
 {
     ServerPacket packet = new ServerPacket(5);
     packet.AppendStringWithBreak(Session.GetHabbo().Id.ToString());
     packet.AppendStringWithBreak(Session.GetHabbo().Username);
     packet.AppendStringWithBreak(Session.GetHabbo().Look);
     packet.AppendStringWithBreak(Session.GetHabbo().Gender.ToUpper());
     packet.AppendStringWithBreak(Session.GetHabbo().Motto);
     packet.AppendStringWithBreak(Session.GetHabbo().RealName);
     packet.AppendInt32(0);
     packet.AppendStringWithBreak("");
     packet.AppendInt32(0);
     packet.AppendInt32(0);
     packet.AppendInt32(Session.GetHabbo().Respect);
     packet.AppendInt32(Session.GetHabbo().DailyRespectPoints); // respect to give away
     packet.AppendInt32(Session.GetHabbo().DailyPetRespectPoints);
     Session.SendPacket(packet);
 }
        public void parse(GameClient Session, ClientPacket Packet)
        {
            string SubscriptionId = Packet.PopFixedString();

            ServerPacket packet = new ServerPacket(7);
            packet.AppendStringWithBreak(SubscriptionId.ToLower());

            if (Session.GetHabbo().GetSubscriptionManager().HasSubscription(SubscriptionId))
            {
                Double Expire = Session.GetHabbo().GetSubscriptionManager().GetSubscription(SubscriptionId).ExpireTime;
                Double TimeLeft = Expire - UberEnvironment.GetUnixTimestamp();
                int TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400);
                int MonthsLeft = TotalDaysLeft / 31;

                if (MonthsLeft >= 1) MonthsLeft--;

                packet.AppendInt32(TotalDaysLeft - (MonthsLeft * 31));
                packet.AppendBoolean(true);
                packet.AppendInt32(MonthsLeft);
                packet.AppendInt32(1);
                packet.AppendInt32(1);

                if (Session.GetHabbo().HasFuse("fuse_use_vip_outfits"))
                {
                    packet.AppendInt32(2);
                }
                else
                {
                    packet.AppendInt32(1);
                }
            }
            else
            {
                for (int i = 0; i < 3; i++)
                {
                    packet.AppendInt32(0);
                }
            }

            Session.SendPacket(packet);
        }
Beispiel #22
0
        public ServerPacket Serialize(GameClient Session)
        {
            ServerPacket Message = new ServerPacket(370);
            Message.AppendStringWithBreak(Session.GetHabbo().Id + "");
            Message.AppendStringWithBreak(Session.GetHabbo().Username);
            Message.AppendStringWithBreak(RoomId + "");
            Message.AppendInt32(Category);
            Message.AppendStringWithBreak(Name);
            Message.AppendStringWithBreak(Description);
            Message.AppendStringWithBreak(StartTime);
            Message.AppendInt32(Tags.Count);

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

            return Message;
        }
        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)
 {
     ServerPacket packet = new ServerPacket(309);
     packet.AppendStringWithBreak("IcIrDs43103s19014d5a1dc291574a508bc80a64663e61a00");
     Session.SendPacket(packet);
 }
Beispiel #25
0
        public ServerPacket SerializeSearchResults(string SearchQuery)
        {
            DataTable Data = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                SearchQuery = UberEnvironment.FilterInjectionChars(SearchQuery.ToLower()).Trim();

                if (SearchQuery.Length > 0)
                {
                    dbClient.AddParamWithValue("query", SearchQuery + "%");
                    dbClient.AddParamWithValue("tags_query", "%" + SearchQuery + "%");
                    Data = dbClient.ReadDataTable("SELECT * FROM rooms WHERE caption LIKE @query AND roomtype = 'private' OR tags LIKE @tags_query AND roomtype = 'private' OR owner LIKE @query AND roomtype = 'private' ORDER BY users_now DESC LIMIT 30");
                }
            }

            List<RoomData> Results = new List<RoomData>();

            if (Data != null)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    RoomData RData = new RoomData();
                    RData.Fill(Row);
                    Results.Add(RData);
                }
            }

            ServerPacket Message = new ServerPacket(451);
            Message.AppendInt32(1);
            Message.AppendInt32(9);
            Message.AppendStringWithBreak(SearchQuery);
            Message.AppendInt32(Results.Count);

            foreach (RoomData Room in Results)
            {
                Room.Serialize(Message, false);
            }

            return Message;
        }
Beispiel #26
0
        public ServerPacket SerializeRoomListing(GameClient Session, int Mode)
        {
            ServerPacket Rooms = new ServerPacket(451);

            if (Mode >= -1)
            {
                Rooms.AppendInt32(Mode);
                Rooms.AppendInt32(1);
            }
            else if (Mode == -2)
            {
                Rooms.AppendInt32(0);
                Rooms.AppendInt32(2);
            }
            else if (Mode == -3)
            {
                Rooms.AppendInt32(0);
                Rooms.AppendInt32(5);
            }
            else if (Mode == -4)
            {
                Rooms.AppendInt32(0);
                Rooms.AppendInt32(3);
            }
            else if (Mode == -5)
            {
                Rooms.AppendInt32(0);
                Rooms.AppendInt32(4);
            }

            Rooms.AppendStringWithBreak("");

            DataTable Data = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                switch (Mode)
                {
                    case -5:

                        List<uint> FriendRooms = new List<uint>();
                        foreach (MessengerBuddy Buddy in Session.GetHabbo().GetMessenger().GetBuddies())
                        {
                            GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(Buddy.Id);

                            if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().CurrentRoomId <= 0)
                            {
                                continue;
                            }

                            FriendRooms.Add(Client.GetHabbo().CurrentRoomId);
                        }

                        StringBuilder _Query = new StringBuilder("SELECT * FROM rooms WHERE");

                        int _i = 0;

                        foreach (uint Room in FriendRooms)
                        {
                            if (_i > 0)
                            {
                                _Query.Append(" OR");
                            }

                            _Query.Append(" id = '" + Room + "'");

                            _i++;
                        }

                        _Query.Append(" ORDER BY users_now DESC LIMIT 40");

                        if (_i > 0)
                        {
                            Data = dbClient.ReadDataTable(_Query.ToString());
                        }
                        else
                        {
                            Data = null;
                        }

                        break;

                    case -4:

                        List<string> FriendsNames = new List<string>();

                        foreach (MessengerBuddy Buddy in Session.GetHabbo().GetMessenger().GetBuddies())
                        {
                            FriendsNames.Add(Buddy.Username);
                        }

                        StringBuilder Query = new StringBuilder("SELECT * FROM rooms WHERE");

                        int i = 0;

                        foreach (string Name in FriendsNames)
                        {
                            if (i > 0)
                            {
                                Query.Append(" OR");
                            }

                            Query.Append(" owner = '" + Name + "'");

                            i++;
                        }

                        Query.Append(" ORDER BY users_now DESC LIMIT 40");

                        if (i > 0)
                        {
                            Data = dbClient.ReadDataTable(Query.ToString());
                        }
                        else
                        {
                            Data = null;
                        }

                        break;

                    case -3:

                        Data = dbClient.ReadDataTable("SELECT * FROM rooms WHERE owner = '" + Session.GetHabbo().Username + "' ORDER BY id ASC");
                        break;

                    case -2:

                        Data = dbClient.ReadDataTable("SELECT * FROM rooms WHERE score > 0 AND roomtype = 'private' ORDER BY score DESC LIMIT 40");
                        break;

                    case -1:

                        Data = dbClient.ReadDataTable("SELECT * FROM rooms WHERE users_now > 0 AND roomtype = 'private' ORDER BY users_now DESC LIMIT 40");
                        break;

                    default:

                        Data = dbClient.ReadDataTable("SELECT * FROM rooms WHERE category = '" + Mode + "' AND roomtype = 'private' ORDER BY users_now DESC LIMIT 40");
                        break;
                }
            }

            if (Data == null)
            {
                Rooms.AppendInt32(0);
            }
            else
            {
                Rooms.AppendInt32(Data.Rows.Count);

                foreach (DataRow Row in Data.Rows)
                {
                    UberEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)Row["id"]).Serialize(Rooms, false);
                }
            }

            return Rooms;
        }
Beispiel #27
0
        public ServerPacket SerializeRecentRooms(GameClient Session)
        {
            DataTable Data = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                Data = dbClient.ReadDataTable("SELECT * FROM user_roomvisits ORDER BY entry_timestamp DESC LIMIT 50");
            }

            List<RoomData> ValidRecentRooms = new List<RoomData>();
            List<uint> RoomsListed = new List<uint>();

            if (Data != null)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    RoomData rData = UberEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)Row["room_id"]);

                    if (rData == null || rData.IsPublicRoom || RoomsListed.Contains(rData.Id))
                    {
                        continue;
                    }

                    ValidRecentRooms.Add(rData);
                    RoomsListed.Add(rData.Id);
                }
            }

            ServerPacket Rooms = new ServerPacket(451);
            Rooms.AppendInt32(0);
            Rooms.AppendInt32(7);
            Rooms.AppendStringWithBreak("");
            Rooms.AppendInt32(ValidRecentRooms.Count);

            foreach (RoomData _Data in ValidRecentRooms)
            {
                _Data.Serialize(Rooms, false);
            }

            return Rooms;
        }
Beispiel #28
0
        public ServerPacket SerializePopularRoomTags()
        {
            Dictionary<string, int> Tags = new Dictionary<string, int>();
            DataTable Data = null;

            using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
            {
                Data = dbClient.ReadDataTable("SELECT tags,users_now FROM rooms WHERE roomtype = 'private' AND users_now > 0 ORDER BY users_now DESC LIMIT 50");
            }

            if (Data != null)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    List<string> RoomTags = new List<string>();

                    foreach (string Tag in Row["tags"].ToString().Split(','))
                    {
                        RoomTags.Add(Tag);
                    }

                    foreach (string Tag in RoomTags)
                    {
                        if (Tags.ContainsKey(Tag))
                        {
                            Tags[Tag] += (int)Row["users_now"];
                        }
                        else
                        {
                            Tags.Add(Tag, (int)Row["users_now"]);
                        }
                    }
                }
            }

            List<KeyValuePair<string, int>> SortedTags = new List<KeyValuePair<string, int>>(Tags);

            SortedTags.Sort(

                delegate(KeyValuePair<string, int> firstPair,

                KeyValuePair<string, int> nextPair)
                {
                    return firstPair.Value.CompareTo(nextPair.Value);
                }

            );

            ServerPacket Message = new ServerPacket(452);
            Message.AppendInt32(SortedTags.Count);

            foreach (KeyValuePair<string, int> TagData in SortedTags)
            {
                Message.AppendStringWithBreak(TagData.Key);
                Message.AppendInt32(TagData.Value);
            }

            return Message;
        }
Beispiel #29
0
        public ServerPacket SerializeFlatCategories()
        {
            ServerPacket Cats = new ServerPacket(221);
            Cats.AppendInt32(PrivateCategories.Count);

            foreach (FlatCat FlatCat in PrivateCategories)
            {
                if (FlatCat.Id > 0)
                {
                    Cats.AppendBoolean(true);
                }

                Cats.AppendInt32(FlatCat.Id);
                Cats.AppendStringWithBreak(FlatCat.Caption);
            }

            Cats.AppendStringWithBreak("");

            return Cats;
        }
Beispiel #30
0
        public ServerPacket SerializeFavoriteRooms(GameClient Session)
        {
            ServerPacket Rooms = new ServerPacket(451);
            Rooms.AppendInt32(0);
            Rooms.AppendInt32(6);
            Rooms.AppendStringWithBreak("");
            Rooms.AppendInt32(Session.GetHabbo().FavoriteRooms.Count);

            foreach (uint Id in Session.GetHabbo().FavoriteRooms)
            {
                UberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id).Serialize(Rooms, false);
            }

            return Rooms;
        }