コード例 #1
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (room == null || !room.CheckRights(Session, true))
            {
                return;
            }
            if (room.MoodlightData == null || room.MoodlightData.Presets == null)
            {
                return;
            }
            ServerPacket Response = new ServerPacket(ServerPacketHeader.MoodlightConfigMessageComposer);

            Response.WriteInteger(room.MoodlightData.Presets.Count);
            Response.WriteInteger(room.MoodlightData.CurrentPreset);
            int i = 0;

            foreach (MoodlightPreset moodlightPreset in room.MoodlightData.Presets)
            {
                ++i;
                Response.WriteInteger(i);
                Response.WriteInteger(int.Parse(ButterflyEnvironment.BoolToEnum(moodlightPreset.BackgroundOnly)) + 1);
                Response.WriteString(moodlightPreset.ColorCode);
                Response.WriteInteger(moodlightPreset.ColorIntensity);
            }
            Session.SendPacket(Response);
        }
コード例 #2
0
        public void Execute(GameClient Session, Room Room, RoomUser UserRoom, string[] Params)
        {
            if (Params.Length != 2)
            {
                return;
            }

            GameClient clientByUsername = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (clientByUsername == null || clientByUsername.GetHabbo() == null)
            {
                return;
            }

            clientByUsername.GetHabbo().IgnoreAll = !clientByUsername.GetHabbo().IgnoreAll;

            if (clientByUsername.GetHabbo().IgnoreAll)
            {
                UserRoom.SendWhisperChat("IgnoreAll activé");
            }
            else
            {
                UserRoom.SendWhisperChat("IgnoreAll désactivé");
            }

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                queryreactor.RunQuery("UPDATE users SET ignoreall = '" + ButterflyEnvironment.BoolToEnum(clientByUsername.GetHabbo().IgnoreAll) + "' WHERE id = " + clientByUsername.GetHabbo().Id);
        }
コード例 #3
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

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

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

            if (BotId <= 0)
            {
                return;
            }

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

            RoomUser Bot = null;

            if (!Room.GetRoomUserManager().TryGetBot(BotId, out Bot))
            {
                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:
            {
                //Change the defaults
                Bot.BotData.Look   = Session.GetHabbo().Look;
                Bot.BotData.Gender = Session.GetHabbo().Gender;

                Room.SendPacket(new UserChangeComposer(Bot));

                using (IQueryAdapter dbClient = ButterflyEnvironment.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();
                }
                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);

                string Text   = "";
                string Phrase = "";
                for (int i = 0; i <= SpeechData.Length - 1; i++)
                {
                    Phrase = SpeechData[i];
                    if (Phrase.Length > 150)
                    {
                        Phrase.Substring(0, 150);
                    }

                    Text += SpeechData[i] + "\r";
                }

                RoomBot.ChatText = Text;
                RoomBot.LoadRandomSpeech(Text);

                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `bots` SET `chat_enabled` = @AutomaticChat, `chat_seconds` = @SpeakingInterval, `is_mixchat` = @MixChat, `chat_text` = @ChatText WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", BotId);
                    dbClient.AddParameter("AutomaticChat", ButterflyEnvironment.BoolToEnum(Convert.ToBoolean(AutomaticChat)));
                    dbClient.AddParameter("SpeakingInterval", Convert.ToInt32(SpeakingInterval));
                    dbClient.AddParameter("MixChat", ButterflyEnvironment.BoolToEnum(Convert.ToBoolean(MixChat)));
                    dbClient.AddParameter("ChatText", Text);
                    dbClient.RunQuery();
                }

                break;
            }
                #endregion

                #region Relax (3)
            case 3:
            {
                Bot.BotData.WalkingEnabled = !Bot.BotData.WalkingEnabled;
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.RunQuery("UPDATE bots SET walk_enabled = '" + ButterflyEnvironment.BoolToEnum(Bot.BotData.WalkingEnabled) + "' WHERE id = " + Bot.BotData.Id);
                }
                break;
            }
                #endregion

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

                Room.SendPacket(new DanceComposer(Bot, Bot.DanceId));

                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                    queryreactor.RunQuery("UPDATE bots SET is_dancing = '" + ButterflyEnvironment.BoolToEnum(Bot.BotData.IsDancing) + "' WHERE id = " + Bot.BotData.Id);
                break;
            }
                #endregion

                #region Change Name (5)
            case 5:
            {
                if (DataString.Length == 0)
                {
                    return;
                }
                else if (DataString.Length >= 16)
                {
                    return;
                }

                if (DataString.Contains("<img src") || DataString.Contains("<font ") || DataString.Contains("</font>") || DataString.Contains("</a>") || DataString.Contains("<i>"))
                {
                    return;
                }

                Bot.BotData.Name = DataString;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `bots` SET `name` = @name WHERE `id` = '" + Bot.BotData.Id + "' LIMIT 1");
                    dbClient.AddParameter("name", DataString);
                    dbClient.RunQuery();
                }
                Room.SendPacket(new UserNameChangeMessageComposer(Bot.BotData.Name, Bot.VirtualId));
                break;
            }
                #endregion
            }
        }
コード例 #4
0
        internal void UpdatePreset(int Preset, string Color, int Intensity, bool BgOnly)
        {
            if (!IsValidColor(Color) || !IsValidIntensity(Intensity))
            {
                return;
            }

            string Pr;

            switch (Preset)
            {
            case 3:

                Pr = "three";
                break;

            case 2:

                Pr = "two";
                break;

            case 1:
            default:

                Pr = "one";
                break;
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("UPDATE items_moodlight SET preset_" + Pr + " = '@color," + Intensity + "," + ButterflyEnvironment.BoolToEnum(BgOnly) + "' WHERE item_id = " + ItemId);
                dbClient.addParameter("color", Color);
                dbClient.runQuery();
            }

            GetPreset(Preset).ColorCode      = Color;
            GetPreset(Preset).ColorIntensity = Intensity;
            GetPreset(Preset).BackgroundOnly = BgOnly;
        }
コード例 #5
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!ButterflyEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int PetId = Packet.PopInt();

            RoomUser Pet = null;

            if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))
            {
                return;
            }

            if (Pet.PetData == null || Pet.PetData.Type != 13)
            {
                return;
            }

            if (Pet.PetData.AnyoneCanRide)
            {
                Pet.PetData.AnyoneCanRide = false;
            }
            else
            {
                Pet.PetData.AnyoneCanRide = true;
            }

            if (!Pet.PetData.AnyoneCanRide)
            {
                if (Pet.RidingHorse)
                {
                    Pet.RidingHorse = false;
                    RoomUser User = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID);
                    if (User != null)
                    {
                        if (Room.CheckRights(User.GetClient(), true))
                        {
                            User.RidingHorse = false;
                            User.HorseID     = 0;
                            User.ApplyEffect(-1);
                            User.MoveTo(User.X + 1, User.Y + 1);
                        }
                    }
                }
            }


            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_pets` SET `anyone_ride` = '" + ButterflyEnvironment.BoolToEnum(Pet.PetData.AnyoneCanRide) + "' WHERE `id` = '" + PetId + "' LIMIT 1");
            }

            Room.SendPacket(new PetInformationComposer(Pet.PetData, Pet.RidingHorse));
        }