Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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();
                }
            }
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
0
        private void UnloadRoom(Client Client, List<string> Params)
        {
            int RoomId = Client.GetUser().RoomId;

            if (Params.Count == 1)
            {
                int.TryParse(Params[0], out RoomId);
            }

            BrickEngine.GetRoomReactor().DisposeRoom(RoomId);

            Client.Notif(string.Format("Disposed room {0} fawlessly.", RoomId), false);
        }
Exemplo n.º 9
0
        private void Teleport(Client Client, List<string> Params)
        {
            if (!Client.GetUser().GetRoomUser().TeleportingEnabled)
            {
                Client.GetUser().GetRoomUser().TeleportingEnabled = true;
            }
            else
            {
                Client.GetUser().GetRoomUser().TeleportingEnabled = false;
            }

            Client.Notif(string.Format("Teleporting is setted {0}", (Client.GetUser().GetRoomUser().TeleportingEnabled) ? "enabled" : "disabled"), false);
        }
Exemplo n.º 10
0
        private void Summon(Client Client, List<string> Params)
        {
            if (Params.Count != 1)
            {
                Client.Notif("Failed to summon user " + GetParams("summon"), false);
                return;
            }

            string Username = Params[0];

            if (Username.ToLower().Equals(Client.GetUser().Username))
            {
                Client.Notif("You cannot summon yourself.", false);
                return;
            }

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (HabboId <= 0)
            {
                Client.Notif(string.Format("User {0} not found in database/cache.", Username), false);
                return;
            }

            if (!BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client.Notif(string.Format("User {0} is offline.", Username), false);
                return;
            }

            int CurrentRoomId = Client.GetUser().RoomId;

            if (CurrentRoomId <= 0)
            {
                Client.Notif("You have to be in a room.", false);
                return;
            }

            Client Target = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

            if (Target.GetUser().Rank > Client.GetUser().Rank)
            {
                Client.Notif("You cannot summon someone with a higher rank.", false);
                return;
            }

            if (!Target.GetUser().IsInRoom)
            {
                return;
            }

            Target.Notif(string.Format("You have been summoned by {0}.", Client.GetUser().Username), true);

            if (!Target.GetUser().RoomId.Equals(CurrentRoomId))
            {
                BrickEngine.GetPacketHandler().BeginLoadRoom(Target, CurrentRoomId, string.Empty);
            }
            else
            {
                VirtualRoomUser TargetUser = Client.GetUser().GetRoom().GetRoomEngine().GetUserByHabboId(HabboId);
                VirtualRoomUser MyUser = Client.GetUser().GetRoomUser();

                if (TargetUser != null && MyUser != null)
                {
                    TargetUser.UnhandledGoalPoint = MyUser.FontPoint;
                }
            }
        }
Exemplo n.º 11
0
        private void DisconnectUser(Client Client, List<string> Params)
        {
            if (Params.Count != 1)
            {
                Client.Notif("Failed to disconnect user " + GetParams("disconnect"), false);
                return;
            }

            string Username = Params[0];

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (HabboId <= 0)
            {
                Client.Notif("Failed to disconnect user " + GetParams("disconnect"), false);
                return;
            }

            if (!BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client.Notif(string.Format("User {0} is offline.", Username), false);
                return;
            }

            Client Target = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

            Target.Dispose();

            Client.Notif(string.Format("Disconnected {0} fawlessly.", Username), true);
        }
Exemplo n.º 12
0
        private void Empty(Client Client, List<string> Params)
        {
            foreach (PetInfo Item in BrickEngine.GetPetReactor().GetPetsForInventory(Client.GetUser().HabboId))
            {
                BrickEngine.GetPetReactor().RemovePet(Item.Id);
            }

            foreach (Item Item in BrickEngine.GetItemReactor().GetItemsForUser(Client.GetUser().HabboId))
            {
                BrickEngine.GetItemReactor().RemoveItem(Item.Id);
            }

            Client.SendResponse(new Response(101));
            Client.Notif("Inventory Emptied.", true);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM items WHERE user_id = @habboid AND room_id <= 0");
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.ExcuteQuery();
            }

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM user_pets WHERE user_id = @habboid AND room_id <= 0");
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.ExcuteQuery();
            }
        }
Exemplo n.º 13
0
        private void MuteRoom(Client Client, List<string> Params)
        {
            if (Params.Count != 1)
            {
                Client.Notif("Failed to mute room " + GetParams("muteroom"), false);
                return;
            }

            int SecondsMuted = BrickEngine.GetConvertor().ObjectToInt32(Params[0]);

            if (SecondsMuted > 3600)
            {
                Client.Notif("Limit of 1 hour " + GetParams("muteroom"), false);
                return;
            }

            foreach (VirtualRoomUser User in Client.GetUser().GetRoom().GetRoomEngine().GetUsers())
            {
                if (BrickEngine.GetUserReactor().IsOnline(User.HabboId))
                {
                    if (User.GetClient().GetUser().Rank == 1 && !Client.GetUser().GetRoom().GetRoomEngine().HasRights(User.HabboId, RightsType.Rights))
                    {
                        Mute(Client, new string[] { User.GetClient().GetUser().Username, SecondsMuted.ToString() }.ToList());
                    }
                }
            }

            Client.Notif("Room muted fawlessly.", true);
        }
Exemplo n.º 14
0
        private void IPBan(Client Client, List<string> Params)
        {
            if (Params.Count != 2)
            {
                Client.Notif("Failed to ip-ban a user " + GetParams("ipban"), false);
                return;
            }

            int HabboId = BrickEngine.GetUserReactor().GetId(Params[0]);

            if (!BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client.Notif(string.Format("{0} is not in the hotel.", Params[0]), false);
                return;
            }

            Client Target = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

            string IP = Target.IPAddress;

            BrickEngine.GetToolReactor().BanUser(Client, HabboId, Params[1], 100000, true);
        }
Exemplo n.º 15
0
        private void Mute(Client Client, List<string> Params)
        {
            if (Params.Count != 2)
            {
                Client.Notif("Failed to mute a user " + GetParams("mute"), false);
                return;
            }

            string Username = Params[0];

            int SecondsMuted = BrickEngine.GetConvertor().ObjectToInt32(Params[1]);

            if (SecondsMuted > 3600)
            {
                Client.Notif("Limit of 1 hour " + GetParams("mute"), false);
                return;
            }

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client TargetClient = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

                TargetClient.GetUser().GetClient().GetUser().MutedStart = DateTime.Now;
                TargetClient.GetUser().GetClient().GetUser().SecondsMuted = SecondsMuted;

                Response Mute = new Response(27);
                Mute.AppendInt32(SecondsMuted);
                TargetClient.SendResponse(Mute);

                TargetClient.Notif(string.Format("You've been muted by: {0}", Client.GetUser().Username), true);
            }
        }
Exemplo n.º 16
0
        private void GivePixels(Client Client, List<string> Params)
        {
            if (Params.Count != 2)
            {
                Client.Notif("Failed to give pixels " + GetParams("givepixels"), false);
                return;
            }

            int FilteredPixels = -1;

            string RawPixels = Params[1];

            if (!int.TryParse(RawPixels.Trim(), out FilteredPixels))
            {
                Client.Notif("Failed to give pixels " + GetParams("givepixels"), false);
                return;
            }
            else if (FilteredPixels <= 0)
            {
                Client.Notif("Failed to give pixels " + GetParams("givepixels"), false);
                return;
            }

            string Username = Params[0];

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (HabboId <= 0)
            {
                Client.Notif("Failed to give pixels " + GetParams("givepixels"), false);
                return;
            }

            if (!BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client.Notif(string.Format("User {0} is offline.", Username), false);
                return;
            }

            Client Target = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

            Target.GetUser().Pixels += FilteredPixels;
            Target.GetUser().UpdatePixels(true);

            Target.Notif(string.Format("{0} gave you {1} pixels.", Client.GetUser().Username, FilteredPixels), true);
        }
Exemplo n.º 17
0
        private void DropEvents(Client Client, List<string> Params)
        {
            int i = 0;

            foreach (VirtualRoom Room in BrickEngine.GetRoomReactor().GetEventRooms(-1))
            {
                Room.Event.Drop();
                i++;
            }

            Client.Notif(string.Format("Dropped {0} event(s).", i), true);
        }
Exemplo n.º 18
0
        private void GiveBadge(Client Client, List<string> Params)
        {
            if (Params.Count != 2)
            {
                Client.Notif("Failed to give badge " + GetParams("givebadge"), false);
                return;
            }

            string Username = Params[0];

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (HabboId <= 0)
            {
                Client.Notif("Failed to give badge " + GetParams("givebadge"), false);
                return;
            }

            if (!BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client.Notif(string.Format("User {0} is offline.", Username), false);
                return;
            }

            Client Target = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

            string BadgeCode = Params[1];

            BrickEngine.GetBadgeHandler().GiveBadge(Target, BadgeCode);
            BrickEngine.GetPacketHandler().GetBadges(Target, null);

            Target.Notif(string.Format("{0} gave you a badge: {1}", Client.GetUser().Username, BadgeCode), true);
        }
Exemplo n.º 19
0
        private void UnMute(Client Client, List<string> Params)
        {
            if (Params.Count != 1)
            {
                Client.Notif("Failed to mute a user " + GetParams("unmute"), false);
                return;
            }

            string Username = Params[0];

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client TargetClient = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

                if (TargetClient.GetUser().Muted)
                {
                    TargetClient.Notif("You've been unmuted, reload the room.", false);

                    TargetClient.GetUser().GetClient().GetUser().MutedStart = new DateTime(1, 1, 1);
                    TargetClient.GetUser().GetClient().GetUser().SecondsMuted = 0;

                    Response Mute = new Response(27);
                    Mute.AppendInt32(0);
                    TargetClient.SendResponse(Mute);
                }
            }
        }
Exemplo n.º 20
0
        private void DestroyRoom(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))
            {
                Client.Notif("You has not the rights to do this.", false);
                return;
            }

            BrickEngine.GetRoomReactor().DisposeRoom(Room.Id);

            // Cleanup Data
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM private_rooms WHERE id = @roomid LIMIT 1");
                Reactor.AddParam("roomid", RoomId);
                Reactor.ExcuteQuery();
            }

            // Cleanup HomeRooms
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE users SET home_room_id = '0' WHERE home_room_id = @roomid LIMIT 1");
                Reactor.AddParam("roomid", RoomId);
                Reactor.ExcuteQuery();
            }

            // Cleanup Rights
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM private_rooms_rights WHERE room_id = @roomid LIMIT 1");
                Reactor.AddParam("roomid", RoomId);
                Reactor.ExcuteQuery();
            }

            // Cleanup Rights
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("DELETE FROM user_favorite_rooms WHERE room_id = @roomid LIMIT 1");
                Reactor.AddParam("roomid", RoomId);
                Reactor.ExcuteQuery();
            }

            // Cleanup Items
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE items SET room_id = '0' WHERE room_id = @roomid LIMIT 1");
                Reactor.AddParam("roomid", RoomId);
                Reactor.ExcuteQuery();
            }
        }
Exemplo n.º 21
0
        private void UnMuteRoom(Client Client, List<string> Params)
        {
            foreach (VirtualRoomUser User in Client.GetUser().GetRoom().GetRoomEngine().GetUsers())
            {
                if (BrickEngine.GetUserReactor().IsOnline(User.HabboId))
                {
                    if (User.GetClient().GetUser().Rank == 1 && !Client.GetUser().GetRoom().GetRoomEngine().HasRights(User.HabboId, RightsType.Rights))
                    {
                        UnMute(Client, new string[] { User.GetClient().GetUser().Username }.ToList());
                    }
                }
            }

            Client.Notif("Room un-muted fawlessly.", true);
        }
Exemplo n.º 22
0
        private void KickUser(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

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

            int HabboId = Request.PopWiredInt32();

            VirtualRoomUser TriggeredUser = Client.GetUser().GetRoom().GetRoomEngine().GetUserByHabboId(HabboId);

            if (TriggeredUser == null)
            {
                return;
            }

            if (Client.GetUser().GetRoom().GetRoomEngine().HasRights(HabboId, Rooms.RightsType.Founder))
            {
                Client.Notif("You can't kick the room owner.", false);
                return;
            }

            if (TriggeredUser.GetClient().GetUser().Rank > 1)
            {
                Client.Notif("You can't kick staff.", false);
                return;
            }

            Response Kick = new Response(33);
            Kick.AppendInt32(4008);
            TriggeredUser.GetClient().SendResponse(Kick);

            TriggeredUser.WalkFreezed = true;
            TriggeredUser.UnhandledGoalPoint = Client.GetUser().GetRoom().GetRoomModel().Door;
        }
Exemplo n.º 23
0
        private void RefreshCatalogue(Client Client, List<string> Params)
        {
            BrickEngine.GetSocketShield().BroadcastResponse(new Response(441));

            BrickEngine.GetShopReactor().LoadPages();
            BrickEngine.GetShopReactor().LoadItems();

            BrickEngine.GetShopReactor().LoadShopClubItems();
            BrickEngine.GetShopReactor().LoadShopGiftItems();

            BrickEngine.GetShopReactor().LoadPetRaces();

            Client.Notif("Catalogue refreshed sucessfully.", false);
        }
Exemplo n.º 24
0
        private void Effect(Client Client, List<string> Params)
        {
            if (Params.Count != 1)
            {
                Client.Notif("Failed to run effect " + GetParams("effect"), false);
                return;
            }

            int FilteredEffect = -1;

            string RawEffect = Params[0];

            if (!int.TryParse(RawEffect.Trim(), out FilteredEffect))
            {
                Client.Notif("Failed to run effect " + GetParams("effect"), false);
                return;
            }
            else if (FilteredEffect < 0)
            {
                Client.Notif("Failed to run effect " + GetParams("effect"), false);
                return;
            }

            BrickEngine.GetEffectsHandler().RunFreeEffect(Client, FilteredEffect);
        }
Exemplo n.º 25
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.º 26
0
        private void RefreshItems(Client Client, List<string> Params)
        {
            BrickEngine.GetFurniReactor().Prepare();

            Client.Notif("Items refreshed sucessfully.", false);
        }
Exemplo n.º 27
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();
            }
        }
Exemplo n.º 28
0
        private void SingPets(Client Client, List<string> Params)
        {
            if (Params.Count == 0)
            {
                Client.Notif("Failed to sing pets " + GetParams("singpets"), false);
                return;
            }

            StringBuilder Message = new StringBuilder();

            int i = 0;

            foreach (string Param in Params)
            {
                if (i > 0 && i < Params.Count)
                {
                    Message.Append(' ');
                }

                Message.Append(Param);

                i++;
            }

            foreach (VirtualRoomUser Pet in Client.GetUser().GetRoom().GetRoomEngine().GetPets())
            {
                Pet.Talk(Message.ToString(), SpeechType.Shout, 0, string.Empty);

                Pet.AddStatus("dan", string.Empty);
                Pet.UpdateStatus(true);
            }
        }
Exemplo n.º 29
0
        private void RefreshNavigator(Client Client, List<string> Params)
        {
            BrickEngine.GetNavigatorManager().LoadFeacturedRooms();
            BrickEngine.GetNavigatorManager().LoadPrivateCategorys();

            Client.Notif("Navigator refreshed sucessfully.", false);
        }
Exemplo n.º 30
0
        private void ClearMotto(Client Client, List<string> Params)
        {
            if (Params.Count != 1)
            {
                Client.Notif("Failed to clear motto " + GetParams("clearmotto"), false);
                return;
            }

            string Username = Params[0];

            int HabboId = BrickEngine.GetUserReactor().GetId(Username);

            if (HabboId <= 0)
            {
                Client.Notif("Failed to clear motto " + GetParams("clearmotto"), false);
                return;
            }

            if (!BrickEngine.GetUserReactor().IsOnline(HabboId))
            {
                Client.Notif(string.Format("User {0} is offline.", Username), false);
                return;
            }

            Client Target = BrickEngine.GetSocketShield().GetSocketClientByHabboId(HabboId).GetClient();

            Target.GetUser().Motto = string.Empty;

            Target.GetUser().RefreshUser();

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE users SET motto = @motto WHERE id = @habboid LIMIT 1");
                Reactor.AddParam("motto", string.Empty);
                Reactor.AddParam("habboid", HabboId);
                Reactor.ExcuteQuery();
            }

            BrickEngine.GetStreamHandler().AddStream(Target.GetUser().HabboId, Users.Handlers.Messenger.Streaming.StreamType.EditedMotto, string.Empty);

            Client.Notif(string.Format("Cleared motto of {0}", Username), true);
        }