Exemple #1
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            Session.GetHabbo().AllowMimic = !Session.GetHabbo().AllowMimic;
            Session.SendWhisper("Tu " + (Session.GetHabbo().AllowMimic == true ? "agora" : "agora nao") + " pode ser imitado.");

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `allow_mimic` = @AllowMimic WHERE `id` = '" + Session.GetHabbo().Id + "'");
                dbClient.AddParameter("AllowMimic", CloudServer.BoolToEnum(Session.GetHabbo().AllowMimic));
                dbClient.RunQuery();
            }
        }
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            Boolean ChatPreference = Packet.PopBoolean();

            Session.GetHabbo().ChatPreference = ChatPreference;
            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `chat_preference` = @chatPreference WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1");
                dbClient.AddParameter("chatPreference", CloudServer.BoolToEnum(ChatPreference));
                dbClient.RunQuery();
            }
        }
Exemple #3
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            Boolean Status = Packet.PopBoolean();

            Session.GetHabbo().AllowMessengerInvites = Status;
            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `ignore_invites` = @MessengerInvites WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1");
                dbClient.AddParameter("MessengerInvites", CloudServer.BoolToEnum(Status));
                dbClient.RunQuery();
            }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            Session.GetHabbo().AllowGifts = !Session.GetHabbo().AllowGifts;
            Session.SendWhisper("You're " + (Session.GetHabbo().AllowGifts == true ? "nao" : "nao") + " aceitar de presentes.");

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `allow_gifts` = @AllowGifts WHERE `id` = '" + Session.GetHabbo().Id + "'");
                dbClient.AddParameter("AllowGifts", CloudServer.BoolToEnum(Session.GetHabbo().AllowGifts));
                dbClient.RunQuery();
            }
        }
Exemple #5
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = CloudServer.GetGame().GetRoomManager().LoadRoom(Packet.PopInt());

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

            string word;
            string Name = Packet.PopString();

            Name = CloudServer.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(Name, out word) ? "Spam" : Name;
            string Description = Packet.PopString();

            Description = CloudServer.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(Description, out word) ? "Spam" : Description;
            RoomAccess Access     = RoomAccessUtility.ToRoomAccess(Packet.PopInt());
            string     Password   = Packet.PopString();
            int        MaxUsers   = Packet.PopInt();
            int        CategoryId = Packet.PopInt();
            int        TagCount   = Packet.PopInt();

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

            for (int i = 0; i < TagCount; i++)
            {
                if (i > 0)
                {
                    formattedTags.Append(",");
                }

                string tag = Packet.PopString().ToLower();

                Tags.Add(tag);
                formattedTags.Append(tag);
            }

            int TradeSettings       = Packet.PopInt();//2 = All can trade, 1 = owner only, 0 = no trading.
            int AllowPets           = Convert.ToInt32(CloudServer.BoolToEnum(Packet.PopBoolean()));
            int AllowPetsEat        = Convert.ToInt32(CloudServer.BoolToEnum(Packet.PopBoolean()));
            int RoomBlockingEnabled = Convert.ToInt32(CloudServer.BoolToEnum(Packet.PopBoolean()));
            int Hidewall            = Convert.ToInt32(CloudServer.BoolToEnum(Packet.PopBoolean()));
            int WallThickness       = Packet.PopInt();
            int FloorThickness      = Packet.PopInt();
            int WhoMute             = Packet.PopInt(); // mute
            int WhoKick             = Packet.PopInt(); // kick
            int WhoBan = Packet.PopInt();              // ban

            int chatMode     = Packet.PopInt();
            int chatSize     = Packet.PopInt();
            int chatSpeed    = Packet.PopInt();
            int chatDistance = Packet.PopInt();
            int extraFlood   = Packet.PopInt();

            if (chatMode < 0 || chatMode > 1)
            {
                chatMode = 0;
            }

            if (chatSize < 0 || chatSize > 2)
            {
                chatSize = 0;
            }

            if (chatSpeed < 0 || chatSpeed > 2)
            {
                chatSpeed = 0;
            }

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

            if (chatDistance > 99)
            {
                chatDistance = 100;
            }

            if (extraFlood < 0 || extraFlood > 2)
            {
                extraFlood = 0;
            }

            if (TradeSettings < 0 || TradeSettings > 2)
            {
                TradeSettings = 0;
            }

            if (WhoMute < 0 || WhoMute > 1)
            {
                WhoMute = 0;
            }

            if (WhoKick < 0 || WhoKick > 1)
            {
                WhoKick = 0;
            }

            if (WhoBan < 0 || WhoBan > 1)
            {
                WhoBan = 0;
            }

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

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

            if (Name.Length < 1)
            {
                return;
            }

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

            if (Access == RoomAccess.PASSWORD && Password.Length == 0)
            {
                Access = RoomAccess.OPEN;
            }

            if (MaxUsers < 0)
            {
                MaxUsers = 10;
            }

            if (MaxUsers > 50)
            {
                MaxUsers = 50;
            }

            SearchResultList SearchResultList = null;

            if (!CloudServer.GetGame().GetNavigator().TryGetSearchResultList(CategoryId, out SearchResultList))
            {
                CategoryId = 36;
            }

            if (SearchResultList.CategoryType != NavigatorCategoryType.CATEGORY || SearchResultList.RequiredRank > Session.GetHabbo().Rank || (Session.GetHabbo().Id != Room.OwnerId && Session.GetHabbo().Rank >= SearchResultList.RequiredRank))
            {
                CategoryId = 36;
            }

            if (TagCount > 2)
            {
                return;
            }

            Room.AllowPets           = AllowPets;
            Room.AllowPetsEating     = AllowPetsEat;
            Room.RoomBlockingEnabled = RoomBlockingEnabled;
            Room.Hidewall            = Hidewall;

            Room.RoomData.AllowPets           = AllowPets;
            Room.RoomData.AllowPetsEating     = AllowPetsEat;
            Room.RoomData.RoomBlockingEnabled = RoomBlockingEnabled;
            Room.RoomData.Hidewall            = Hidewall;

            Room.Name        = Name;
            Room.Access      = Access;
            Room.Description = Description;
            Room.Category    = CategoryId;
            Room.Password    = Password;

            Room.RoomData.Name        = Name;
            Room.RoomData.Access      = Access;
            Room.RoomData.Description = Description;
            Room.RoomData.Category    = CategoryId;
            Room.RoomData.Password    = Password;

            Room.WhoCanBan           = WhoBan;
            Room.WhoCanKick          = WhoKick;
            Room.WhoCanMute          = WhoMute;
            Room.RoomData.WhoCanBan  = WhoBan;
            Room.RoomData.WhoCanKick = WhoKick;
            Room.RoomData.WhoCanMute = WhoMute;

            Room.ClearTags();
            Room.AddTagRange(Tags);
            Room.UsersMax = MaxUsers;

            Room.RoomData.Tags.Clear();
            Room.RoomData.Tags.AddRange(Tags);
            Room.RoomData.UsersMax = MaxUsers;

            Room.WallThickness           = WallThickness;
            Room.FloorThickness          = FloorThickness;
            Room.RoomData.WallThickness  = WallThickness;
            Room.RoomData.FloorThickness = FloorThickness;

            Room.chatMode     = chatMode;
            Room.chatSize     = chatSize;
            Room.chatSpeed    = chatSpeed;
            Room.chatDistance = chatDistance;
            Room.extraFlood   = extraFlood;

            Room.TradeSettings = TradeSettings;

            Room.RoomData.chatMode     = chatMode;
            Room.RoomData.chatSize     = chatSize;
            Room.RoomData.chatSpeed    = chatSpeed;
            Room.RoomData.chatDistance = chatDistance;
            Room.RoomData.extraFlood   = extraFlood;

            Room.RoomData.TradeSettings = TradeSettings;

            string AccessStr = Password.Length > 0 ? "password" : "open";

            switch (Access)
            {
            default:
            case RoomAccess.OPEN:
                AccessStr = "open";
                break;

            case RoomAccess.PASSWORD:
                AccessStr = "password";
                break;

            case RoomAccess.DOORBELL:
                AccessStr = "locked";
                break;

            case RoomAccess.INVISIBLE:
                AccessStr = "invisible";
                break;
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE rooms SET caption = @caption, description = @description, password = @password, category = " +
                                  CategoryId + ", state = '" + AccessStr + "', tags = @tags, users_max = " + MaxUsers +
                                  ", allow_pets = '" + AllowPets + "', allow_pets_eat = '" + AllowPetsEat + "', room_blocking_disabled = '" +
                                  RoomBlockingEnabled + "', allow_hidewall = '" + Room.Hidewall + "', floorthick = " +
                                  Room.FloorThickness + ", wallthick = " + Room.WallThickness + ", mute_settings='" + Room.WhoCanMute +
                                  "', kick_settings='" + Room.WhoCanKick + "',ban_settings='" + Room.WhoCanBan + "', `chat_mode` = '" + Room.chatMode + "', `chat_size` = '" + Room.chatSize + "', `chat_speed` = '" + Room.chatSpeed + "', `chat_extra_flood` = '" + Room.extraFlood + "', `chat_hearing_distance` = '" + Room.chatDistance + "', `trade_settings` = '" + Room.TradeSettings + "' WHERE `id` = '" + Room.RoomId + "' LIMIT 1");
                dbClient.AddParameter("caption", Room.Name);
                dbClient.AddParameter("description", Room.Description);
                dbClient.AddParameter("password", Room.Password);
                dbClient.AddParameter("tags", formattedTags.ToString());
                dbClient.RunQuery();
            }

            Room.GetGameMap().GenerateMaps();

            if (Session.GetHabbo().CurrentRoom == null)
            {
                Session.SendMessage(new RoomSettingsSavedComposer(Room.RoomId));
                Session.SendMessage(new RoomInfoUpdatedComposer(Room.RoomId));
                Session.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, CloudServer.EnumToBool(Room.Hidewall.ToString())));
            }
            else
            {
                Room.SendMessage(new RoomSettingsSavedComposer(Room.RoomId));
                Room.SendMessage(new RoomInfoUpdatedComposer(Room.RoomId));
                Room.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, CloudServer.EnumToBool(Room.Hidewall.ToString())));
            }

            CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModDoorModeSeen", 1);
            CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModWalkthroughSeen", 1);
            CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatScrollSpeedSeen", 1);
            CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatFloodFilterSeen", 1);
            CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatHearRangeSeen", 1);
        }
Exemple #6
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            int    BotId      = Packet.PopInt();
            int    ActionId   = Packet.PopInt();
            string DataString = Packet.PopString();

            if (ActionId < 1 || ActionId > 5)
            {
                return;
            }

            RoomUser Bot = null;

            if (!Room.GetRoomUserManager().TryGetBot(BotId, out Bot))
            {
                return;
            }

            if ((Bot.BotData.ownerID != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("bot_edit_any_override")))
            {
                return;
            }

            RoomBot RoomBot = Bot.BotData;

            if (RoomBot == null)
            {
                return;
            }

            /* 1 = Copy looks
             * 2 = Setup Speech
             * 3 = Relax
             * 4 = Dance
             * 5 = Change Name
             */

            switch (ActionId)
            {
                #region Copy Looks (1)
            case 1:
            {
                ServerPacket UserChangeComposer = new ServerPacket(ServerPacketHeader.UserChangeMessageComposer);
                UserChangeComposer.WriteInteger(Bot.VirtualId);
                UserChangeComposer.WriteString(Session.GetHabbo().Look);
                UserChangeComposer.WriteString(Session.GetHabbo().Gender);
                UserChangeComposer.WriteString(Bot.BotData.Motto);
                UserChangeComposer.WriteInteger(0);
                Room.SendMessage(UserChangeComposer);

                //Change the defaults
                Bot.BotData.Look   = Session.GetHabbo().Look;
                Bot.BotData.Gender = Session.GetHabbo().Gender;

                using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `bots` SET `look` = @look, `gender` = '" + Session.GetHabbo().Gender + "' WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1");
                    dbClient.AddParameter("look", Session.GetHabbo().Look);
                    dbClient.RunQuery();
                }

                //Room.SendMessage(new UserChangeComposer(BotUser.GetClient(), true));
                break;
            }
                #endregion

                #region Setup Speech (2)
            case 2:
            {
                string[] ConfigData = DataString.Split(new string[]
                    {
                        ";#;"
                    }, StringSplitOptions.None);

                string[] SpeechData = ConfigData[0].Split(new char[]
                    {
                        '\r',
                        '\n'
                    }, StringSplitOptions.RemoveEmptyEntries);

                string AutomaticChat    = Convert.ToString(ConfigData[1]);
                string SpeakingInterval = Convert.ToString(ConfigData[2]);
                string MixChat          = Convert.ToString(ConfigData[3]);

                if (String.IsNullOrEmpty(SpeakingInterval) || Convert.ToInt32(SpeakingInterval) <= 0 || Convert.ToInt32(SpeakingInterval) < 7)
                {
                    SpeakingInterval = "7";
                }

                RoomBot.AutomaticChat    = Convert.ToBoolean(AutomaticChat);
                RoomBot.SpeakingInterval = Convert.ToInt32(SpeakingInterval);
                RoomBot.MixSentences     = Convert.ToBoolean(MixChat);

                using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                { dbClient.runFastQuery("DELETE FROM `bots_speech` WHERE `bot_id` = '" + Bot.BotData.Id + "'"); }

                #region Save Data - TODO: MAKE METHODS FOR THIS.
                for (int i = 0; i <= SpeechData.Length - 1; i++)
                {
                    using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("INSERT INTO `bots_speech` (`bot_id`, `text`) VALUES (@id, @data)");
                        dbClient.AddParameter("id", BotId);
                        dbClient.AddParameter("data", SpeechData[i]);
                        dbClient.RunQuery();

                        dbClient.SetQuery("UPDATE `bots` SET `automatic_chat` = @AutomaticChat, `speaking_interval` = @SpeakingInterval, `mix_sentences` = @MixChat WHERE `id` = @id LIMIT 1");
                        dbClient.AddParameter("id", BotId);
                        dbClient.AddParameter("AutomaticChat", AutomaticChat.ToLower());
                        dbClient.AddParameter("SpeakingInterval", Convert.ToInt32(SpeakingInterval));
                        dbClient.AddParameter("MixChat", CloudServer.BoolToEnum(Convert.ToBoolean(MixChat)));
                        dbClient.RunQuery();
                    }
                }
                #endregion

                #region Handle Speech
                RoomBot.RandomSpeech.Clear();
                using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT * FROM `bots_speech` WHERE `bot_id` = @id ORDER BY id ASC");
                    dbClient.AddParameter("id", BotId);

                    DataTable BotSpeech = dbClient.getTable();

                    List <RandomSpeech> Speeches = new List <RandomSpeech>();
                    foreach (DataRow Speech in BotSpeech.Rows)
                    {
                        RoomBot.RandomSpeech.Add(new RandomSpeech(Convert.ToString(Speech["text"]), BotId));
                    }
                }
                #endregion

                break;
            }
                #endregion

                #region Relax (3)
            case 3:
            {
                if (Bot.BotData.WalkingMode == "stand")
                {
                    Bot.BotData.WalkingMode = "freeroam";
                }
                else
                {
                    Bot.BotData.WalkingMode = "stand";
                }

                using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.runFastQuery("UPDATE `bots` SET `walk_mode` = '" + Bot.BotData.WalkingMode + "' WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1");
                }
                break;
            }
                #endregion

                #region Dance (4)
            case 4:
            {
                if (Bot.BotData.DanceId > 0)
                {
                    Bot.BotData.DanceId = 0;
                }
                else
                {
                    Random RandomDance = new Random();
                    Bot.BotData.DanceId = RandomDance.Next(1, 4);
                }

                Room.SendMessage(new DanceComposer(Bot, Bot.BotData.DanceId));
                break;
            }
                #endregion

                #region Change Name (5)
            case 5:
            {
                if (DataString.Length == 0)
                {
                    Session.SendWhisper("Vamos, al menos dale un nombre al bot!");
                    return;
                }
                else if (DataString.Length >= 16)
                {
                    Session.SendWhisper("Vamos, el bot no necesita un nombre tan largo!");
                    return;
                }

                if (DataString.Contains("<img src") || DataString.Contains("<font ") || DataString.Contains("</font>") || DataString.Contains("</a>") || DataString.Contains("<i>"))
                {
                    Session.SendWhisper("No HTML, Porfavor :<");
                    return;
                }

                Bot.BotData.Name = DataString;
                using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `bots` SET `name` = @name WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1");
                    dbClient.AddParameter("name", DataString);
                    dbClient.RunQuery();
                }
                Room.SendMessage(new UsersComposer(Bot));
                break;
            }
                #endregion
            }
        }
Exemple #7
0
        public void UpdatePreset(int Preset, string Color, int Intensity, bool BgOnly, bool Hax = false)
        {
            if (!IsValidColor(Color) || !IsValidIntensity(Intensity) && !Hax)
            {
                return;
            }

            string Pr;

            switch (Preset)
            {
            case 3:

                Pr = "three";
                break;

            case 2:

                Pr = "two";
                break;

            case 1:
            default:

                Pr = "one";
                break;
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE room_items_moodlight SET preset_" + Pr + " = '@color," + Intensity + "," + CloudServer.BoolToEnum(BgOnly) + "' WHERE item_id = '" + ItemId + "' LIMIT 1");
                dbClient.AddParameter("color", Color);
                dbClient.RunQuery();
            }

            GetPreset(Preset).ColorCode      = Color;
            GetPreset(Preset).ColorIntensity = Intensity;
            GetPreset(Preset).BackgroundOnly = BgOnly;
        }