Exemplo n.º 1
0
 public void GetInternalResponse(Response Response)
 {
     Response.AppendInt32(Id);
     Response.AppendBoolean(MemberType == Items.MemberType.VIP);
     Response.AppendInt32(MemberdaysNeed);
     Response.AppendBoolean(true);
 }
Exemplo n.º 2
0
        public Response GetButtonData()
        {
            Response Response = new Response(126);
            Response.AppendBoolean(true);
            Response.AppendBoolean(false);
            Response.AppendBoolean(false);
            Response.AppendInt32(-1);
            Response.AppendChar(2);
            Response.AppendInt32(GetButtonTreeAmount(-1));

            var SortedFirst = from pag in PagesForTree(-1)
                              orderby pag.OrderId ascending
                              select pag;

            foreach (ShopPage Page in SortedFirst)
            {
                Page.GetButtonData(Response);

                var SortedLast = from pag in PagesForTree(Page.Id)
                                 orderby pag.OrderId ascending
                                 select pag;

                foreach (ShopPage TreePage in SortedLast)
                {
                    TreePage.GetButtonData(Response);
                }
            }

            return Response;
        }
Exemplo n.º 3
0
        public void GetResponse(Response Response)
        {
            StringBuilder PacketBuilder = new StringBuilder();
            Response.AppendInt32(ShopItemId);

            PacketBuilder.Append("HABBO_CLUB_");
            PacketBuilder.Append(MemberShipType.ToUpper());
            PacketBuilder.Append('_');
            PacketBuilder.Append(MonthsAmount);
            PacketBuilder.Append("_MONTH");

            if (MonthsAmount > 1)
            {
                PacketBuilder.Append('S');
            }

            Response.AppendStringWithBreak(PacketBuilder.ToString());
            Response.AppendInt32(BrickEngine.GetShopReactor().GetShopItem(ShopItemId).CreditsCost);
            Response.AppendBoolean(false);
            Response.AppendBoolean(MemberShipType == "VIP");
            Response.AppendInt32(MonthsAmount);
            Response.AppendInt32(MonthsAmount * 31);
            Response.AppendInt32(ExpireDate().Year);
            Response.AppendInt32(ExpireDate().Month);
            Response.AppendInt32(ExpireDate().Day);
        }
Exemplo n.º 4
0
 public void GetExternalResponse(Response Response)
 {
     Response.AppendInt32(Id);
     Response.AppendStringWithBreak(GetBaseItem().InternalName);
     Response.AppendBoolean(true);
     Response.AppendBoolean(false);
     Response.AppendBoolean(false);
     Response.AppendBoolean(true);
     Response.AppendStringWithBreak(GetBaseItem().InternalType.ToLower());
     Response.AppendInt32(GetBaseItem().SpriteId);
     Response.AppendChar(2);
     Response.AppendBoolean(true);
     Response.AppendInt32(-1);
     Response.AppendInt32((MemberType == Items.MemberType.VIP) ? 2 : 1);
 }
Exemplo n.º 5
0
        public void GetFurniture(Client Client, Request Request)
        {
            var Items = BrickEngine.GetItemReactor().GetItemsForUser(Client.GetUser().HabboId);

            var FloorItems = new List<Item>();
            var WallItems = new List<Item>();

            foreach (Item Item in Items)
            {
                if (Item.GetBaseItem().InternalType.ToLower() == "s")
                {
                    FloorItems.Add(Item);
                }
                else if (Item.GetBaseItem().InternalType.ToLower() == "i")
                {
                    WallItems.Add(Item);
                }
            }

            Response FloorItemsResponse = new Response(140);
            FloorItemsResponse.AppendStringWithBreak("S");
            FloorItemsResponse.AppendBoolean(true);
            FloorItemsResponse.AppendBoolean(true);
            FloorItemsResponse.AppendInt32(FloorItems.Count);

            foreach (Item Item in FloorItems)
            {
                Item.GetInventoryResponse(FloorItemsResponse);
            }

            Client.SendResponse(FloorItemsResponse);

            Response WallItemsResponse = new Response(140);
            WallItemsResponse.AppendStringWithBreak("I");
            WallItemsResponse.AppendBoolean(true);
            WallItemsResponse.AppendBoolean(true);
            WallItemsResponse.AppendInt32(WallItems.Count);

            foreach (Item Item in WallItems)
            {
                Item.GetInventoryResponse(WallItemsResponse);
            }

            Client.SendResponse(WallItemsResponse);
        }
Exemplo n.º 6
0
 public void GetButtonData(Response Response)
 {
     Response.AppendBoolean(true); // always true
     Response.AppendUInt32(IconPaint);
     Response.AppendUInt32(IconId);
     Response.AppendInt32(Id);
     Response.AppendStringWithBreak(Name);
     Response.AppendInt32(BrickEngine.GetShopReactor().GetButtonTreeAmount(Id));
 }
Exemplo n.º 7
0
        private void CheckRoomCreate(Client Client, Request Request)
        {
            int Limit = BrickEngine.GetConfigureFile().CallIntKey("max.rooms.amount");
            int RoomAmount = BrickEngine.GetRoomReactor().GetMe(Client.GetUser().HabboId).Count;

            Response Response = new Response(512);
            Response.AppendBoolean(RoomAmount >= Limit);
            Response.AppendInt32(Limit);
            Client.SendResponse(Response);
        }
Exemplo n.º 8
0
 public void GetResponse(Client Client, Response Response)
 {
     Response.AppendInt32(Id);
     Response.AppendBoolean((Client.GetUser().CurrentQuest.Equals(Id)) ? true : false);
     Response.AppendStringWithBreak(FilterAction);
     Response.AppendStringWithBreak(FilterParam);
     Response.AppendInt32(PixelReward);
     Response.AppendStringWithBreak(FilterReAction);
     Response.AppendInt32((Client.GetUser().CurrentQuest.Equals(Id)) ? Client.GetUser().CurrentQuestProgress : 0);
     Response.AppendInt32(ActionAmount);
 }
Exemplo n.º 9
0
        public void GetResponse(Client Client, Response Response)
        {
            var AchievedQuests = Client.GetUser().Quests;
            var CategoryQuests = BrickEngine.GetQuestReactor().OrderQuestsForCategory(Id);

            Response.AppendStringWithBreak(Name.ToLower());

            if (!AchievedQuests.ContainsKey(Id))
            {
                Response.AppendInt32(0);
            }
            else
            {
                Response.AppendInt32(AchievedQuests[Id]);
            }

            Response.AppendInt32(CategoryQuests.Count);

            Response.AppendInt32(0); // Pixels Type - Reward

            if (AchievedCategory(Client) || BrickEngine.GetQuestReactor().GetQuestForCategory(Client, Id) == null)
            {
                Response.AppendInt32(0);
                Response.AppendBoolean(false);
                Response.AppendChar(2);
                Response.AppendChar(2);
                Response.AppendInt32(0);
                Response.AppendChar(2);
                Response.AppendInt32(0);
                Response.AppendInt32(0);
            }
            else
            {
                BrickEngine.GetQuestReactor().GetQuestForCategory(Client, Id).GetResponse(Client, Response);
            }

            Response.AppendBoolean(false);
        }
Exemplo n.º 10
0
 private void HandleSessionDetails(Client Client, Request Request)
 {
     Response Response = new Response(257);
     Response.AppendInt32(9);
     Response.AppendBoolean(false);
     Response.AppendBoolean(false);
     Response.AppendBoolean(true);
     Response.AppendBoolean(true);
     Response.AppendInt32(3);
     Response.AppendBoolean(false);
     Response.AppendInt32(2);
     Response.AppendBoolean(false);
     Response.AppendInt32(4);
     Response.AppendBoolean(true);
     Response.AppendInt32(5);
     Response.AppendStringWithBreak("dd-MM-yyyy");
     Response.AppendInt32(7);
     Response.AppendBoolean(false);
     Response.AppendInt32(8);
     Response.AppendStringWithBreak("http://");
     Response.AppendInt32(9);
     Response.AppendBoolean(false);
     Client.SendResponse(Response);
 }
Exemplo n.º 11
0
        public Response GetWardRobeResponse(int HabboId, int Max)
        {
            Response Response = new Response(267);
            Response.AppendBoolean(true);

            var Items = (from clothe in GetClothes(HabboId).Values.ToList() orderby clothe.SlotId ascending select clothe).ToList();

            Response.AppendInt32(Items.Count);

            int i = 0;

            foreach (Clothe Clothe in Items)
            {
                if (i < Max)
                {
                    Clothe.GetResponse(Response);
                    i++;
                }
            }

            return Response;
        }
Exemplo n.º 12
0
 // 3011
 private void GetShopInfoA(Client Client, Request Request)
 {
     Response Response = new Response(612);
     Response.AppendBoolean(true);
     Response.AppendBoolean(true);
     Response.AppendBoolean(true);
     Response.AppendInt32(5);
     Response.AppendBoolean(true);
     Response.AppendInt32(10000);
     Response.AppendInt32(48);
     Response.AppendInt32(7);
     Client.SendResponse(Response);
 }
Exemplo n.º 13
0
        public void PurchaseItem(int Id, Client Client, string ExtraData, int PageId)
        {
            ShopItem Item = null;

            if ((Item = GetShopItem(Id)) == null)
            {
                return;
            }

            Boolean CreditsToLow = false;
            Boolean PixelsToLow = false;

            if (Client.GetUser().Credits < Item.CreditsCost)
            {
                CreditsToLow = true;
            }

            if (Client.GetUser().Pixels < Item.PixelsCost)
            {
                PixelsToLow = true;
            }

            if (CreditsToLow || PixelsToLow)
            {
                Response Response = new Response(68);
                Response.AppendBoolean(CreditsToLow);
                Response.AppendBoolean(PixelsToLow);
                Client.SendResponse(Response);
                return;
            }

            if (Item.CreditsCost > 0)
            {
                Client.GetUser().Credits -= Item.CreditsCost;
                Client.GetUser().UpdateCredits(true);
            }

            if (Item.PixelsCost > 0)
            {
                Client.GetUser().Pixels -= Item.PixelsCost;
                Client.GetUser().UpdatePixels(true);
            }

            if (!Item.GetBaseItem(Item.InternalItemIds[0]).InternalType.ToLower().Equals("e"))
            {
                if (Item.GetBaseItem(Item.InternalItemIds[0]).ExternalType.ToLower().Equals("membership"))
                {
                    Client.SendResponse(Item.GetPurchaseResponse(true));

                    ShopClubItem ClubItem = GetClubItem(Id);

                    if (Item == null)
                    {
                        return;
                    }

                    int Type = (ClubItem.MemberShipType.ToUpper() == "VIP") ? 1 : 0;
                    int Months = ClubItem.MonthsAmount;

                    BrickEngine.GetMembershipHandler().DeliverMembership(Client.GetUser().HabboId, Type, Months);

                    BrickEngine.GetPacketHandler().GetMembershipParams(Client, null);

                    Response Rights = new Response(2);

                    if (Client.GetUser().GetMembership() != null)
                    {
                        Rights.AppendInt32(Type + 1);
                    }
                    else
                    {
                        Rights.AppendInt32(0);
                    }

                    Client.SendResponse(Rights);

                    BrickEngine.GetAchievementReactor().UpdateUsersAchievement(Client, 8);
                    BrickEngine.GetAchievementReactor().UpdateUsersAchievement(Client, 9);
                }
                else
                {
                    if (Item.IsDeal)
                    {
                        var FloorItems = new List<int>();
                        var WallItems = new List<int>();

                        Client.SendResponse(Item.GetPurchaseResponse(false));

                        Response ShowItems = new Response(832);
                        ShowItems.AppendInt32(Item.InternalItemIds.Count);

                        for (int i = 0; i < Item.Amount; i++)
                        {
                            foreach (int ItemId in Item.InternalItemIds)
                            {
                                if (Item.GetBaseItem(ItemId).InternalType.ToLower().Equals("s"))
                                {
                                    FloorItems.Add(BrickEngine.GetItemReactor().InsertItem(Client.GetUser().HabboId, ItemId, ExtraData, -1));
                                }
                                else
                                {
                                    WallItems.Add(BrickEngine.GetItemReactor().InsertItem(Client.GetUser().HabboId, ItemId, ExtraData, -1));
                                }
                            }
                        }

                        ShowItems.AppendInt32(1);
                        ShowItems.AppendInt32(FloorItems.Count);

                        foreach (int ItemId in FloorItems)
                        {
                            ShowItems.AppendInt32(ItemId);
                        }

                        ShowItems.AppendInt32(2);
                        ShowItems.AppendInt32(WallItems.Count);

                        foreach (int ItemId in WallItems)
                        {
                            ShowItems.AppendInt32(ItemId);
                        }

                        Client.SendResponse(ShowItems);
                    }
                    else
                    {
                        if (Item.GetBaseItem(Item.InternalItemIds[0]).InternalName.ToLower().Contains("pet"))
                        {
                            string[] PetData = ExtraData.Split('\n');

                            int PetType = -1;
                            int PetRace = -1;
                            string PetName = string.Empty;
                            string PetColor = string.Empty;

                            PetType = Convert.ToInt32(Item.GetBaseItem(Item.InternalItemIds[0]).InternalName.ToLower().Substring(6));
                            PetRace = Convert.ToInt32(PetData[1]);
                            PetName = PetData[0];
                            PetColor = PetData[2];

                            int PetId = BrickEngine.GetPetReactor().GeneratePet(Client.GetUser().HabboId, PetType, PetRace, PetColor, PetName);

                            Response ShowPet = new Response(832);
                            ShowPet.AppendInt32(Item.Amount);
                            ShowPet.AppendInt32(3);
                            ShowPet.AppendInt32(Item.Amount);
                            ShowPet.AppendInt32(PetId);
                            Client.SendResponse(ShowPet);

                            Response AddMessage = new Response(603);
                            BrickEngine.GetPetReactor().GetPetInfo(PetId).GetInventoryResponse(AddMessage);
                            Client.SendResponse(AddMessage);
                        }

                        Response ShowItem = new Response(832);
                        ShowItem.AppendInt32(Item.Amount);
                        ShowItem.AppendInt32(Item.GetBaseItem(Item.InternalItemIds[0]).InternalType.ToLower().Equals("s") ? 1 : 2);
                        ShowItem.AppendInt32(Item.Amount);

                        Client.SendResponse(Item.GetPurchaseResponse(false));

                        for (int i = 0; i < Item.Amount; i++)
                        {
                            ShowItem.AppendInt32(BrickEngine.GetItemReactor().InsertItem(Client.GetUser().HabboId, Item.InternalItemIds[0], ExtraData, -1));
                        }

                        Client.SendResponse(ShowItem);
                    }

                    Client.SendResponse(new Response(101));
                }
            }
            else
            {
                if (Item.IsDeal)
                {
                    Client.SendResponse(Item.GetPurchaseResponse(false));

                    for (int i = 0; i < Item.Amount; i++)
                    {
                        foreach (int ItemId in Item.InternalItemIds)
                        {
                            BrickEngine.GetEffectsHandler().InsertEffect(Client, Item.GetBaseItem(ItemId).SpriteId, Item.GetBaseItem(ItemId).InteractorAmount);
                        }
                    }
                }
                else
                {
                    Client.SendResponse(Item.GetPurchaseResponse(false));

                    for (int i = 0; i < Item.Amount; i++)
                    {
                        BrickEngine.GetEffectsHandler().InsertEffect(Client, Item.GetBaseItem(Item.InternalItemIds[0]).SpriteId, Item.GetBaseItem(Item.InternalItemIds[0]).InteractorAmount);
                    }
                }
            }

            if (Item.CreditsCost > 0)
            {
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("INSERT INTO user_transactions (user_id, datetime, activity) VALUES (@user_id, @datetime, @activity)");
                    Reactor.AddParam("user_id", Client.GetUser().HabboId);
                    Reactor.AddParam("datetime", DateTime.Now);
                    Reactor.AddParam("activity", -Item.CreditsCost);
                    Reactor.ExcuteQuery();
                }
            }
        }
Exemplo n.º 14
0
        public void GetNavigatorResponse(Response Response, Boolean AllowEvents)
        {
            Response.AppendInt32(Id);
            Response.AppendBoolean(AllowEvents);
            Response.AppendStringWithBreak((AllowEvents) ? Event.Name : Name);
            Response.AppendStringWithBreak(BrickEngine.GetUserReactor().GetUsername(OwnerId));
            Response.AppendInt32(DoorState);
            Response.AppendInt32(RoomUserAmount);
            Response.AppendInt32(LimitUsers);
            Response.AppendStringWithBreak((AllowEvents) ? Event.Description : Description);
            Response.AppendBoolean(false);
            Response.AppendBoolean(BrickEngine.GetNavigatorManager().GetPrivateCategory(CategoryId).EnableTrading);
            Response.AppendInt32(Rating);
            Response.AppendInt32((AllowEvents) ? Event.CategoryId : CategoryId);

            if (AllowEvents)
            {
                Response.AppendString(Event.Started.ToShortTimeString());
            }

            Response.AppendChar(2);
            Response.AppendInt32((AllowEvents) ? Event.Tags.Count : Tags.Count);

            if (AllowEvents)
            {
                Event.Tags.ToList().ForEach(Response.AppendStringWithBreak);
            }
            else
            {
                Tags.ToList().ForEach(Response.AppendStringWithBreak);
            }

            Icon.GetResponse(Response);

            Response.AppendBoolean(true);
            Response.AppendBoolean(false);
        }
Exemplo n.º 15
0
        public void GetRestResponse(Client Client)
        {
            Response UsersWithoutMe = new Response(28); // Users without me (before me)
            UsersWithoutMe.AppendInt32(GetRoomEngine().UnitCount); // UsersCount

            foreach (VirtualRoomUser User in GetRoomEngine().GetUsers())
            {
                User.GetResponse(UsersWithoutMe);
            }

            foreach (VirtualRoomUser Pet in GetRoomEngine().GetPets())
            {
                Pet.GetResponse(UsersWithoutMe);
            }

            Client.SendResponse(UsersWithoutMe);

            Response StaticFurni = new Response(30);
            StaticFurni.AppendBoolean(false); // Habbo leaves Public Rooms?
            Client.SendResponse(StaticFurni);

            Response FloorItems = new Response(32);
            FloorItems.AppendInt32(GetRoomEngine().GetFloorItems().Count); // ItemCount

            foreach (Item FloorItem in GetRoomEngine().GetFloorItems())
            {
                FloorItem.GetRoomResponse(FloorItems);
            }

            Client.SendResponse(FloorItems);

            Response WallItems = new Response(45);
            WallItems.AppendInt32(GetRoomEngine().GetWallItems().Count); // ItemCount

            foreach (Item WallItem in GetRoomEngine().GetWallItems())
            {
                WallItem.GetRoomResponse(WallItems);
            }

            Client.SendResponse(WallItems);

            if (GetRoomEngine().GenerateRoomUser(Client) != null)
            {
                Response UsersWithMe = new Response(28); // Users with me (after me)
                UsersWithMe.AppendInt32(GetRoomEngine().UnitCount); // UsersCount

                foreach (VirtualRoomUser User in GetRoomEngine().GetUsers())
                {
                    User.GetResponse(UsersWithMe);

                    if (User.DanceId > 0)
                    {
                        Response Dance = new Response(480);
                        Dance.AppendInt32(User.VirtualId);
                        Dance.AppendInt32(User.DanceId);
                        Client.SendResponse(Dance);
                    }

                    if (User.Suppressed)
                    {
                        Response Suppressed = new Response(486);
                        Suppressed.AppendInt32(User.VirtualId);
                        Suppressed.AppendBoolean(true);
                        Client.SendResponse(Suppressed);
                    }

                    if (BrickEngine.GetEffectsHandler().UserHasRunningEffect(User.HabboId))
                    {
                        Response Response = new Response(485);
                        Response.AppendInt32(User.VirtualId);
                        Response.AppendInt32(BrickEngine.GetEffectsHandler().GetRunningEffect(User.HabboId).EffectId);
                        Client.SendResponse(Response);
                    }
                }

                foreach (VirtualRoomUser Pet in GetRoomEngine().GetPets())
                {
                    Pet.GetResponse(UsersWithMe);
                }

                Client.SendResponse(UsersWithMe);
            }
            else
            {
                BrickEngine.GetPacketHandler().ClearLoading(Client, true);
                return;
            }

            if (BrickEngine.GetEffectsHandler().UserHasRunningEffect(Client.GetUser().HabboId))
            {
                Response Response = new Response(485);
                Response.AppendInt32(Client.GetUser().GetRoomUser().VirtualId);
                Response.AppendInt32(BrickEngine.GetEffectsHandler().GetRunningEffect(Client.GetUser().HabboId).EffectId);
                Client.SendResponse(Response);
            }

            Response Additionals = new Response(472);
            Additionals.AppendBoolean(AllowHideWall);
            Additionals.AppendInt32(WallThick);
            Additionals.AppendInt32(FloorThick);
            Client.SendResponse(Additionals);

            int HabboId = Client.GetUser().HabboId;

            if (GetRoomEngine().HasRights(Client.GetUser().HabboId, RightsType.Founder))
            {
                Client.SendResponse(new Response(47));
                Client.SendResponse(new Response(42));

                VirtualRoomUser myUser = GetRoomEngine().GetUserByHabboId(Client.GetUser().HabboId);
                myUser.AddStatus("flatctrl useradmin", "");
            }
            else if (GetRoomEngine().HasRights(Client.GetUser().HabboId, RightsType.Rights))
            {
                Client.SendResponse(new Response(42));

                VirtualRoomUser myUser = GetRoomEngine().GetUserByHabboId(Client.GetUser().HabboId);
                myUser.AddStatus("flatctrl", "");
            }

            Response Extra = new Response(471);
            Extra.AppendBoolean(true);
            Extra.AppendInt32(Id);
            Extra.AppendBoolean(GetRoomEngine().HasRights(Client.GetUser().HabboId,RightsType.Founder)); // Enable Editing
            Client.SendResponse(Extra);

            Response Statusses = new Response(34);
            Statusses.AppendInt32(GetRoomEngine().UnitCount); // UsersCount

            foreach (VirtualRoomUser User in GetRoomEngine().GetUsers())
            {
                User.GetStatusResponse(Statusses);
            }

            foreach (VirtualRoomUser Pet in GetRoomEngine().GetPets())
            {
                Pet.GetStatusResponse(Statusses);
            }

            Client.SendResponse(Statusses);

            Client.SendResponse(new Response(208));

            Response RoomCache = new Response(454);
            RoomCache.AppendBoolean(true);
            GetNavigatorResponse(RoomCache, false);
            Client.SendResponse(RoomCache);
        }
Exemplo n.º 16
0
        public void TakeBackItem(Client Client, int OfferId)
        {
            MarketOffer Offer = GetOffer(OfferId);

            if (Offer == null)
            {
                return;
            }

            if (Offer.UserId != Client.GetUser().HabboId)
            {
                return;
            }

            // Update @ list
            Response Response = new Response(614);
            Response.AppendInt32(Offer.Id);
            Response.AppendBoolean(true);
            Client.SendResponse(Response);

            Response ItemUpdate = new Messages.Response(832);
            ItemUpdate.AppendInt32(1);
            ItemUpdate.AppendInt32(Offer.GetBaseItem().InternalType.ToLower().Equals("s") ? 1 : 2);
            ItemUpdate.AppendInt32(1);
            ItemUpdate.AppendInt32(BrickEngine.GetItemReactor().InsertItem(Client.GetUser().HabboId, Offer.BaseId, string.Empty, -1));
            Client.SendResponse(ItemUpdate);

            Client.SendResponse(new Response(101));

            Offers.Remove(Offer.Id);

            // DELETE @ SQL
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM marketplace_offers WHERE id = @offerid LIMIT 1");
                Reactor.AddParam("offerid", Offer.Id);
                Reactor.ExcuteQuery();
            }
        }
Exemplo n.º 17
0
 private void ActivateLoading(Client Client, Request Request)
 {
     Response Response = new Response(297);
     Response.AppendBoolean(false);
     Client.SendResponse(Response);
 }
Exemplo n.º 18
0
        private void BeginEditRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int RoomId = Request.PopWiredInt32();

            VirtualRoom Room = BrickEngine.GetRoomReactor().GetVirtualRoom(RoomId, RoomRunningState.Alive);

            if (Room == null)
            {
                return;
            }

            if (!Room.GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                return;
            }

            Response Response = new Response(465);
            Response.AppendInt32(RoomId);
            Response.AppendStringWithBreak(Room.Name);
            Response.AppendStringWithBreak(Room.Description);
            Response.AppendInt32(Room.DoorState);
            Response.AppendInt32(Room.CategoryId);
            Response.AppendInt32(Room.LimitUsers);
            Response.AppendInt32(Room.GetRoomModel().LimitUsers);
            Response.AppendInt32(Room.Tags.Count);
            Room.Tags.ForEach(Response.AppendStringWithBreak);

            Response.AppendInt32(Room.GetRoomEngine().GetUsersWithRights().Count);

            foreach (int UserId in Room.GetRoomEngine().GetUsersWithRights())
            {
                Response.AppendInt32(UserId);
                Response.AppendStringWithBreak(BrickEngine.GetUserReactor().GetUsername(UserId));
            }

            Response.AppendInt32(Room.GetRoomEngine().GetUsersWithRights().Count);

            Response.AppendBoolean(Room.AllowPets);
            Response.AppendBoolean(Room.AllowPetsEat);
            Response.AppendBoolean(Room.AllowWalkthough);
            Response.AppendBoolean(Room.AllowHideWall);
            Response.AppendInt32(Room.WallThick);
            Response.AppendInt32(Room.FloorThick);
            Client.SendResponse(Response);
        }
Exemplo n.º 19
0
        private void EndEditRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int RoomId = Request.PopWiredInt32();

            VirtualRoom Room = BrickEngine.GetRoomReactor().GetVirtualRoom(RoomId, RoomRunningState.Alive);

            if (Room == null)
            {
                return;
            }

            if (!Room.GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                return;
            }

            string Name = BrickEngine.CleanString(Request.PopFixedString());
            string Description = BrickEngine.CleanString(Request.PopFixedString());
            int DoorState = Request.PopWiredInt32();
            string Password = BrickEngine.CleanString(Request.PopFixedString());
            int LimitUsers = Request.PopWiredInt32();

            int CategoryId = Request.PopWiredInt32();

            PrivateCategory Category = BrickEngine.GetNavigatorManager().GetPrivateCategory(CategoryId);

            if (Category == null)
            {
                CategoryId = 0;
            }

            if (Client.GetUser().Rank < Category.RankAllowed)
            {
                Client.Notif("You're not allowed to use this category.", false);
                CategoryId = 0;
            }

            int TagAmount = Request.PopWiredInt32();

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

            for (int i = 0; i < TagAmount; i++)
            {
                string Tag = BrickEngine.CleanString(Request.PopFixedString()).Trim().ToLower();

                if (Tag.Length > 32)
                {
                    Tag = Tag.Substring(0, 32);
                }

                if (Tag.Length > 0 && !Tags.Contains(Tag))
                {
                    Tags.Add(Tag);
                }
            }

            Boolean AllowPets = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            Boolean AllowPetsEat = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            Boolean AllowWalkthough = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            Boolean AllowHideWall = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            int WallThick = Request.PopWiredInt32();

            if (WallThick < -2 || WallThick > 1)
            {
                WallThick = 0;
            }

            int FloorThick = Request.PopWiredInt32();

            if (FloorThick < -2 || FloorThick > 1)
            {
                FloorThick = 0;
            }

            if (Name.Length > 60)
            {
                Name = Name.Substring(0, 60);
            }

            if (Description.Length > 128)
            {
                Description = Description.Substring(0, 128);
            }

            if (Password.Length > 64)
            {
                Password = Password.Substring(0, 64);
            }

            if (LimitUsers > Client.GetUser().GetRoom().GetRoomModel().LimitUsers)
            {
                LimitUsers = Client.GetUser().GetRoom().GetRoomModel().LimitUsers;
            }

            if (DoorState == 2 && Password.Length <= 0)
            {
                DoorState = 0;
            }

            Dictionary<string, Object> Params = new Dictionary<string, object>();

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

            if (!Room.Name.Equals(Name))
            {
                Commands.Add("name = @name");
                Params.Add("name", Name);
                Room.Name = Name;
            }

            if (!Room.Description.Equals(Description))
            {
                Commands.Add("description = @desc");
                Params.Add("desc", Description);
                Room.Description = Description;
            }

            if (!Room.DoorState.Equals(DoorState))
            {
                Commands.Add("door_state = @door");
                Params.Add("door", DoorState);
                Room.DoorState = DoorState;
            }

            if (!Room.Password.Equals(Password))
            {
                Commands.Add("password = @pw");
                Params.Add("pw", Password);
                Room.Password = Password;
            }

            if (!Room.LimitUsers.Equals(LimitUsers))
            {
                Commands.Add("limit_users = @limit");
                Params.Add("limit", LimitUsers);
                Room.LimitUsers = LimitUsers;
            }

            if (!Room.CategoryId.Equals(CategoryId))
            {
                Commands.Add("category_id = @catid");
                Params.Add("catid", CategoryId);
                Room.CategoryId = CategoryId;
            }

            if (!Room.Tags.Equals(Tags))
            {
                string SplittedTags = string.Empty;

                int x = 0;

                foreach (string Tag in Tags)
                {
                    if (x > 0)
                    {
                        SplittedTags += ',';
                    }

                    SplittedTags += Tag.ToLower();

                    x++;
                }

                Commands.Add("tags = @tags");
                Params.Add("tags", SplittedTags.ToString());
                Room.Tags = Tags;
            }

            if (!Room.AllowPets.Equals(AllowPets))
            {
                Commands.Add("allow_pets = @allow_pets");
                Params.Add("allow_pets", AllowPets ? 1 : 0);
                Room.AllowPets = AllowPets;
            }

            if (!Room.AllowPetsEat.Equals(AllowPetsEat))
            {
                Commands.Add("allow_pets_eat = @allow_pets_eat");
                Params.Add("allow_pets_eat", AllowPetsEat ? 1 : 0);
                Room.AllowPetsEat = AllowPetsEat;
            }

            if (!Room.AllowWalkthough.Equals(AllowWalkthough))
            {
                Commands.Add("allow_walkthough = @allow_walkthough");
                Params.Add("allow_walkthough", AllowWalkthough ? 1 : 0);
                Room.AllowWalkthough = AllowWalkthough;
            }

            if (!Room.AllowHideWall.Equals(AllowHideWall))
            {
                Commands.Add("allow_hidewall = @allow_hidewall");
                Params.Add("allow_hidewall", AllowHideWall ? 1 : 0);
                Room.AllowHideWall = AllowHideWall;
            }

            if (!Room.WallThick.Equals(WallThick))
            {
                Commands.Add("walls_thick = @walls_thick");
                Params.Add("walls_thick", WallThick);
                Room.WallThick = WallThick;
            }

            if (!Room.FloorThick.Equals(FloorThick))
            {
                Commands.Add("floors_thick = @floors_thick");
                Params.Add("floors_thick", FloorThick);
                Room.FloorThick = FloorThick;
            }

            Response Data = new Response(454);
            Data.AppendBoolean(true);
            Room.GetNavigatorResponse(Data, false);
            Client.SendRoomResponse(Data);

            Response Response = new Response();
            Response.Initialize(467);
            Response.AppendInt32(Client.GetUser().RoomId);
            Response.Initialize(456);
            Response.AppendInt32(Client.GetUser().RoomId);
            Client.SendResponse(Response);

            Response RoomStruct = new Response(472);
            RoomStruct.AppendBoolean(AllowHideWall);
            RoomStruct.AppendInt32(WallThick);
            RoomStruct.AppendInt32(FloorThick);
            Client.SendRoomResponse(RoomStruct);

            if (Commands.Count > 0)
            {
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    StringBuilder Builder = new StringBuilder();
                    Builder.Append("UPDATE private_rooms SET ");

                    int i = 0;

                    foreach (string Command in Commands)
                    {
                        i++;
                        Builder.Append(Command);

                        if (i < Commands.Count)
                        {
                            Builder.Append(", ");
                        }
                    }

                    Builder.Append(" WHERE id = @roomid LIMIT 1");

                    Reactor.SetQuery(Builder.ToString());

                    foreach (KeyValuePair<string, Object> kvp in Params)
                    {
                        Reactor.AddParam(kvp.Key, kvp.Value);
                    }

                    Reactor.AddParam("roomid", Room.Id);

                    Reactor.ExcuteQuery();
                }
            }
        }
Exemplo n.º 20
0
        private void SerializePetRaces(Client Client, Request Request)
        {
            string PetType = Request.PopFixedString();

            int Type = Convert.ToInt32(PetType.Substring(6));

            if (Type < 0)
            {
                return;
            }

            Response Response = new Response(827);

            PetRace PetRace = BrickEngine.GetShopReactor().SelectPetRace(Type);

            if (PetRace == null)
            {
                System.Data.DataRow Row = new DataTable().Rows[0];

                Row[0] = 1;
                Row[1] = Type;
                Row[2] = 0;
                Row[3] = 0;

                PetRace = new PetRace(Row);
            }

            Response.AppendStringWithBreak("a0 pet" + Type);
            Response.AppendInt32(PetRace.RaceAmount);

            for (int i = PetRace.StartIndexer; i < PetRace.RaceAmount; i++)
            {
                Response.AppendInt32(Type);
                Response.AppendInt32(i);
                Response.AppendBoolean(true);
                Response.AppendBoolean(false);
            }

            Client.SendResponse(Response);
        }
Exemplo n.º 21
0
        // 473
        private void GetShopInfoB(Client Client, Request Request)
        {
            Response Response = new Response(620);
            Response.AppendBoolean(true);
            Response.AppendBoolean(true);
            Response.AppendInt32(10);

            for (int i = 3064; i < 3074; i++)
            {
                Response.AppendInt32(i);
            }

            Response.AppendInt32(7);

            for (int i = 0; i < 7; i++)
            {
                Response.AppendInt32(i);
            }

            Response.AppendInt32(11);

            for (int i = 0; i < 11; i++)
            {
                Response.AppendInt32(i);
            }

            Client.SendResponse(Response);
        }
Exemplo n.º 22
0
        public void GetResponse(Response Response, Client Client)
        {
            int Next = GetNextLevel(Client);

            Response.AppendInt32(Id);
            Response.AppendInt32(Next);
            Response.AppendStringWithBreak(GetBadgeCode(Next));
            Response.AppendInt32(GetNeeded(Next));
            Response.AppendInt32(GetPixelReward(Next));
            Response.AppendBoolean(false);
            Response.AppendInt32(BrickEngine.GetAchievementReactor().GetGotAmount(Client, Id)); // GotAmount;
            Response.AppendBoolean(CompletedAchievement(Client));
            Response.AppendStringWithBreak(Category.Name.ToLower());
            Response.AppendInt32(MaxLevel);
        }
Exemplo n.º 23
0
 public void GetResponse(Response Response)
 {
     Response.AppendInt32(EffectId);
     Response.AppendInt32(EffectLength);
     Response.AppendBoolean(!IsActivated);
     Response.AppendInt32(RemainingTime);
 }
Exemplo n.º 24
0
        public void InsertOffer(Client Client, Item Item, int GeneralPrice)
        {
            Response Response = new Response(610);

            // Verifying.
            if (GeneralPrice > 10000 || !Item.GetBaseItem().EnableAuction)
            {
                Response.AppendBoolean(false);
                Client.SendResponse(Response);
                return;
            }

            // OfferDetails
            int OfferId = OfferIdCounter.Next;

            // Developmentdetails
            int DevelopmentId = DevelopmentIdCounter.Next;

            // Both details
            int TotalPrice = (GeneralPrice + GetPriceCommission(GeneralPrice));
            DateTime DateTime = DateTime.Now;

            // Generating offer, and adding offer
            Dictionary<int, Object> OfferRow = new Dictionary<int, object>();

            OfferRow[0] = OfferId;
            OfferRow[1] = Client.GetUser().HabboId;
            OfferRow[2] = Item.BaseId;
            OfferRow[3] = 1;
            OfferRow[4] = Item.GetBaseItem().InternalName.ToLower();
            OfferRow[5] = GeneralPrice;
            OfferRow[6] = TotalPrice;
            OfferRow[7] = DateTime;

            // Generating from leak-row
            MarketOffer Offer = new MarketOffer(OfferRow);

            Offers.Add(Offer.Id, Offer);

            // Generating development, and adding development
            Dictionary<int, Object> DevelopmentRow = new Dictionary<int, object>();

            DevelopmentRow[0] = DevelopmentId;
            DevelopmentRow[1] = Item.BaseId;
            DevelopmentRow[2] = DateTime;
            DevelopmentRow[3] = TotalPrice;

            // Generating from leak-row
            MarketDevelopment Development = new MarketDevelopment(DevelopmentRow);

            Developments.Add(Development.Id, Development);

            // Sending positive response
            Response.AppendBoolean(true);
            Client.SendResponse(Response);

            // Delete furniture @ cache + response update
            Client.SendResponse(BrickEngine.GetItemReactor().RemoveItem(Item.Id));

            // Delete furniture @ database
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM items WHERE id = @itemid LIMIT 1");
                Reactor.AddParam("itemid", Item.Id);
                Reactor.ExcuteQuery();
            }

            // Insert Offer @ database
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("INSERT INTO marketplace_offers (user_id, base_id, base_name, credits_request, credits_request_tot, datetime) VALUES (@habboid, @baseid, @basename, @creditsreq, @creditsreqtot, @datetime)");
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.AddParam("baseid", Item.BaseId);
                Reactor.AddParam("basename", Item.GetBaseItem().InternalName.ToLower());
                Reactor.AddParam("creditsreq", GeneralPrice);
                Reactor.AddParam("creditsreqtot", TotalPrice);
                Reactor.AddParam("datetime", DateTime);
                Reactor.ExcuteQuery();
            }

            // Insert Development @ database
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("INSERT INTO marketplace_development (base_id, datetime, credits_request) VALUES (@baseid, @datetime, @creditsreq)");
                Reactor.AddParam("baseid", Item.BaseId);
                Reactor.AddParam("datetime", DateTime);
                Reactor.AddParam("creditsreq", TotalPrice);
                Reactor.ExcuteQuery();
            }

            // Update tickets @ cache
            Client.GetUser().MarketplaceTickets--;

            // Update tickets @ database
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE users SET marketplace_tickets = marketplace_tickets - 1 WHERE id = @habboid LIMIT 1");
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.ExcuteQuery();
            }
        }
Exemplo n.º 25
0
        private void UpdateFavorite(Client Client, Request Request)
        {
            int RoomId = Request.PopWiredInt32();

            string Query = string.Empty;

            Response Response = new Response(459);
            Response.AppendInt32(RoomId);

            if (Client.GetUser().FavoriteRoomIds.Contains(RoomId))
            {
                Client.GetUser().FavoriteRoomIds.Remove(RoomId);

                Query = "DELETE FROM user_favorite_rooms WHERE user_id = @habboid AND room_id = @roomid LIMIT 1";

                Response.AppendBoolean(false);
            }
            else
            {
                Client.GetUser().FavoriteRoomIds.Add(RoomId);

                Query = "INSERT INTO user_favorite_rooms (user_id, room_id) VALUES (@habboid, @roomid)";

                Response.AppendBoolean(true);
            }

            Client.SendResponse(Response);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery(Query);
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.AddParam("roomid", RoomId);
                Reactor.ExcuteQuery();
            }
        }
Exemplo n.º 26
0
        private void GetEventMenu(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                return;
            }

            Response Response = new Response(367);
            Response.AppendBoolean(true);
            Response.AppendBoolean(false);
            Client.SendResponse(Response);
        }
Exemplo n.º 27
0
        private void UpdateRoomIcon(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int Q = Request.PopWiredInt32();

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                return;
            }

            var Icons = new Dictionary<int, int>();

            int BackgroundIcon = Request.PopWiredInt32();

            if (BackgroundIcon < 1 || BackgroundIcon > 24)
            {
                BackgroundIcon = 1;
            }

            int ForegroundIcon = Request.PopWiredInt32();

            if (ForegroundIcon < 0 || ForegroundIcon > 11)
            {
                ForegroundIcon = 0;
            }

            int IconsAmount = Request.PopWiredInt32();

            for (int i = 0; i < IconsAmount; i++)
            {
                int SlotId = Request.PopWiredInt32();
                int Icon = Request.PopWiredInt32();

                if (SlotId < 0 || SlotId > 10 || Icon < 1 || Icon > 27)
                {
                    continue;
                }

                if (!Icons.ContainsKey(SlotId))
                {
                    Icons.Add(SlotId, Icon);
                }
            }

            int x = 0;

            StringBuilder Query = new StringBuilder();

            foreach (KeyValuePair<int, int> kvp in Icons)
            {
                if (x < Icons.Count)
                {
                    Query.Append(',');
                }

                Query.Append(kvp.Key);
                Query.Append('.');
                Query.Append(kvp.Value);

                x++;
            }

            Client.GetUser().GetRoom().Icon = new RoomIcon(Client.GetUser().GetRoom().Id, BackgroundIcon, ForegroundIcon, Query.ToString());

            Response Response = new Response();
            Response.Initialize(457);
            Response.AppendInt32(Client.GetUser().RoomId);
            Response.AppendBoolean(true);
            Response.Initialize(456);
            Response.AppendInt32(Client.GetUser().RoomId);
            Client.SendResponse(Response);

            Response Data = new Response(454);
            Data.AppendBoolean(false);
            Client.GetUser().GetRoom().GetNavigatorResponse(Data, false);
            Client.SendRoomResponse(Data);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE private_rooms SET nav_icon_bg = @bg, nav_icon_fg = @fg, nav_icons = @icons WHERE id = @roomid LIMIT 1");
                Reactor.AddParam("bg", BackgroundIcon);
                Reactor.AddParam("fg", ForegroundIcon);
                Reactor.AddParam("icons", Query.ToString());
                Reactor.AddParam("roomid", Client.GetUser().RoomId);
                Reactor.ExcuteQuery();
            }
        }
Exemplo n.º 28
0
        public void PurchaseOffer(int OfferId, Client Client)
        {
            MarketOffer Offer = GetOffer(OfferId);

            if (Offer == null)
            {
                return;
            }

            if (Client.GetUser().Credits < Offer.CreditsRequestTot)
            {
                Response Response = new Response(68);
                Response.AppendBoolean(true);
                Response.AppendBoolean(false);
                Client.SendResponse(Response);
                return;
            }

            Offer.State = 2;

            Client.GetUser().Credits -= Offer.CreditsRequestTot;
            Client.GetUser().UpdateCredits(true);

            Response ItemUpdate = new Messages.Response(832);
            ItemUpdate.AppendInt32(1);
            ItemUpdate.AppendInt32(Offer.GetBaseItem().InternalType.ToLower().Equals("s") ? 1 : 2);
            ItemUpdate.AppendInt32(1);
            ItemUpdate.AppendInt32(BrickEngine.GetItemReactor().InsertItem(Client.GetUser().HabboId, Offer.BaseId, string.Empty, -1));
            Client.SendResponse(ItemUpdate);

            Client.SendResponse(new Response(101));

            Client.SendResponse(Offer.GetPurchaseResponse());

            Client.SendResponse(GetResponse(-1, -1, string.Empty, 1));

            // Update @ database
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE marketplace_offers SET state = '2' WHERE id = @offerid LIMIT 1");
                Reactor.AddParam("offerid", Offer.Id);
                Reactor.ExcuteQuery();
            }

            if (Offer.CreditsRequestTot > 0)
            {
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("INSERT INTO user_transactions (user_id, datetime, activity, description) VALUES (@user_id, @datetime, @activity, @description)");
                    Reactor.AddParam("user_id", Client.GetUser().HabboId);
                    Reactor.AddParam("datetime", DateTime.Now);
                    Reactor.AddParam("activity", -Offer.CreditsRequestTot);
                    Reactor.AddParam("description", "Marketplace Purchase");
                    Reactor.ExcuteQuery();
                }
            }
        }
Exemplo n.º 29
0
        public Response GetUnlockResponse(Client Client)
        {
            int Level = GetNextLevel(Client);
            int OldLevel = (Level - 1);

            if (OldLevel <= 0)
            {
                OldLevel = 1;
            }

            string OldBadge = GetBadgeCode(OldLevel);
            string NewBadge = GetBadgeCode(Level);

            int OldBadgeId = BrickEngine.GetBadgeHandler().GetIdForBadge(OldBadge);
            int NewBadgeId = BrickEngine.GetBadgeHandler().GetIdForBadge(NewBadge);

            int ScoreReward = GetScoreReward(Level);
            int PixelReward = GetPixelReward(Level);

            Response Response = new Response(437);
            Response.AppendInt32(Id);
            Response.AppendInt32(Level);
            Response.AppendInt32(NewBadgeId);
            Response.AppendStringWithBreak(NewBadge);
            Response.AppendInt32(ScoreReward);
            Response.AppendInt32(PixelReward);
            Response.AppendBoolean(false);
            Response.AppendInt32(ExtraScore);
            Response.AppendInt32(OldBadgeId);
            Response.AppendStringWithBreak(OldBadge);
            Response.AppendStringWithBreak(Category.Name.ToLower());

            return Response;
        }
Exemplo n.º 30
0
        public void GiveRespect()
        {
            Respect++;

            if (IsInRoom)
            {
                Response Response = new Response(606);
                Response.AppendInt32(Respect);
                Response.AppendInt32(UserId);
                Response.AppendInt32(Id);
                Response.AppendStringWithBreak(Name);
                Response.AppendBoolean(false);
                Response.AppendInt32(10);
                Response.AppendBoolean(false);
                Response.AppendInt32(-2);
                Response.AppendBoolean(true);
                Response.AppendChar(2);
                GetRoom().GetRoomEngine().BroadcastResponse(Response);
            }

            GiveExpirience(10);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE user_pets SET respect = respect + 1 WHERE id = @petid LIMIT 1");
                Reactor.AddParam("petid", Id);
                Reactor.ExcuteQuery();
            }
        }