Пример #1
0
 private void GetEcotronInfo(Client Client, Request Request)
 {
     Response Response = new Response(507);
     Response.AppendInt32(BrickEngine.GetEcotronReactor().GetTimerTime(Client.GetUser().HabboId));
     Response.AppendInt32(BrickEngine.GetEcotronReactor().GetTimeToWait(Client.GetUser().HabboId));
     Client.SendResponse(Response);
 }
Пример #2
0
        private void CreateRoom(Client Client, Request Request)
        {
            int Limit = BrickEngine.GetConfigureFile().CallIntKey("max.rooms.amount");
            int RoomAmount = BrickEngine.GetRoomReactor().GetMe(Client.GetUser().HabboId).Count;

            if (RoomAmount >= Limit)
            {
                Client.Notif("You're over the rooms limit, first delete a room before you create a new one.", false);
                return;
            }

            string RawName = Request.PopFixedString();
            string RawModel = Request.PopFixedString();

            int RoomId = -1;

            if ((RoomId = BrickEngine.GetRoomReactor().CreateRoom(Client, RawName, RawModel)) > 0)
            {
                Response Response = new Response(59);
                Response.AppendInt32(RoomId);
                Response.AppendStringWithBreak(BrickEngine.CleanString(RawName));
                Client.SendResponse(Response);
            }
            else
            {
                CheckRoomCreate(Client, null);
            }
        }
Пример #3
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);
        }
Пример #4
0
        private void ChatWithFriend(Client Client, Request Request)
        {
            int FriendId = Request.PopWiredInt32();

            if (!BrickEngine.GetMessengerHandler().HasFriend(Client.GetUser().HabboId, FriendId))
            {
                return;
            }

            BrickEmulator.HabboHotel.Users.Handlers.Messenger.Friend Friend = BrickEngine.GetMessengerHandler().GetFriend(Client.GetUser().HabboId, FriendId);

            if (Friend == null)
            {
                Response Respose = new Response(261);
                Respose.AppendInt32(6);
                Respose.AppendInt32(FriendId);
                Client.SendResponse(Respose);
                return;
            }

            if (Client.GetUser().Muted)
            {
                Response Respose = new Response(261);
                Respose.AppendInt32(4);
                Respose.AppendInt32(FriendId);
                Client.SendResponse(Respose);
                return;
            }

            if (Friend.IsAlive)
            {
                if (Friend.GetClient().GetUser().Muted)
                {
                    Response Respose = new Response(261);
                    Respose.AppendInt32(3);
                    Respose.AppendInt32(FriendId);
                    Client.SendResponse(Respose);
                }

                Response Response = new Response(134);
                Response.AppendInt32(Client.GetUser().HabboId);
                Response.AppendStringWithBreak(BrickEngine.CleanString(Request.PopFixedString()));

                Friend.GetClient().SendResponse(Response);
            }
            else
            {
                Response Respose = new Response(261);
                Respose.AppendInt32(5);
                Respose.AppendInt32(FriendId);
                Client.SendResponse(Respose);
            }
        }
Пример #5
0
        public void OpenFeacturedRoom(Client Client, Request Request)
        {
            int RoomId = Request.PopWiredInt32();
            string Password = Request.PopFixedString();

            if (Client.GetUser().RoomId == RoomId)
            {
                return;
            }

            BeginLoadRoom(Client, RoomId, Password);
        }
Пример #6
0
        private void AlertSelectedUser(Client Client, Request Request)
        {
            int UserId = Request.PopWiredInt32();

            string Message = BrickEngine.CleanString(Request.PopFixedString());

            if (UserId <= 0)
            {
                return;
            }

            BrickEngine.GetToolReactor().AlertUser(Client, UserId, Message, false, false, false);
        }
Пример #7
0
        private void BanSelectedUser(Client Client, Request Request)
        {
            int UserId = Request.PopWiredInt32();

            string Reason = BrickEngine.CleanString(Request.PopFixedString());

            int DurationHours = Request.PopWiredInt32();

            if (UserId <= 0)
            {
                return;
            }

            BrickEngine.GetToolReactor().BanUser(Client, UserId, Reason, DurationHours, false);
        }
Пример #8
0
        private void AlertSelectedRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            // Avoid Junk
            Request.PopWiredInt32();

            Boolean Warning = !Request.PopWiredInt32().Equals(3);

            string Message = BrickEngine.CleanString(Request.PopFixedString());

            BrickEngine.GetToolReactor().AlertRoom(Client, Client.GetUser().RoomId, Message, Warning);
        }
Пример #9
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);
        }
Пример #10
0
        private void GetEcotronPackage(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int ItemAmount = Request.PopWiredInt32();

            if (ItemAmount < 5 || ItemAmount > 5)
            {
                return;
            }

            var ItemList = new List<int>();

            for (int i = 0; i < ItemAmount; i++)
            {
                int ItemId = Request.PopWiredInt32();

                ItemList.Add(ItemId);
            }

            if (BrickEngine.GetEcotronReactor().GainReward(Client))
            {
                foreach (int ItemId in ItemList)
                {
                    BrickEngine.GetItemReactor().RemoveItem(ItemId);
                }

                Client.SendResponse(new Response(101));

                foreach (int ItemId in ItemList)
                {
                    using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                    {
                        Reactor.SetQuery("DELETE FROM items WHERE id = @itemid LIMIT 1");
                        Reactor.AddParam("itemid", ItemId);
                        Reactor.ExcuteQuery();
                    }
                }
            }
        }
Пример #11
0
        private void GetPetsTool(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int PetId = Request.PopWiredInt32();

            VirtualRoomUser PetUser = Client.GetUser().GetRoom().GetRoomEngine().GetUserByPetId(PetId);

            if (PetUser == null)
            {
                return;
            }

            PetInfo Info = BrickEngine.GetPetReactor().GetPetInfo(PetId);

            if (Info == null)
            {
                return;
            }

            Response Response = new Response(605);
            Response.AppendInt32(PetId);
            Response.AppendInt32(PetReactor.MAX_LEVEL);

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

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

            Client.SendResponse(Response);
        }
Пример #12
0
        private void GetEcotronRewards(Client Client, Request Request)
        {
            Response Response = new Response(506);
            Response.AppendInt32(5);

            for (int i = 5; i > 0; i--)
            {
                var Items = BrickEngine.GetEcotronReactor().GetRewardsForLevel(i);

                Response.AppendInt32(i);
                Response.AppendInt32(BrickEngine.GetEcotronReactor().GetChangeByLevel(i));
                Response.AppendInt32(Items.Count);

                foreach (EcotronReward Item in Items)
                {
                    Response.AppendStringWithBreak(Item.GetBaseItem().InternalType.ToLower());
                    Response.AppendInt32(Item.GetBaseItem().SpriteId);
                }
            }

            Client.SendResponse(Response);
        }
Пример #13
0
        private void AcceptRequests(Client Client, Request Request)
        {
            int Amount = Request.PopWiredInt32();

            for (int i = 0; i < Amount; i++)
            {
                int UserId = Request.PopWiredInt32();

                BrickEmulator.HabboHotel.Users.Handlers.Messenger.Friend Friend = new BrickEmulator.HabboHotel.Users.Handlers.Messenger.Friend(UserId);

                if (Friend.IsAlive)
                {
                    // Send Response (come online) >> Friend
                    Friend.GetClient().SendResponse(BrickEngine.GetMessengerHandler().GetStatusMessage(Friend.HabboId, Client.GetUser(), true));

                    // Send Response (come online) >> MySELF
                    Client.SendResponse(BrickEngine.GetMessengerHandler().GetStatusMessage(Client.GetUser().HabboId, Friend.GetClient().GetUser(), true));
                }

                BrickEngine.GetMessengerHandler().AcceptRequest(UserId, Client.GetUser().HabboId);
            }
        }
Пример #14
0
        private void HandleTicket(Client Client, Request Request)
        {
            string Ticket = Request.PopFixedString();

            Client.ParseUser(BrickEngine.GetUserReactor().HandleTicket(Ticket));

            if (Client.IsValidUser)
            {
                if (BrickEngine.GetToolReactor().IsBanned(Client.GetUser().HabboId, Client.IPAddress))
                {
                    Client.Dispose();
                    return;
                }

                Response Userhash = new Response(439);
                Userhash.AppendStringWithBreak(Client.GetUser().Hash);
                Client.SendResponse(Userhash);

                Client.SendResponse(new Response(3));

                if (BrickEngine.GetConfigureFile().CallBooleanKey("welcomemessage.enabled"))
                {
                    Client.LongNotif(string.Empty);
                }

                Client.SendResponse(Client.GetUser().GetLoginResponse());

                Client.Authenticated = true;

                Client.SendResponse(BrickEngine.GetToolReactor().GetResponse(Client));
            }
            else
            {
                Client.Notif("Invalid Ticket, try again!", false);
                Client.Dispose();
            }
        }
Пример #15
0
        public void HandlePacket(Request Request, Client Client)
        {
            if (Request == null)
            {
                return;
            }

            if (BrickEngine.GetPacketHandler().ShowRequests)
            {
                BrickEngine.GetScreenWriter().ScretchLine(string.Format("[{0}] > {1}", Request.Id, Request), IO.WriteType.Incoming);
            }

            if (!Interactions.ContainsKey(Request.Id) && !Request.Type.Equals(RequestType.Policy))
            {
                return;
            }

            if (Request.Type == RequestType.Policy)
            {
                SendPolicy(Client);
            }
            else if (Request.Type == RequestType.Default)
            {
                if (!Client.Authenticated)
                {
                    if (!Request.Id.Equals(206) && !Request.Id.Equals(415))
                    {
                        return;
                    }
                }

                if (Interactions[Request.Id] != null)
                {
                    Interactions[Request.Id].Invoke(Client, Request);
                }
            }
        }
Пример #16
0
        public void GetBadges(Client Client, Request Request)
        {
            var Badges = BrickEngine.GetBadgeHandler().GetBadgesForUser(Client.GetUser().HabboId);
            var Equiped = BrickEngine.GetBadgeHandler().GetEquipedBadges(Client.GetUser().HabboId);

            Response Response = new Response(229);
            Response.AppendInt32(Badges.Count);

            foreach (Badge Badge in Badges)
            {
                Response.AppendInt32(BrickEngine.GetBadgeHandler().GetIdForBadge(Badge.BadgeCode));
                Response.AppendStringWithBreak(Badge.BadgeCode);
            }

            Response.AppendInt32(Equiped.Count);

            foreach (Badge Badge in Equiped)
            {
                Response.AppendInt32(Badge.SlotId);
                Response.AppendStringWithBreak(Badge.BadgeCode);
            }

            Client.SendResponse(Response);
        }
Пример #17
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);
 }
Пример #18
0
 private void GetMe(Client Client, Request Request)
 {
     Client.SendResponse(BrickEngine.GetNavigatorManager().GetResponseForUser(Client));
 }
Пример #19
0
 private void GetLastVisitedRooms(Client Client, Request Request)
 {
     Client.SendResponse(BrickEngine.GetNavigatorManager().GetLastVisited(Client));
 }
Пример #20
0
 private void GetFavoriteRooms(Client Client, Request Request)
 {
     Client.SendResponse(BrickEngine.GetNavigatorManager().GetFavoriteRooms(Client));
 }
Пример #21
0
        private void UpdateHomeRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int RoomId = Request.PopWiredInt32();

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                // You can't use anothers room.
                return;
            }

            if (Client.GetUser().HomeRoomId == RoomId)
            {
                return;
            }

            Client.GetUser().HomeRoomId = RoomId;

            Response Response = new Response(455);
            Response.AppendInt32(RoomId);
            Client.SendResponse(Response);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE users SET home_room_id = @roomid WHERE id = @habboid LIMIT 1");
                Reactor.AddParam("roomid", RoomId);
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.ExcuteQuery();
            }
        }
Пример #22
0
        private void SearchRooms(Client Client, Request Request)
        {
            string Query = string.Empty;

            if (Request.Length > 3)
            {
                Query = Request.PopFixedString();
            }

            Client.SendResponse(BrickEngine.GetNavigatorManager().GetSearchResponse(Query));
        }
Пример #23
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();
            }
        }
Пример #24
0
        private void GoHotelView(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            Client.GetUser().GetRoomUser().UnhandledGoalPoint = Client.GetUser().GetRoom().GetRoomModel().Door;
        }
Пример #25
0
 private void ActivateLoading(Client Client, Request Request)
 {
     Response Response = new Response(297);
     Response.AppendBoolean(false);
     Client.SendResponse(Response);
 }
Пример #26
0
        private void MovePetToRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                // Outside room placing FTW.
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                // Only Place in your own room.
                return;
            }

            int PetId = Request.PopWiredInt32();

            if (PetId <= 0)
            {
                return;
            }

            PetInfo Info = BrickEngine.GetPetReactor().GetPetInfo(PetId);

            if (Info == null)
            {
                return;
            }

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

            if (Client.GetUser().GetRoom().GetRoomEngine().GetPets().Count >= PetReactor.MAX_PETS_PER_ROOM)
            {
                Client.Notif(string.Format("A room can only contains {0} pets.",PetReactor.MAX_PETS_PER_ROOM), false);
                return;
            }

            int LimitX = Client.GetUser().GetRoom().GetRoomModel().XLength;
            int LimitY = Client.GetUser().GetRoom().GetRoomModel().YLength;

            int X = Request.PopWiredInt32();

            if (X < 0 || X >= LimitX)
            {
                return;
            }

            int Y = Request.PopWiredInt32();

            if (Y < 0 || Y >= LimitY)
            {
                return;
            }

            iPoint Place = new iPoint(X, Y);

            VirtualRoomEngine RoomEngine = BrickEngine.GetRoomReactor().GetVirtualRoom(Client.GetUser().RoomId, RoomRunningState.Alive).GetRoomEngine();

            if (RoomEngine == null)
            {
                return;
            }

            Info.RoomId = Client.GetUser().RoomId;

            int Rot = Rotation.Calculate(Place, Client.GetUser().GetRoomUser().Point);

            RoomEngine.GenerateRoomPet(PetId, Place, Rot);

            Response RemoveMessage = new Response(604);
            RemoveMessage.AppendInt32(PetId);
            Client.SendResponse(RemoveMessage);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE user_pets SET room_id = @roomid WHERE id = @petid LIMIT 1");
                Reactor.AddParam("roomid", Client.GetUser().RoomId);
                Reactor.AddParam("petid", PetId);
                Reactor.ExcuteQuery();
            }
        }
Пример #27
0
        private void MovePetToInventory(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                // Outside room placing FTW.
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                // Only Place in your own room.
                return;
            }

            int PetId = Request.PopWiredInt32();

            if (PetId <= 0)
            {
                return;
            }

            PetInfo Info = BrickEngine.GetPetReactor().GetPetInfo(PetId);

            if (Info == null)
            {
                return;
            }

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

            VirtualRoomEngine RoomEngine = BrickEngine.GetRoomReactor().GetVirtualRoom(Client.GetUser().RoomId, RoomRunningState.Alive).GetRoomEngine();

            if (RoomEngine == null)
            {
                return;
            }

            Info.RoomId = -1;

            RoomEngine.RemovePet(PetId);

            Response AddMessage = new Response(603);
            Info.GetInventoryResponse(AddMessage);
            Client.SendResponse(AddMessage);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE user_pets SET room_id = @roomid WHERE id = @petid LIMIT 1");
                Reactor.AddParam("roomid", -1);
                Reactor.AddParam("petid", PetId);
                Reactor.ExcuteQuery();
            }
        }
Пример #28
0
 private void GetPrivates(Client Client, Request Request)
 {
     Client.SendResponse(BrickEngine.GetNavigatorManager().GetPrivateResponse());
 }
Пример #29
0
        private void GetRooms(Client Client, Request Request)
        {
            int Category = int.Parse(Request.PopFixedString());

            Client.SendResponse(BrickEngine.GetNavigatorManager().GetRoomsResponse(Category));
        }
Пример #30
0
        public void OpenPrivateRoom(Client Client, Request Request)
        {
            int RoomId = Request.PopWiredInt32();
            string Password = Request.PopFixedString();

            BeginLoadRoom(Client, RoomId, Password);
        }