public Boolean HandleCommand(string Command, Client Client, List<string> Params)
        {
            string Lowered = Command.ToLower();

            foreach (KeyValuePair<KeyValuePair<string, string>, KeyValuePair<Handler, int>> kvp in Handlers)
            {
                if (kvp.Key.Key.ToLower().Equals(Command))
                {
                    if (kvp.Value.Key != null && Client.GetUser().Rank >= kvp.Value.Value)
                    {
                        if (Client.GetUser().Rank >= kvp.Value.Value)
                        {
                            kvp.Value.Key.Invoke(Client, Params);
                            return true;
                        }
                        else
                        {
                            Client.Notif("You have no rights to do that command.", true);
                            return false;
                        }
                    }
                }
            }

            return false;
        }
Example #2
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);
 }
Example #3
0
        public void BeginLoadRoom(Client Client, int RoomId, string Password)
        {
            if (Client.GetUser().PreparingRoomId == RoomId)
            {
                return;
            }

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

            if (Room == null)
            {
                ClearLoading(Client, true);
                return;
            }

            if (BrickEngine.GetRoomReactor().GetRoomModel(Room.ModelParam) == null)
            {
                Client.Notif("The RoomModel of this room is missing.", false);
                ClearLoading(Client, true);
                return;
            }

            if (!Room.BeginEnterRoom(Client, Password))
            {
                Client.GetUser().LeaveCurrentRoom();
                ClearLoading(Client, false);
            }
            else
            {
                Client.GetUser().LeaveCurrentRoom();
                Client.GetUser().PreparingRoomId = RoomId;
                ContinueLoading(Client, null);
            }
        }
        private void AddUserTag(Client Client, SiteRequest Request)
        {
            string Tag = Request.PopString();

            if (!Client.GetUser().Tags.Contains(Tag))
            {
                Client.GetUser().Tags.Add(Tag);
            }
        }
Example #5
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);
 }
Example #6
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);
            }
        }
Example #7
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);
        }
Example #8
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);
            }
        }
        public Boolean GainReward(Client Client)
        {
            EcotronReward Reward = DeliverReward();

            if (Reward == null)
            {
                return false;
            }

            BaseItem EcotronBox = BrickEngine.GetFurniReactor().GetSpecifiqueItem("ecotron_box");

            if (EcotronBox == null)
            {
                return false;
            }

            int BoxId = BrickEngine.GetItemReactor().InsertItem(Client.GetUser().HabboId, EcotronBox.Id, DateTime.Now.ToShortDateString(), Reward.BaseId);

            Response Response = new Response(832);
            Response.AppendInt32(1);
            Response.AppendInt32(EcotronBox.InternalType.ToLower().Equals("s") ? 1 : 2);
            Response.AppendInt32(1);
            Response.AppendInt32(BoxId);
            Client.SendResponse(Response);

            Response Box = new Response(508);
            Box.AppendBoolean(true);
            Box.AppendInt32(BoxId);
            Client.SendResponse(Box);

            TimeToWait.Add(Client.GetUser().HabboId, DateTime.Now.AddMinutes(3));

            return true;
        }
Example #10
0
        public void AlertRoom(Client Client, int RoomId, string Message, Boolean Warning)
        {
            if (Client.GetUser().Rank < 7)
            {
                Client.Notif("You need rank '7' to do this action.", false);
                return;
            }

            if (BrickEngine.GetRoomReactor().RoomIsAlive(RoomId))
            {
                if (BrickEngine.GetRoomReactor().GetVirtualRoom(RoomId, Rooms.RoomRunningState.Alive).RoomUserAmount > 0)
                {
                    foreach (VirtualRoomUser User in BrickEngine.GetRoomReactor().GetVirtualRoom(RoomId, Rooms.RoomRunningState.Alive).GetRoomEngine().GetUsers())
                    {
                        if (User.GetClient().GetUser().Rank > 1)
                        {
                            AlertUser(Client, User.HabboId, Message, false, false, true);
                        }
                        else
                        {
                            AlertUser(Client, User.HabboId, Message, Warning, false, true);
                        }
                    }
                }
            }
        }
Example #11
0
        public void ClearLoading(Client Client, Boolean Reset)
        {
            if (Client.GetUser().IsInRoom)
            {
                Client.GetUser().RoomId = -1;
            }

            if (Client.GetUser().IsLoadingRoom)
            {
                Client.GetUser().PreparingRoomId = -1;
            }

            if (Reset)
            {
                Client.SendResponse(new Response(18));
            }
        }
Example #12
0
        public void AlertUser(Client Client, int UserId, string Message, Boolean Warning, Boolean Kick, Boolean RoomAlert)
        {
            if (Client.GetUser().Rank < 6)
            {
                Client.Notif("You need rank '6' to do this action.", false);
                return;
            }

            if (Client.GetUser().HabboId.Equals(UserId) && !RoomAlert)
            {
                Client.Notif("You can't message yourself.", false);
                return;
            }

            if (BrickEngine.GetUserReactor().IsOnline(UserId))
            {
                if (Kick)
                {
                    if (BrickEngine.GetSocketShield().GetSocketClientByHabboId(UserId).GetClient().GetUser().IsInRoom)
                    {
                        BrickEngine.GetSocketShield().GetSocketClientByHabboId(UserId).GetClient().GetUser().GetRoom().GetRoomEngine().HandleLeaveUser(UserId, true);
                    }
                }

                if (Message.Length > 0)
                {
                    BrickEngine.GetSocketShield().GetSocketClientByHabboId(UserId).GetClient().Notif(Message, true);
                }
            }

            if (Warning)
            {
                if (BrickEngine.GetUserReactor().IsOnline(UserId))
                {
                    BrickEngine.GetSocketShield().GetSocketClientByHabboId(UserId).GetClient().GetUser().Warnings++;
                }

                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE users SET warnings = warnings + 1 WHERE id = @habboid LIMIT 1");
                    Reactor.AddParam("habboid", UserId);
                    Reactor.ExcuteQuery();
                }
            }
        }
Example #13
0
        public Boolean CompletedAchievement(Client Client)
        {
            if (Client.GetUser().Achievements.ContainsKey(Id))
            {
                return (Client.GetUser().Achievements[Id] >= MaxLevel);
            }

            return false;
        }
Example #14
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);
        }
Example #15
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);
        }
Example #16
0
        public Boolean AchievedCategory(Client Client)
        {
            var AchievedQuests = Client.GetUser().Quests;
            var CategoryQuests = BrickEngine.GetQuestReactor().OrderQuestsForCategory(Id);

            if (AchievedQuests.ContainsKey(Id))
            {
                return AchievedQuests[Id] >= CategoryQuests.Count;
            }

            return false;
        }
Example #17
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);
            }
        }
Example #18
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);
        }
Example #19
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();
            }
        }
Example #20
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);
        }
        public string FilterMessage(Client Receiver, string RawMessage)
        {
            string Result = RawMessage;

            if (Receiver.GetUser().EnableWordfilter)
            {
                foreach (string ForcedParam in ForcedParams)
                {
                    if (Result.ToLower().Contains(ForcedParam.ToLower()))
                    {
                        Result = Result.Replace(ForcedParam, GenerateStars(ForcedParam));
                    }
                }
            }

            return Result;
        }
Example #22
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);
        }
Example #23
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();
                    }
                }
            }
        }
Example #24
0
        public Quest GetQuestForCategory(Client Client, int CategoryId)
        {
            var AchievedQuests = Client.GetUser().Quests;

            if (!AchievedQuests.ContainsKey(CategoryId))
            {
                return OrderQuestsForCategory(CategoryId)[0];
            }
            else
            {
                int LastAchievedLevel = AchievedQuests[CategoryId];

                if (LastAchievedLevel + 1 >= OrderQuestsForCategory(CategoryId).Count)
                {
                    return null;
                }

                return OrderQuestsForCategory(CategoryId)[LastAchievedLevel];
            }
        }
Example #25
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);
        }
Example #26
0
        public int CreateRoom(Client Client, string RawName, string RawModel)
        {
            string FixedName = BrickEngine.CleanString(RawName);
            string FixedModel = BrickEngine.CleanString(RawModel);

            if (GetRoomModel(FixedModel) == null)
            {
                Client.Notif("RoomModel: " + FixedModel + " could not found in cache, try another.", false);
                return -1;
            }

            if (FixedName.Length < 3)
            {
                Client.Notif("The name you typed in was to short, try again.",false);
                return -1;
            }

            if (FixedName.Length > 25)
            {
                Client.Notif("The name you typed in was to long, try again.", false);
                return -1;
            }

            int GeneratedId = RoomIdCounter.Next;

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("INSERT INTO private_rooms (id, name, owner_id, model_param) VALUES (@roomid, @name, @ownerid, @model)");
                Reactor.AddParam("roomid", GeneratedId);
                Reactor.AddParam("name", FixedName);
                Reactor.AddParam("ownerid", Client.GetUser().HabboId);
                Reactor.AddParam("model", FixedModel);
                Reactor.ExcuteQuery();
            }

            return GeneratedId;
        }
Example #27
0
        public int GetNextLevel(Client Client)
        {
            if (CompletedAchievement(Client))
            {
                return Client.GetUser().Achievements[Id];
            }

            if (Client.GetUser().Achievements.ContainsKey(Id))
            {
                return Client.GetUser().Achievements[Id] + 1;
            }

            return 1;
        }
Example #28
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();
            }
        }
Example #29
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();
            }
        }
Example #30
0
        private void GoHotelView(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            Client.GetUser().GetRoomUser().UnhandledGoalPoint = Client.GetUser().GetRoom().GetRoomModel().Door;
        }