Esempio n. 1
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void Init(IQueryAdapter dbClient)
        {
            Polls.Clear();

            dbClient.SetQuery("SELECT * FROM polls_data WHERE enabled = '1'");

            var table = dbClient.GetTable();

            if (table == null)
                return;

            foreach (DataRow dataRow in table.Rows)
            {
                var num = uint.Parse(dataRow["id"].ToString());

                dbClient.SetQuery($"SELECT * FROM polls_questions WHERE poll_id = {num}");

                var table2 = dbClient.GetTable();

                var list = (from DataRow dataRow2 in table2.Rows select new PollQuestion(uint.Parse(dataRow2["id"].ToString()), (string) dataRow2["question"], int.Parse(dataRow2["answertype"].ToString()), dataRow2["answers"].ToString().Split('|'), (string) dataRow2["correct_answer"])).ToList();

                var value = new Poll(num, uint.Parse(dataRow["room_id"].ToString()), (string) dataRow["caption"], (string) dataRow["invitation"], (string) dataRow["greetings"], (string) dataRow["prize"], int.Parse(dataRow["type"].ToString()), list);

                Polls.Add(num, value);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Loads the rights.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadRights(IQueryAdapter dbClient)
        {
            ClearRights();

            dbClient.SetQuery("SELECT * FROM server_fuses;");

            DataTable table = dbClient.GetTable();

            if (table == null)
                return;

            foreach (DataRow dataRow in table.Rows)
                if (!_cmdRights.ContainsKey(dataRow["command"].ToString()))
                    _cmdRights.Add(dataRow["command"].ToString(), dataRow["rank"].ToString());
                else
                    Writer.WriteLine($"Duplicate Fuse Command \"{dataRow[0]}\" found", "Yupi.Fuses");

            dbClient.SetQuery("SELECT * FROM server_fuserights");

            DataTable table2 = dbClient.GetTable();

            if (table2 == null)
                return;

            foreach (DataRow dataRow2 in table2.Rows)
                if ((int) dataRow2["min_sub"] > 0)
                    _subRights.Add(dataRow2["fuse"].ToString(), (int) dataRow2["min_sub"]);
                else
                    if (!_rights.ContainsKey(dataRow2["fuse"].ToString()))
                        _rights.Add(dataRow2["fuse"].ToString(), (uint)dataRow2["min_rank"]);             
        }
Esempio n. 3
0
 /// <summary>
 ///     Loads the rights.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal void LoadRights(IQueryAdapter dbClient)
 {
     ClearRights();
     dbClient.SetQuery("SELECT command,rank FROM server_fuses;");
     var table = dbClient.GetTable();
     if (table != null)
     {
         foreach (DataRow dataRow in table.Rows)
         {
             if (!_cmdRights.ContainsKey((string) dataRow[0]))
             {
                 _cmdRights.Add((string) dataRow[0], (string) dataRow[1]);
             }
             else
             {
                 Logging.LogException(string.Format("Duplicate Fuse Command \"{0}\" found", dataRow[0]));
             }
         }
     }
     dbClient.SetQuery("SELECT * FROM server_fuserights");
     var table2 = dbClient.GetTable();
     if (table2 == null)
     {
         return;
     }
     foreach (DataRow dataRow2 in table2.Rows)
     {
         if ((int) dataRow2[3] == 0)
         {
             if (!_rights.ContainsKey((string) dataRow2[0]))
             {
                 _rights.Add((string) dataRow2[0], Convert.ToUInt32(dataRow2[1]));
             }
             else
             {
                 Logging.LogException(string.Format("Unknown Subscription Fuse \"{0}\" found", dataRow2[0]));
             }
         }
         else
         {
             if ((int) dataRow2[3] > 0)
             {
                 _subRights.Add((string) dataRow2[0], (int) dataRow2[3]);
             }
             else
             {
                 Logging.LogException(string.Format("Unknown fuse type \"{0}\" found", dataRow2[3]));
             }
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Gets the achievement levels.
 /// </summary>
 /// <param name="achievements">The achievements.</param>
 /// <param name="dbClient">The database client.</param>
 internal static void GetAchievementLevels(out Dictionary<string, Achievement> achievements, IQueryAdapter dbClient)
 {
     achievements = new Dictionary<string, Achievement>();
     dbClient.SetQuery("SELECT * FROM achievements_data");
     DataTable table = dbClient.GetTable();
     foreach (DataRow dataRow in table.Rows)
     {
         uint id = Convert.ToUInt32(dataRow["id"]);
         var category = (string)dataRow["category"];
         var text = (string)dataRow["group_name"];
         var level = (int)dataRow["level"];
         var rewardPixels = (int)dataRow["reward_pixels"];
         var rewardPoints = (int)dataRow["reward_points"];
         var requirement = (int)dataRow["progress_needed"];
         var level2 = new AchievementLevel(level, rewardPixels, rewardPoints, requirement);
         if (!achievements.ContainsKey(text))
         {
             Achievement achievement = new Achievement(id, text, category);
             achievement.AddLevel(level2);
             achievements.Add(text, achievement);
         }
         else
         {
             if (!achievements[text].CheckLevel(level2))
                 achievements[text].AddLevel(level2);
             else
                 Out.WriteLine("Was Found a Duplicated Level for: " + text + ", Level: " + level2.Level, "[Azure.Achievements]", ConsoleColor.Cyan);
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        ///     Gets the achievement levels.
        /// </summary>
        /// <param name="achievements">The achievements.</param>
        /// <param name="dbClient">The database client.</param>
        internal static void GetAchievementLevels(out Dictionary<string, Achievement> achievements,
            IQueryAdapter dbClient)
        {
            achievements = new Dictionary<string, Achievement>();

            dbClient.SetQuery("SELECT * FROM achievements_data");

            foreach (DataRow dataRow in dbClient.GetTable().Rows)
            {
                string achievementName = dataRow["achievement_name"].ToString();

                AchievementLevel level = new AchievementLevel((uint) dataRow["achievement_level"], (uint) dataRow["reward_pixels"],
                    (uint) dataRow["reward_points"], (uint) dataRow["progress_needed"]);

                if (!achievements.ContainsKey(achievementName))
                    achievements.Add(achievementName,
                        new Achievement((uint) dataRow["id"], achievementName,
                            dataRow["achievement_category"].ToString()));

                if (!achievements[achievementName].CheckLevel(level))
                    achievements[achievementName].AddLevel(level);
                else
                    YupiWriterManager.WriteLine(
                        "Was Found a Duplicated Level for: " + achievementName + ", Level: " + level.Level,
                        "Yupi.Achievements", ConsoleColor.Cyan);
            }
        }
 /// <summary>
 ///     Initializes the specified database client.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal static void Init(IQueryAdapter dbClient)
 {
     dbClient.SetQuery("SELECT userpeak FROM server_status");
     _userPeak = dbClient.GetInteger();
     _lowPriorityStopWatch = new Stopwatch();
     _lowPriorityStopWatch.Start();
 }
Esempio n. 7
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void Initialize(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM catalog_clothing");
            ClothingItems = new Dictionary<string, ClothingItem>();
            _table = dbClient.GetTable();

            foreach (DataRow dataRow in _table.Rows)
                ClothingItems.Add((string)dataRow["item_name"], new ClothingItem(dataRow));
        }
Esempio n. 8
0
        /// <summary>
        ///     Loads the bans.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadBans(IQueryAdapter dbClient)
        {
            _bannedUsernames.Clear();
            _bannedIPs.Clear();
            _bannedMachines.Clear();
            dbClient.SetQuery("SELECT bantype,value,reason,expire FROM users_bans");
            DataTable table = dbClient.GetTable();
            double num = Yupi.GetUnixTimeStamp();

            foreach (DataRow dataRow in table.Rows)
            {
                string text = (string) dataRow["value"];
                string reasonMessage = (string) dataRow["reason"];
                double num2 = (double) dataRow["expire"];
                string a = (string) dataRow["bantype"];

                ModerationBanType type;

                switch (a)
                {
                    case "user":
                        type = ModerationBanType.UserName;
                        break;

                    case "ip":
                        type = ModerationBanType.Ip;
                        break;

                    default:
                        type = ModerationBanType.Machine;
                        break;
                }

                ModerationBan moderationBan = new ModerationBan(type, text, reasonMessage, num2);

                if (!(num2 > num))
                    continue;

                switch (moderationBan.Type)
                {
                    case ModerationBanType.UserName:
                        if (!_bannedUsernames.Contains(text))
                            _bannedUsernames.Add(text, moderationBan);
                        break;

                    case ModerationBanType.Ip:
                        if (!_bannedIPs.Contains(text))
                            _bannedIPs.Add(text, moderationBan);
                        break;

                    default:
                        if (!_bannedMachines.ContainsKey(text))
                            _bannedMachines.Add(text, moderationBan);
                        break;
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 ///     Saves the message.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 /// <param name="toId">To identifier.</param>
 /// <param name="fromId">From identifier.</param>
 /// <param name="message">The message.</param>
 internal static void SaveMessage(IQueryAdapter dbClient, uint toId, uint fromId, string message)
 {
     dbClient.SetQuery(
         "INSERT INTO messenger_offline_messages (to_id, from_id, Message, timestamp) VALUES (@tid, @fid, @msg, UNIX_TIMESTAMP())");
     dbClient.AddParameter("tid", toId);
     dbClient.AddParameter("fid", fromId);
     dbClient.AddParameter("msg", message);
     dbClient.RunQuery();
 }
Esempio n. 10
0
        /// <summary>
        /// Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal static void Init(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT userpeak FROM server_status");
            _userPeak = dbClient.GetInteger();

            lowPriorityProcessWatch = new Stopwatch();
            consoleTitleWorkerWatch = new Stopwatch();
            lowPriorityProcessWatch.Start();
            consoleTitleWorkerWatch.Start();
        }
Esempio n. 11
0
        internal void Initialize(IQueryAdapter dbClient)
        {
            CraftingRecipes.Clear();
            dbClient.SetQuery("SELECT * FROM crafting_recipes");
            var recipes = dbClient.GetTable();
            foreach (DataRow recipe in recipes.Rows)
            {
                CraftingRecipe value = new CraftingRecipe((string)recipe["id"], (string)recipe["items"], (string)recipe["result"]);
                CraftingRecipes.Add((string)recipe["id"], value);
            }

            CraftableItems.Clear();
            dbClient.SetQuery("SELECT * FROM crafting_items");
            var items = dbClient.GetTable();
            foreach (DataRow item in items.Rows)
            {
                CraftableItems.Add((string)item["itemName"]);
            }
        }
Esempio n. 12
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal static void Init(IQueryAdapter dbClient)
        {
            _values = new Dictionary<string, string[]>();

            dbClient.SetQuery("SELECT * FROM pets_speech");
            DataTable table = dbClient.GetTable();

            foreach (DataRow dataRow in table.Rows)
                _values.Add(dataRow["pet_id"].ToString(), dataRow["responses"].ToString().Split(';'));
        }
Esempio n. 13
0
File: PetRace.cs Progetto: sgf/Yupi
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        public static void Init(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM pets_breeds");

            DataTable table = dbClient.GetTable();
            Races = new List<PetRace>();

            foreach (PetRace item in from DataRow row in table.Rows select new PetRace { RaceId = (int) row["breed_id"], Color1 = (int) row["color1"], Color2 = (int) row["color2"], Has1Color = (string) row["color1_enabled"] == "1", Has2Color = (string) row["color2_enabled"] == "1" })
                Races.Add(item);
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes the specified database client.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal void Initialize(IQueryAdapter dbClient)
 {
     dbClient.SetQuery("SELECT * FROM items_pinatas");
     Pinatas = new Dictionary<uint, PinataItem>();
     _table = dbClient.GetTable();
     foreach (DataRow dataRow in _table.Rows)
     {
         var value = new PinataItem(dataRow);
         Pinatas.Add(uint.Parse(dataRow["item_baseid"].ToString()), value);
     }
 }
Esempio n. 15
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal static void Init(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM pets_commands");

            _petCommands = new Dictionary<uint, PetCommand>();

            DataTable table = dbClient.GetTable();

            foreach (DataRow dataRow in table.Rows)
                _petCommands.Add(uint.Parse(dataRow["id"].ToString()), new PetCommand(dataRow));
        }
Esempio n. 16
0
        internal static void GetTypes(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM catalog_pets ORDER BY pet_race_id ASC");

            DataTable table = dbClient.GetTable();

            _petTypes = new Dictionary<string, PetType>();

            foreach (DataRow dataRow in table.Rows)
                _petTypes.Add((string) dataRow["pet_type"], new PetType(dataRow));
        }
Esempio n. 17
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal static void GetRaces(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM pets_races ORDER BY race_type ASC");

            DataTable table = dbClient.GetTable();

            _petRaces = new List<PetRace>();

            foreach (DataRow dataRow in table.Rows)
                _petRaces.Add(new PetRace(dataRow));
        }
Esempio n. 18
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ServerDatabaseSettings" /> class.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal ServerDatabaseSettings(IQueryAdapter dbClient)
        {
            DbData = new Dictionary<string, string>();

            DbData.Clear();
            dbClient.SetQuery("SELECT * FROM server_settings");

            DataTable table = dbClient.GetTable();

            foreach (DataRow dataRow in table.Rows)
                DbData.Add(dataRow[0].ToString(), dataRow[1].ToString());
        }
Esempio n. 19
0
 /// <summary>
 /// Initializes the offline messages.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal static void InitOfflineMessages(IQueryAdapter dbClient)
 {
     dbClient.SetQuery("SELECT * FROM messenger_offline_messages");
     var table = dbClient.GetTable();
     foreach (DataRow dataRow in table.Rows)
     {
         var key = (uint)dataRow[1];
         var id = (uint)dataRow[2];
         var msg = dataRow[3].ToString();
         var ts = (double)dataRow[4];
         if (!AzureEmulator.OfflineMessages.ContainsKey(key))
             AzureEmulator.OfflineMessages.Add(key, new List<OfflineMessage>());
         AzureEmulator.OfflineMessages[key].Add(new OfflineMessage(id, msg, ts));
     }
 }
Esempio n. 20
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void Initialize(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM achievements_talents ORDER BY `order_num` ASC");

            DataTable table = dbClient.GetTable();

            foreach (Talent talent in from DataRow dataRow in table.Rows select new Talent(
                (int)dataRow["id"], 
                (string)dataRow["type"], 
                (int)dataRow["parent_category"],
                (int)dataRow["level"], 
                (string)dataRow["achievement_group"], 
                (int)dataRow["achievement_level"],
                (string)dataRow["prize"], 
                (uint)dataRow["prize_baseitem"]))
                Talents.Add(talent.Id, talent);
        }
Esempio n. 21
0
        /// <summary>
        ///     Initializes the offline messages.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal static void InitOfflineMessages(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM messenger_offline_messages");
            DataTable table = dbClient.GetTable();

            foreach (DataRow dataRow in table.Rows)
            {
                uint key = (uint) dataRow[1];
                uint id = (uint) dataRow[2];
                string msg = dataRow[3].ToString();
                double ts = (double) dataRow[4];

                if (!Yupi.OfflineMessages.ContainsKey(key))
                    Yupi.OfflineMessages.Add(key, new List<OfflineMessage>());

                Yupi.OfflineMessages[key].Add(new OfflineMessage(id, msg, ts));
            }
        }
Esempio n. 22
0
 /// <summary>
 /// Reloads the quests.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 public void ReloadQuests(IQueryAdapter dbClient)
 {
     _quests.Clear();
     dbClient.SetQuery("SELECT * FROM users_quests");
     DataTable table = dbClient.GetTable();
     foreach (DataRow dataRow in table.Rows)
     {
         UInt32 id = Convert.ToUInt32(dataRow["id"]);
         string category = (string)dataRow["type"];
         Int32 number = (int)dataRow["level_num"];
         Int32 goalType = (int)dataRow["goal_type"];
         UInt32 goalData = Convert.ToUInt32(dataRow["goal_data"]);
         string name = (string)dataRow["action"];
         Int32 reward = (int)dataRow["pixel_reward"];
         string dataBit = (string)dataRow["data_bit"];
         Int32 rewardType = Convert.ToInt32(dataRow["reward_type"].ToString());
         Int32 timeUnlock = (int)dataRow["timestamp_unlock"];
         Int32 timeLock = (int)dataRow["timestamp_lock"];
         Quest value = new Quest(id, category, number, (QuestType)goalType, goalData, name, reward, dataBit,
             rewardType, timeUnlock, timeLock);
         _quests.Add(id, value);
         AddToCounter(category);
     }
 }
Esempio n. 23
0
        public void processCommand(String data)
        {
            GameClient Client = null;

            String header = data.Split(Convert.ToChar(1))[0];
            String param  = data.Split(Convert.ToChar(1))[1];

            string[] Params = param.ToString().Split(':');
            int      UserId, RoomId = 0;

            switch (header.ToLower())
            {
                #region User Related
                #region :reload_credits <UserID>
            case "reload_credits":
            {
                UserId = Convert.ToInt32(Params[0]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                int Credits = 0;
                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `credits` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", UserId);
                    Credits = dbClient.getInteger();
                }

                Client.GetHabbo().Credits = Credits;
                Client.SendMessage(new CreditBalanceComposer(Client.GetHabbo().Credits));
                break;
            }

                #endregion
                #region :reload_pixels <UserID>
            case "reload_pixels":
            {
                UserId = Convert.ToInt32(Params[0]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                int Pixels = 0;
                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `activity_points` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", UserId);
                    Pixels = dbClient.getInteger();
                }

                Client.GetHabbo().Duckets = Pixels;
                Client.SendMessage(new HabboActivityPointNotificationComposer(Client.GetHabbo().Duckets, Pixels));
                break;
            }

                #endregion
                #region :reload_diamonds <UserID>
            case "reload_diamonds":
            {
                UserId = Convert.ToInt32(Params[0]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                int Diamonds = 0;
                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `vip_points` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", UserId);
                    Diamonds = dbClient.getInteger();
                }

                Client.GetHabbo().Diamonds = Diamonds;
                Client.SendMessage(new HabboActivityPointNotificationComposer(Diamonds, 0, 5));
                break;
            }

                #endregion
                #region :reload_gotw <UserID>
            case "reload_gotw":
            {
                UserId = Convert.ToInt32(Params[0]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                int GOTWPoints = 0;
                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `gotw_points` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", UserId);
                    GOTWPoints = dbClient.getInteger();
                }

                Client.GetHabbo().GOTWPoints = GOTWPoints;
                Client.SendMessage(new HabboActivityPointNotificationComposer(GOTWPoints, 0, 103));
                break;
            }

                #endregion
            case "moveto":
            {
                UserId = Convert.ToInt32(Params[0]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                Room     Testing = Client?.GetHabbo()?.CurrentRoom;
                RoomUser Testing2;
                if ((Testing2 = Testing?.GetRoomUserManager()?.GetRoomUserByHabbo(Client.GetHabbo().Username)) != null)
                {
                    Testing2.MoveTo(12, 12);
                }
                break;
            }

                #region :reload_user_rank userID
            case "reload_user_rank":
            {
                UserId = Convert.ToInt32(Params[0]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `rank` FROM `users` WHERE `id` = @userID LIMIT 1");
                    dbClient.AddParameter("userID", UserId);
                    Client.GetHabbo().Rank = dbClient.getInteger();
                }
                break;
            }

                #endregion
                #region :reload_user_vip userID
            case "reload_user_vip":
            {
                UserId = Convert.ToInt32(Params[0]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `rank_vip` FROM `users` WHERE `id` = @userID LIMIT 1");
                    dbClient.AddParameter("userID", UserId);
                    Client.GetHabbo().VIPRank = dbClient.getInteger();
                }
                break;
            }

                #endregion
                #region :reload_motto userID
            case "reload_motto":
            {
                UserId = Convert.ToInt32(Params[0]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `motto` FROM `users` WHERE `id` = @userID LIMIT 1");
                    dbClient.AddParameter("userID", UserId);
                    Client.GetHabbo().Motto = dbClient.getString();
                }

                if (Client.GetHabbo().InRoom)
                {
                    Room Room = Client.GetHabbo().CurrentRoom;
                    if (Room == null)
                    {
                        return;
                    }

                    RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Client.GetHabbo().Id);
                    if (User == null || User.GetClient() == null)
                    {
                        return;
                    }

                    Room.SendMessage(new UserChangeComposer(User, false));
                }
                break;
            }

                #endregion
                #region :alert_user <userid> <message>
            case "alert":
            case "alert_user":
            {
                UserId = Convert.ToInt32(Params[0]);
                string alertMessage = Convert.ToString(Params[1]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                Client.SendMessage(new BroadcastMessageAlertComposer(alertMessage));
                break;
            }

                #endregion
                #region :reload_badges <UserID>
            case "update_badges":
            case "reload_badges":
            {
                UserId = Convert.ToInt32(Params[0]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

                if (Client != null)
                {
                    if (Client.GetHabbo() != null)
                    {
                        Client.SendMessage(new BadgesComposer(Client));
                    }
                }
                break;
            }

                #endregion
                #region :givebadge <UserID> <badge>
            case "givebadge":
            {
                UserId = Convert.ToInt32(Params[0]);
                string badgeCode = Convert.ToString(Params[1]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

                if (Client != null)
                {
                    if (Client.GetHabbo() != null)
                    {
                        Client.GetHabbo().GetBadgeComponent().GiveBadge(badgeCode, true, Client);
                    }
                }
                break;
            }

                #endregion
                #region :disconnect <username>
            case "disconnect":
            {
                try
                {
                    GameClient TargetClient = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(Convert.ToInt32(Params[0]));
                    if (TargetClient != null && TargetClient.GetConnection() != null)
                    {
                        TargetClient.GetConnection().Dispose();
                    }
                }
                catch
                {
                    string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");
                    Console.WriteLine(CurrentTime + "» Fout tijdens disconnecten van een gebruiker via MUS");
                }
                return;
            }

                #endregion
                #region :reload_last_change userID
            case "reload_last_change":
            {
                UserId = Convert.ToInt32(Params[0]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `last_change` FROM `users` WHERE `id` = @userID LIMIT 1");
                    dbClient.AddParameter("userID", UserId);
                    Client.GetHabbo().LastNameChange = dbClient.getInteger();
                }
                break;
            }

                #endregion
                #region :goto <UserID> <RoomID>
            case "goto":
            {
                UserId = Convert.ToInt32(Params[0]);
                RoomId = Convert.ToInt32(Params[1]);

                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                if (!int.TryParse(Params[1], out RoomId))
                {
                    break;
                }
                else
                {
                    Room _room = QuasarEnvironment.GetGame().GetRoomManager().LoadRoom(RoomId);
                    if (_room == null)
                    {
                        Client.SendNotification("Failed to find the requested room!");
                    }
                    else
                    {
                        if (!Client.GetHabbo().InRoom)
                        {
                            Client.SendMessage(new RoomForwardComposer(_room.Id));
                        }
                        else
                        {
                            Client.GetHabbo().PrepareRoom(_room.Id, "");
                        }
                    }
                }
            }
            break;
                #endregion
                #endregion

                #region Fastfood
                #region :progress_achievement
            case "progress_achievement":
            {
                UserId = Convert.ToInt32(Params[0]);
                Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null)
                {
                    break;
                }

                string Achievement = Convert.ToString(Params[1]);
                int    Progress    = Convert.ToInt32(Params[2]);

                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Client, Achievement, Progress);
                break;
            }
                #endregion
                #endregion

                #region Settings related
                #region :reload_filter/:update_filter
            case "update_filter":
            case "reload_filter":
            case "recache_filter":
            case "refresh_filter":
            {
                QuasarEnvironment.GetGame().GetChatManager().GetFilter().InitWords();
                QuasarEnvironment.GetGame().GetChatManager().GetFilter().InitCharacters();
                break;
            }

                #endregion
                #region :reload_catalog/:reload_catalog
            case "update_catalog":
            case "reload_catalog":
            case "recache_catalog":
            case "refresh_catalog":
            case "update_catalogue":
            case "reload_catalogue":
            case "recache_catalogue":
            case "refresh_catalogue":
            {
                QuasarEnvironment.GetGame().GetCatalog().Init(QuasarEnvironment.GetGame().GetItemManager());
                QuasarEnvironment.GetGame().GetClientManager().SendMessage(new CatalogUpdatedComposer());
                break;
            }

                #endregion
                #region :reload_items/:update_items
            case "update_items":
            case "reload_items":
            case "recache_items":
            case "refresh_items":
            {
                QuasarEnvironment.GetGame().GetItemManager().Init();
                break;
            }

                #endregion
                #region :reload_navigator/:update_navigator
            case "update_navigator":
            case "reload_navigator":
            case "recache_navigator":
            case "refresh_navigator":
            {
                QuasarEnvironment.GetGame().GetNavigator().Init();
                break;
            }

                #endregion
                #region :reload_ranks/:update_ranks
            case "update_ranks":
            case "reload_ranks":
            case "recache_ranks":
            case "refresh_ranks":
            {
                QuasarEnvironment.GetGame().GetPermissionManager().Init();

                foreach (GameClient C in QuasarEnvironment.GetGame().GetClientManager().GetClients.ToList())
                {
                    if (C == null || C.GetHabbo() == null || C.GetHabbo().GetPermissions() == null)
                    {
                        continue;
                    }

                    C.GetHabbo().GetPermissions().Init(Client.GetHabbo());
                }
                break;
            }

                #endregion
                #region :reload_settings/:update_settings
            case "update_settings":
            case "reload_settings":
            case "recache_settings":
            case "refresh_settings":
            {
                QuasarEnvironment.ConfigData = new ConfigData();
                break;
            }

                #endregion
                #region :reload_quests/:update_quests
            case "reload_quests":
            case "update_quests":
            {
                QuasarEnvironment.GetGame().GetQuestManager().Init();
                break;
            }

                #endregion
                #region :reload_vouchers/:update_vouchers
            case "reload_vouchers":
            case "update_vouchers":
            {
                QuasarEnvironment.GetGame().GetCatalog().GetVoucherManager().Init();
                break;
            }

                #endregion
                #region :reload_bans/:update_bans
            case "update_bans":
            case "reload_bans":
            {
                QuasarEnvironment.GetGame().GetModerationManager().ReCacheBans();
                break;
            }
                #endregion
                #endregion


            //#region Camera related

            //    #region :add_preview <photo_id> <user_id> <created_at>
            //    case "add_preview":
            //    {
            //        int PhotoId = Convert.ToInt32(Params[0]);
            //        UserId = Convert.ToInt32(Params[1]);
            //        long CreatedAt = Convert.ToInt64(Params[2]);

            //        Client = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            //                    if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().CurrentRoomId < 1)
            //                           break;

            //        QuasarEnvironment.GetGame().GetCameraManager().AddPreview(new CameraPhotoPreview(PhotoId, UserId, CreatedAt));
            //                    break;
            //    }

            //    #endregion

            //    #endregion

            default:
            {
                string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");
                Console.WriteLine(CurrentTime + "» Onbekende Mus-pakket: '" + header + "'");
                return;
            }
            }
            string CurrentTime1 = DateTime.Now.ToString("HH:mm:ss" + " | ");
            Console.WriteLine(CurrentTime1 + "» Mus-command gestuurd: '" + header + "'");
        }
Esempio n. 24
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            string Gender = Packet.PopString().ToUpper();
            string Look   = BiosEmuThiago.GetGame().GetFigureManager().ProcessFigure(Packet.PopString(), Gender, Session.GetHabbo().GetClothing().GetClothingParts, true);

            if (Look == Session.GetHabbo().Look)
            {
                return;
            }

            if ((DateTime.Now - Session.GetHabbo().LastClothingUpdateTime).TotalSeconds <= 2.0)
            {
                Session.GetHabbo().ClothingUpdateWarnings += 1;
                if (Session.GetHabbo().ClothingUpdateWarnings >= 25)
                {
                    Session.GetHabbo().SessionClothingBlocked = true;
                }
                return;
            }

            if (Session.GetHabbo().SessionClothingBlocked)
            {
                return;
            }

            Session.GetHabbo().LastClothingUpdateTime = DateTime.Now;

            string[] AllowedGenders = { "M", "F" };
            if (!AllowedGenders.Contains(Gender))
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Desculpe, você escolheu um gênero inválido."));
                return;
            }

            BiosEmuThiago.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.PROFILE_CHANGE_LOOK);

            Session.GetHabbo().Look   = BiosEmuThiago.FilterFigure(Look);
            Session.GetHabbo().Gender = Gender.ToLower();

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

            BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_AvatarLooks", 1);
            Session.SendMessage(new AvatarAspectUpdateMessageComposer(Look, Gender)); //esto
            if (Session.GetHabbo().Look.Contains("ha-1006"))
            {
                BiosEmuThiago.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.WEAR_HAT);
            }

            if (Session.GetHabbo().InRoom)
            {
                RoomUser RoomUser = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                if (RoomUser != null)
                {
                    Session.SendMessage(new UserChangeComposer(RoomUser, true));
                    Session.GetHabbo().CurrentRoom.SendMessage(new UserChangeComposer(RoomUser, false));
                }
            }
        }
Esempio n. 25
0
        public void ProcessItems()
        {
            List <Item> UserOne = Users[0].OfferedItems.Values.ToList();
            List <Item> UserTwo = Users[1].OfferedItems.Values.ToList();

            RoomUser RoomUserOne = Users[0].RoomUser;
            RoomUser RoomUserTwo = Users[1].RoomUser;

            string logUserOne = "";
            string logUserTwo = "";

            if (RoomUserOne == null || RoomUserOne.GetClient() == null || RoomUserOne.GetClient().GetHabbo() == null || RoomUserOne.GetClient().GetHabbo().GetInventoryComponent() == null)
            {
                return;
            }

            if (RoomUserTwo == null || RoomUserTwo.GetClient() == null || RoomUserTwo.GetClient().GetHabbo() == null || RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent() == null)
            {
                return;
            }

            foreach (Item Item in UserOne)
            {
                Item I = RoomUserOne.GetClient().GetHabbo().GetInventoryComponent().GetItem(Item.Id);

                if (I == null)
                {
                    SendPacket(new BroadcastMessageAlertComposer("Error! Trading Failed!"));
                    return;
                }
            }

            foreach (Item Item in UserTwo)
            {
                Item I = RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent().GetItem(Item.Id);

                if (I == null)
                {
                    SendPacket(new BroadcastMessageAlertComposer("Error! Trading Failed!"));
                    return;
                }
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                foreach (Item Item in UserOne)
                {
                    logUserOne += Item.Id + ";";
                    RoomUserOne.GetClient().GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);
                    if (Item.Data.InteractionType == InteractionType.EXCHANGE && PlusEnvironment.GetSettingsManager().TryGetValue("trading.auto_exchange_redeemables") == "1")
                    {
                        RoomUserTwo.GetClient().GetHabbo().Credits += Item.Data.BehaviourData;
                        RoomUserTwo.GetClient().SendPacket(new CreditBalanceComposer(RoomUserTwo.GetClient().GetHabbo().Credits));

                        dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @id LIMIT 1");
                        dbClient.AddParameter("id", Item.Id);
                        dbClient.RunQuery();
                    }
                    else
                    {
                        if (RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item))
                        {
                            RoomUserTwo.GetClient().SendPacket(new FurniListAddComposer(Item));
                            RoomUserTwo.GetClient().SendPacket(new FurniListNotificationComposer(Item.Id, 1));

                            dbClient.SetQuery("UPDATE `items` SET `user_id` = @user WHERE id=@id LIMIT 1");
                            dbClient.AddParameter("user", RoomUserTwo.UserId);
                            dbClient.AddParameter("id", Item.Id);
                            dbClient.RunQuery();
                        }
                    }
                }

                foreach (Item Item in UserTwo)
                {
                    logUserTwo += Item.Id + ";";
                    RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);
                    if (Item.Data.InteractionType == InteractionType.EXCHANGE && PlusEnvironment.GetSettingsManager().TryGetValue("trading.auto_exchange_redeemables") == "1")
                    {
                        RoomUserOne.GetClient().GetHabbo().Credits += Item.Data.BehaviourData;
                        RoomUserOne.GetClient().SendPacket(new CreditBalanceComposer(RoomUserOne.GetClient().GetHabbo().Credits));

                        dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @id LIMIT 1");
                        dbClient.AddParameter("id", Item.Id);
                        dbClient.RunQuery();
                    }
                    else
                    {
                        if (RoomUserOne.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item))
                        {
                            RoomUserOne.GetClient().SendPacket(new FurniListAddComposer(Item));
                            RoomUserOne.GetClient().SendPacket(new FurniListNotificationComposer(Item.Id, 1));

                            dbClient.SetQuery("UPDATE `items` SET `user_id` = @user WHERE id=@id LIMIT 1");
                            dbClient.AddParameter("user", RoomUserOne.UserId);
                            dbClient.AddParameter("id", Item.Id);
                            dbClient.RunQuery();
                        }
                    }
                }

                dbClient.SetQuery("INSERT INTO `logs_client_trade` VALUES(null, @1id, @2id, @1items, @2items, UNIX_TIMESTAMP())");
                dbClient.AddParameter("1id", RoomUserOne.UserId);
                dbClient.AddParameter("2id", RoomUserTwo.UserId);
                dbClient.AddParameter("1items", logUserOne);
                dbClient.AddParameter("2items", logUserTwo);
                dbClient.RunQuery();
            }
        }
Esempio n. 26
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Oops, you must choose a room option to disable.");
                return;
            }

            if (!Room.CheckRights(Session, true))
            {
                Session.SendWhisper("Oops, only the room owner or staff can use this command.");
                return;
            }

            string Option = Params[1];

            switch (Option)
            {
            case "list":
            {
                StringBuilder List = new StringBuilder("");
                List.AppendLine("Room Command List");
                List.AppendLine("-------------------------");
                List.AppendLine("Pet Morphs: " + (Room.PetMorphsAllowed == true ? "enabled" : "disabled"));
                List.AppendLine("Pull: " + (Room.PullEnabled == true ? "enabled" : "disabled"));
                List.AppendLine("Push: " + (Room.PushEnabled == true ? "enabled" : "disabled"));
                List.AppendLine("Super Pull: " + (Room.SPullEnabled == true ? "enabled" : "disabled"));
                List.AppendLine("Super Push: " + (Room.SPushEnabled == true ? "enabled" : "disabled"));
                List.AppendLine("Respect: " + (Room.RespectNotificationsEnabled == true ? "enabled" : "disabled"));
                List.AppendLine("Enables: " + (Room.EnablesEnabled == true ? "enabled" : "disabled"));
                Session.SendNotification(List.ToString());
                break;
            }

            case "push":
            {
                Room.PushEnabled = !Room.PushEnabled;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `push_enabled` = @PushEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("PushEnabled", PlusEnvironment.BoolToEnum(Room.PushEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Push mode is now " + (Room.PushEnabled == true ? "enabled!" : "disabled!"));
                break;
            }

            case "spush":
            {
                Room.SPushEnabled = !Room.SPushEnabled;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `spush_enabled` = @PushEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("PushEnabled", PlusEnvironment.BoolToEnum(Room.SPushEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Super Push mode is now " + (Room.SPushEnabled == true ? "enabled!" : "disabled!"));
                break;
            }

            case "spull":
            {
                Room.SPullEnabled = !Room.SPullEnabled;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `spull_enabled` = @PullEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("PullEnabled", PlusEnvironment.BoolToEnum(Room.SPullEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Super Pull mode is now " + (Room.SPullEnabled == true ? "enabled!" : "disabled!"));
                break;
            }

            case "pull":
            {
                Room.PullEnabled = !Room.PullEnabled;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `pull_enabled` = @PullEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("PullEnabled", PlusEnvironment.BoolToEnum(Room.PullEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Pull mode is now " + (Room.PullEnabled == true ? "enabled!" : "disabled!"));
                break;
            }

            case "enable":
            case "enables":
            {
                Room.EnablesEnabled = !Room.EnablesEnabled;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `enables_enabled` = @EnablesEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("EnablesEnabled", PlusEnvironment.BoolToEnum(Room.EnablesEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Enables mode set to " + (Room.EnablesEnabled == true ? "enabled!" : "disabled!"));
                break;
            }

            case "respect":
            {
                Room.RespectNotificationsEnabled = !Room.RespectNotificationsEnabled;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `respect_notifications_enabled` = @RespectNotificationsEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("RespectNotificationsEnabled", PlusEnvironment.BoolToEnum(Room.RespectNotificationsEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Respect notifications mode set to " + (Room.RespectNotificationsEnabled == true ? "enabled!" : "disabled!"));
                break;
            }

            case "pets":
            case "morphs":
            {
                Room.PetMorphsAllowed = !Room.PetMorphsAllowed;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `pet_morphs_allowed` = @PetMorphsAllowed WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("PetMorphsAllowed", PlusEnvironment.BoolToEnum(Room.PetMorphsAllowed));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Human pet morphs notifications mode set to " + (Room.PetMorphsAllowed == true ? "enabled!" : "disabled!"));

                if (!Room.PetMorphsAllowed)
                {
                    foreach (RoomUser User in Room.GetRoomUserManager().GetRoomUsers())
                    {
                        if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null)
                        {
                            continue;
                        }

                        User.GetClient().SendWhisper("The room owner has disabled the ability to use a pet morph in this room.");
                        if (User.GetClient().GetHabbo().PetId > 0)
                        {
                            //Tell the user what is going on.
                            User.GetClient().SendWhisper("Oops, the room owner has just disabled pet-morphs, un-morphing you.");

                            //Change the users Pet Id.
                            User.GetClient().GetHabbo().PetId = 0;

                            //Quickly remove the old user instance.
                            Room.SendMessage(new UserRemoveComposer(User.VirtualId));

                            //Add the new one, they won't even notice a thing!!11 8-)
                            Room.SendMessage(new UsersComposer(User));
                        }
                    }
                }
                break;
            }
            }
        }
Esempio n. 27
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            int    MinCost     = Packet.PopInt();
            int    MaxCost     = Packet.PopInt();
            string SearchQuery = Packet.PopString();
            int    FilterMode  = Packet.PopInt();


            DataTable     table   = null;
            StringBuilder builder = new StringBuilder();
            string        str     = "";

            builder.Append("WHERE `state` = '1' AND `timestamp` >= " + ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestamp().ToString());
            if (MinCost >= 0)
            {
                builder.Append(" AND `total_price` > " + MinCost);
            }


            if (MaxCost >= 0)
            {
                builder.Append(" AND `total_price` < " + MaxCost);
            }

            switch (FilterMode)
            {
            case 1:
                str = "ORDER BY `asking_price` DESC";
                break;

            default:
                str = "ORDER BY `asking_price` ASC";
                break;
            }

            if (SearchQuery.Length >= 1)
            {
                builder.Append(" AND `public_name` LIKE @search_query");
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `offer_id`, `item_type`, `sprite_id`, `total_price`, `limited_number`,`limited_stack` FROM `catalog_marketplace_offers` " + builder.ToString() + " " + str + " LIMIT 500");
                dbClient.AddParameter("search_query", SearchQuery.Replace("%", "\\%").Replace("_", "\\_") + "%");

                table = dbClient.GetTable();
            }

            ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Clear();
            ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Clear();
            if (table != null)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (!ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Contains(Convert.ToInt32(row["offer_id"])))
                    {
                        ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Add(Convert.ToInt32(row["offer_id"]));
                        ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Add(new MarketOffer(Convert.ToInt32(row["offer_id"]), Convert.ToInt32(row["sprite_id"]), Convert.ToInt32(row["total_price"]), int.Parse(row["item_type"].ToString()), Convert.ToInt32(row["limited_number"]), Convert.ToInt32(row["limited_stack"])));
                    }
                }
            }

            Dictionary <int, MarketOffer> dictionary  = new Dictionary <int, MarketOffer>();
            Dictionary <int, int>         dictionary2 = new Dictionary <int, int>();

            foreach (MarketOffer item in ButterflyEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems)
            {
                if (dictionary.ContainsKey(item.SpriteId))
                {
                    if (item.LimitedNumber > 0)
                    {
                        if (!dictionary.ContainsKey(item.OfferID))
                        {
                            dictionary.Add(item.OfferID, item);
                        }
                        if (!dictionary2.ContainsKey(item.OfferID))
                        {
                            dictionary2.Add(item.OfferID, 1);
                        }
                    }
                    else
                    {
                        if (dictionary[item.SpriteId].TotalPrice > item.TotalPrice)
                        {
                            dictionary.Remove(item.SpriteId);
                            dictionary.Add(item.SpriteId, item);
                        }

                        int num = dictionary2[item.SpriteId];
                        dictionary2.Remove(item.SpriteId);
                        dictionary2.Add(item.SpriteId, num + 1);
                    }
                }
                else
                {
                    if (!dictionary.ContainsKey(item.SpriteId))
                    {
                        dictionary.Add(item.SpriteId, item);
                    }
                    if (!dictionary2.ContainsKey(item.SpriteId))
                    {
                        dictionary2.Add(item.SpriteId, 1);
                    }
                }
            }

            Session.SendPacket(new MarketPlaceOffersComposer(MinCost, MaxCost, dictionary, dictionary2));
        }
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            string VoucherCode = Packet.PopString().Replace("\r", "");

            Voucher Voucher = null;

            if (!BiosEmuThiago.GetGame().GetCatalog().GetVoucherManager().TryGetVoucher(VoucherCode, out Voucher))
            {
                Session.SendMessage(new VoucherRedeemErrorComposer(0));
                return;
            }

            if (Voucher.CurrentUses >= Voucher.MaxUses)
            {
                Session.SendNotification("Você usou esse código o máximo de vezes permitidas!");
                return;
            }

            DataRow GetRow = null;

            using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `user_vouchers` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `voucher` = @Voucher LIMIT 1");
                dbClient.AddParameter("Voucher", VoucherCode);
                GetRow = dbClient.getRow();
            }

            if (GetRow != null)
            {
                Session.SendNotification("Ops! Você já está usando esse código!");
                return;
            }
            else
            {
                using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `user_vouchers` (`user_id`,`voucher`) VALUES ('" + Session.GetHabbo().Id + "', @Voucher)");
                    dbClient.AddParameter("Voucher", VoucherCode);
                    dbClient.RunQuery();
                }
            }

            Voucher.UpdateUses();

            if (Voucher.Type == VoucherType.CREDIT)
            {
                Session.GetHabbo().Credits += Voucher.Value;
                Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " créditos. Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.DUCKET)
            {
                Session.GetHabbo().Duckets += Voucher.Value;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Voucher.Value));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " duckets. Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.DIAMOND)
            {
                Session.GetHabbo().Diamonds += Voucher.Value;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Voucher.Value, 5));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " diamantes. Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.GOTW)
            {
                Session.GetHabbo().GOTWPoints += Voucher.Value;
                Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, Voucher.Value, 103));
                Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " " + ExtraSettings.PTOS_COINS + ". Use com sabedoria " + Session.GetHabbo().Username + ".", ""));
            }
            else if (Voucher.Type == VoucherType.ITEM)
            {
                ItemData Item = null;
                if (!BiosEmuThiago.GetGame().GetItemManager().GetItem((Voucher.Value), out Item))
                {
                    // No existe este ItemId.
                    return;
                }

                Item GiveItem = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "", "");
                if (GiveItem != null)
                {
                    Session.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem);

                    Session.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1));
                    Session.SendMessage(new FurniListUpdateComposer());
                    Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acabou de receber o objeto raro, corre " + Session.GetHabbo().Username + ", confira seu invetário algo novo está ai!", ""));
                }

                Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
            }

            Session.SendMessage(new VoucherRedeemOkComposer());
        }
Esempio n. 29
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Por favor, introduzca el nombre de usuario del usuario que desea ver.");
                return;
            }

            DataRow UserData = null;
            DataRow UserInfo = null;
            string  Username = Params[1];

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`username`,`mail`,`rank`,`motto`,`credits`,`activity_points`,`vip_points`,`gotw_points`,`online`,`rank_vip` FROM users WHERE `username` = @Username LIMIT 1");
                dbClient.AddParameter("Username", Username);
                UserData = dbClient.getRow();
            }

            if (UserData == null)
            {
                Session.SendNotification("Vaya, no hay ningún usuario en la base de datos con ese nombre de usuario (" + Username + ")!");
                return;
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + Convert.ToInt32(UserData["id"]) + "' LIMIT 1");
                UserInfo = dbClient.getRow();
                if (UserInfo == null)
                {
                    dbClient.runFastQuery("INSERT INTO `user_info` (`user_id`) VALUES ('" + Convert.ToInt32(UserData["id"]) + "')");

                    dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + Convert.ToInt32(UserData["id"]) + "' LIMIT 1");
                    UserInfo = dbClient.getRow();
                }
            }

            GameClient TargetClient = CloudServer.GetGame().GetClientManager().GetClientByUsername(Username);

            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(UserInfo["trading_locked"]));

            StringBuilder HabboInfo = new StringBuilder();

            HabboInfo.Append("Cuenta de " + Convert.ToString(UserData["username"]) + ":\r\r");
            HabboInfo.Append("Información Genérica:\r");
            HabboInfo.Append("ID: " + Convert.ToInt32(UserData["id"]) + "\r");
            HabboInfo.Append("Rango: " + Convert.ToInt32(UserData["rank"]) + "\r");
            HabboInfo.Append("Rango VIP: " + Convert.ToInt32(UserData["rank_vip"]) + "\r");
            HabboInfo.Append("Email: " + Convert.ToString(UserData["mail"]) + "\r");
            HabboInfo.Append("Estado en línea: " + (TargetClient != null ? "Si" : "No") + "\r\r");

            HabboInfo.Append("Información de la moneda:\r");
            HabboInfo.Append("Créditos: " + Convert.ToInt32(UserData["credits"]) + "\r");
            HabboInfo.Append("Duckets: " + Convert.ToInt32(UserData["activity_points"]) + "\r");
            HabboInfo.Append("Diamantes: " + Convert.ToInt32(UserData["vip_points"]) + "\r");
            HabboInfo.Append("GOTW Points: " + Convert.ToInt32(UserData["gotw_points"]) + "\r\r");

            HabboInfo.Append("Información de la moderación:\r");
            HabboInfo.Append("Baneos: " + Convert.ToInt32(UserInfo["bans"]) + "\r");
            HabboInfo.Append("CFHs Sent: " + Convert.ToInt32(UserInfo["cfhs"]) + "\r");
            HabboInfo.Append("Abusive CFHs: " + Convert.ToInt32(UserInfo["cfhs_abusive"]) + "\r");
            HabboInfo.Append("Bloqueo de tradeo: " + (Convert.ToInt32(UserInfo["trading_locked"]) == 0 ? "Sin bloqueo sobresaliente" : "Expira: " + (origin.ToString("dd/MM/yyyy")) + "") + "\r");
            HabboInfo.Append("Cantidad de bloqueos comerciales: " + Convert.ToInt32(UserInfo["trading_locks_count"]) + "\r\r");

            if (TargetClient != null)
            {
                HabboInfo.Append("Sesión Actual:\r");
                if (!TargetClient.GetHabbo().InRoom)
                {
                    HabboInfo.Append("En la actualidad no en una habitación.\r");
                }
                else
                {
                    HabboInfo.Append("Sala: " + TargetClient.GetHabbo().CurrentRoom.Name + " (" + TargetClient.GetHabbo().CurrentRoom.RoomId + ")\r");
                    HabboInfo.Append("Propietario de la sala: " + TargetClient.GetHabbo().CurrentRoom.OwnerName + "\r");
                    HabboInfo.Append("Visitantes actuales: " + TargetClient.GetHabbo().CurrentRoom.UserCount + "/" + TargetClient.GetHabbo().CurrentRoom.UsersMax);
                }
            }
            Session.SendNotification(HabboInfo.ToString());
        }
Esempio n. 30
0
        public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (!item.ExtraData.Contains('\u0005'.ToString()))
            {
                return;
            }

            string[] array = item.ExtraData.Split('\u0005');

            session.GetHabbo().Gender = array[0].ToUpper() == "F" ? "F" : "M";

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Clear();

            string[] array2 = array[1].Split('.');

            foreach (string text in array2)
            {
                string[] array3 = session.GetHabbo().Look.Split('.');

                foreach (string text2 in array3)
                {
                    if (text2.Split('-')[0] == text.Split('-')[0])
                    {
                        if (dictionary.ContainsKey(text2.Split('-')[0]) && !dictionary.ContainsValue(text))
                        {
                            dictionary.Remove(text2.Split('-')[0]);
                            dictionary.Add(text2.Split('-')[0], text);
                        }
                        else
                        {
                            if (!dictionary.ContainsKey(text2.Split('-')[0]) && !dictionary.ContainsValue(text))
                            {
                                dictionary.Add(text2.Split('-')[0], text);
                            }
                        }
                    }
                    else
                    {
                        if (!dictionary.ContainsKey(text2.Split('-')[0]))
                        {
                            dictionary.Add(text2.Split('-')[0], text2);
                        }
                    }
                }
            }

            string text3 = dictionary.Values.Aggregate("", (current1, current) => $"{current1}{current}.");

            session.GetHabbo().Look = text3.TrimEnd('.');

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"UPDATE users SET look = @look, gender = @gender WHERE id = {session.GetHabbo().Id}");
                queryReactor.AddParameter("look", session.GetHabbo().Look);
                queryReactor.AddParameter("gender", session.GetHabbo().Gender);
                queryReactor.RunQuery();
            }

            session.GetMessageHandler()
            .GetResponse()
            .Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
            session.GetMessageHandler().GetResponse().AppendInteger(-1);
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Look);
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Gender.ToLower());
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Motto);
            session.GetMessageHandler().GetResponse().AppendInteger(session.GetHabbo().AchievementPoints);
            session.GetMessageHandler().SendResponse();

            RoomUser roomUserByHabbo = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);

            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));

            serverMessage.AppendInteger(roomUserByHabbo.VirtualId);
            serverMessage.AppendString(session.GetHabbo().Look);
            serverMessage.AppendString(session.GetHabbo().Gender.ToLower());
            serverMessage.AppendString(session.GetHabbo().Motto);
            serverMessage.AppendInteger(session.GetHabbo().AchievementPoints);

            session.GetHabbo().CurrentRoom.SendMessage(serverMessage);
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room;

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

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


            int BotId = Packet.PopInt();
            int X     = Packet.PopInt();
            int Y     = Packet.PopInt();

            if (!Room.GetGameMap().CanWalk(X, Y, false) || !Room.GetGameMap().ValidTile(X, Y))
            {
                Session.SendNotification("Oeps! Je kunt hier geen bot plaatsen.");
                return;
            }

            Bot Bot = null;

            if (!Session.GetHabbo().GetInventoryComponent().TryGetBot(BotId, out Bot))
            {
                return;
            }

            int BotCount = 0;

            foreach (RoomUser User in Room.GetRoomUserManager().GetUserList().ToList())
            {
                if (User == null || User.IsPet || !User.IsBot)
                {
                    continue;
                }

                BotCount += 1;
            }

            if (BotCount >= 5 && !Session.GetHabbo().GetPermissions().HasRight("bot_place_any_override"))
            {
                Session.SendNotification("Oeps! Er kunnen slechts vijf bots tegelijkertijd in een kamer rondlopen.");
                return;
            }

            //TODO: Hmm, maybe not????
            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `bots` SET `room_id` = '" + Room.RoomId + "', `x` = @CoordX, `y` = @CoordY WHERE `id` = @BotId LIMIT 1");
                dbClient.AddParameter("BotId", Bot.Id);
                dbClient.AddParameter("CoordX", X);
                dbClient.AddParameter("CoordY", Y);
                dbClient.RunQuery();
            }

            List <RandomSpeech> BotSpeechList = new List <RandomSpeech>();

            //TODO: Grab data?
            DataRow GetData = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `ai_type`,`rotation`,`walk_mode`,`automatic_chat`,`speaking_interval`,`mix_sentences`,`chat_bubble` FROM `bots` WHERE `id` = @BotId LIMIT 1");
                dbClient.AddParameter("BotId", Bot.Id);
                GetData = dbClient.getRow();

                dbClient.SetQuery("SELECT `text` FROM `bots_speech` WHERE `bot_id` = @BotId");
                dbClient.AddParameter("BotId", Bot.Id);
                DataTable BotSpeech = dbClient.getTable();

                foreach (DataRow Speech in BotSpeech.Rows)
                {
                    BotSpeechList.Add(new RandomSpeech(Convert.ToString(Speech["text"]), Bot.Id));
                }
            }

            RoomUser BotUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Bot.Id, Session.GetHabbo().CurrentRoomId, Convert.ToString(GetData["ai_type"]), Convert.ToString(GetData["walk_mode"]), Bot.Name, "", Bot.Figure, X, Y, 0, 4, 0, 0, 0, 0, ref BotSpeechList, "", 0, Bot.OwnerId, QuasarEnvironment.EnumToBool(GetData["automatic_chat"].ToString()), Convert.ToInt32(GetData["speaking_interval"]), QuasarEnvironment.EnumToBool(GetData["mix_sentences"].ToString()), Convert.ToInt32(GetData["chat_bubble"])), null);

            BotUser.Chat("Hoi hoi " + Session.GetHabbo().Username + "!", false, 0);

            Room.GetGameMap().UpdateUserMovement(new System.Drawing.Point(X, Y), new System.Drawing.Point(X, Y), BotUser);


            Bot ToRemove = null;

            if (!Session.GetHabbo().GetInventoryComponent().TryRemoveBot(BotId, out ToRemove))
            {
                Console.WriteLine("Fout bij het verwijderen van de bot: " + ToRemove.Id);
                return;
            }
            Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots()));
            QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_ExploreBot", 1, false);
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            RoomUser    RUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            List <Item> Items = Room.GetGameMap().GetRoomItemForSquare(RUser.X, RUser.Y);

            if (Params.Length == 1 || Params[1] == "help")
            {
                Session.SendMessage(new MassEventComposer("habbopages/updatemeubi"));
                return;
            }
            String  Type = Params[1].ToLower();
            int     numeroint = 0, FurnitureID = 0;
            double  numerodouble = 0;
            DataRow Item         = null;
            String  opcion       = "";

            switch (Type)
            {
            case "width":
            {
                try
                {
                    numeroint = Convert.ToInt32(Params[2]);
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `width` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item width: " + FurnitureID + " geüpdatet (Nu is de width: " + numeroint.ToString() + ")");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Alleen geldige nummers)");
                }
            }
            break;

            case "length":
            {
                try
                {
                    numeroint = Convert.ToInt32(Params[2]);
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `length` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item length: " + FurnitureID + " geüpdatet (Nu is de length: " + numeroint.ToString() + ")");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Alleen geldige nummers)");
                }
            }
            break;

            case "height":
            {
                try
                {
                    numerodouble = Convert.ToDouble(Params[2]);
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `stack_height` = '" + numerodouble + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item height: " + FurnitureID + " geüpdatet (Nu is de height: " + numerodouble.ToString() + ")");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Alleen geldige nummers)");
                }
            }
            break;

            case "interactioncount":
            {
                try
                {
                    numeroint = Convert.ToInt32(Params[2]);
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `interaction_modes_count` = '" + numeroint + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Interaction count: " + FurnitureID + " geüpdatet (Nu is het mogelijk om het meubi " + numeroint.ToString() + " te veranderen.)");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Alleen geldige nummers)");
                }
            }
            break;

            case "cansit":
            {
                try
                {
                    opcion = Params[2].ToLower();
                    if (!opcion.Equals("ja") && !opcion.Equals("nee"))
                    {
                        Session.SendWhisper("Gebruik enkel 'ja' of 'nee'.");
                        return;
                    }
                    if (opcion.Equals("ja"))
                    {
                        opcion = "1";
                    }
                    else if (opcion.Equals("nee"))
                    {
                        opcion = "0";
                    }
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `can_sit` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item can_sit: " + FurnitureID + " geüpdatet.");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Gebruik enkel 'ja' of 'nee')");
                }
            }
            break;

            case "canstack":
            {
                try
                {
                    opcion = Params[2].ToLower();
                    if (!opcion.Equals("ja") && !opcion.Equals("nee"))
                    {
                        Session.SendWhisper("Gebruik enkel 'ja' of 'nee'.");
                        return;
                    }
                    if (opcion.Equals("ja"))
                    {
                        opcion = "1";
                    }
                    else if (opcion.Equals("nee"))
                    {
                        opcion = "0";
                    }
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `can_stack` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item can_stack: " + FurnitureID + " geüpdatet");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Gebruik enkel 'ja' of 'nee'.");
                }
            }
            break;

            case "canwalk":
            {
                try
                {
                    opcion = Params[2].ToLower();
                    if (!opcion.Equals("ja") && !opcion.Equals("nee"))
                    {
                        Session.SendWhisper("Gebruik enkel 'ja' of 'nee'.");
                        return;
                    }
                    if (opcion.Equals("ja"))
                    {
                        opcion = "1";
                    }
                    else if (opcion.Equals("nee"))
                    {
                        opcion = "0";
                    }
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `is_walkable` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item can_walk: " + FurnitureID + " geüpdatet.");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Gebruik enkel 'ja' of 'nee'.)");
                }
            }
            break;

            case "marktplaats":
            {
                try
                {
                    opcion = Params[2].ToLower();
                    if (!opcion.Equals("ja") && !opcion.Equals("nee"))
                    {
                        Session.SendWhisper("Gebruik enkel 'ja' of 'nee'.");
                        return;
                    }
                    if (opcion.Equals("ja"))
                    {
                        opcion = "1";
                    }
                    else if (opcion.Equals("nee"))
                    {
                        opcion = "0";
                    }
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `is_rare` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Marktplaats optie: " + FurnitureID + " geüpdatet.");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Gebruik enkel 'ja' of 'nee'.)");
                }
            }
            break;

            case "interaction":
            {
                try
                {
                    opcion = Params[2].ToLower();
                    foreach (Item IItem in Items.ToList())
                    {
                        if (IItem == null)
                        {
                            continue;
                        }
                        using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT base_item FROM items WHERE id = '" + IItem.Id + "' LIMIT 1");
                            Item = dbClient.getRow();
                            if (Item == null)
                            {
                                continue;
                            }
                            FurnitureID = Convert.ToInt32(Item[0]);
                            dbClient.RunQuery("UPDATE `furniture` SET `interaction_type` = '" + opcion + "' WHERE `id` = '" + FurnitureID + "' LIMIT 1");
                        }
                        Session.SendWhisper("Item interaction: " + FurnitureID + " updated. (New interaction: " + opcion + ")");
                    }
                    QuasarEnvironment.GetGame().GetItemManager().Init();
                }
                catch (Exception)
                {
                    Session.SendNotification("Oeps! Er ging was mis (Alleen geldige interaction types)");
                }
            }
            break;

            default:
            {
                Session.SendNotification("Oeps! Er ging overduidelijk wat mis voor hulp typ de command :item help.");
                return;
            }
            }
        }
Esempio n. 33
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session.GetHabbo().TimeMuted > 0)
            {
                Session.SendNotification("Opa, esta silenciado - não pode enviar convites para quartos");
                return;
            }

            int Amount = Packet.PopInt();

            if (Amount > 500)
            {
                return; // don't send at all
            }
            List <int> Targets = new List <int>();

            for (int i = 0; i < Amount; i++)
            {
                int uid = Packet.PopInt();
                if (i < 100) // limit to 100 people, keep looping until we fulfil the request though
                {
                    Targets.Add(uid);
                }
            }

            string Message = StringCharFilter.Escape(Packet.PopString());

            if (Message.Length > 121)
            {
                Message = Message.Substring(0, 121);
            }

            string word;

            if (!Session.GetHabbo().GetPermissions().HasRight("word_filter_override") &&
                CloudServer.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(Message, out word))
            {
                Session.GetHabbo().BannedPhraseCount++;
                if (Session.GetHabbo().BannedPhraseCount >= 1)
                {
                    Session.GetHabbo().TimeMuted = 25;
                    Session.SendNotification("Você foi silenciado por divulgar um Hotel! " + Session.GetHabbo().BannedPhraseCount + "/3");
                    CloudServer.GetGame().GetClientManager().StaffAlert(new RoomNotificationComposer("Alerta de divulgador:",
                                                                                                     "Atenção, você mencionou a palavra <b>" + word.ToUpper() + "</b><br><br><b>Frase:</b><br><i>" + Message +
                                                                                                     "</i>.<br><br><b>Tipo</b><br>Spam por divulgação no chat.\r\n" + "- Este usuario: <b>" +
                                                                                                     Session.GetHabbo().Username + "</b>", NotificationSettings.NOTIFICATION_FILTER_IMG, "", ""));
                }
                if (Session.GetHabbo().BannedPhraseCount >= 3)
                {
                    CloudServer.GetGame().GetModerationManager().BanUser("System", HabboHotel.Moderation.ModerationBanType.USERNAME, Session.GetHabbo().Username, "Banido por fazer spam com a frase (" + Message + ")", (CloudServer.GetUnixTimestamp() + 78892200));
                    Session.Disconnect();
                    return;
                }
                return;
            }

            foreach (int UserId in Targets)
            {
                if (!Session.GetHabbo().GetMessenger().FriendshipExists(UserId))
                {
                    continue;
                }

                GameClient Client = CloudServer.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().AllowMessengerInvites == true || Client.GetHabbo().AllowConsoleMessages == false)
                {
                    continue;
                }

                Client.SendMessage(new RoomInviteComposer(Session.GetHabbo().Id, Message));
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `chatlogs_console_invitations` (`user_id`,`message`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @message, UNIX_TIMESTAMP())");
                dbClient.AddParameter("message", Message);
                dbClient.RunQuery();
            }
        }
Esempio n. 34
0
        public void Init()
        {
            if (this._searchResultLists.Count > 0)
            {
                this._searchResultLists.Clear();
            }

            if (this._featuredRooms.Count > 0)
            {
                this._featuredRooms.Clear();
            }

            if (this._staffPicks.Count > 0)
            {
                this._staffPicks.Clear();
            }

            DataTable Table = null;

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `navigator_categories` ORDER BY `id` ASC");
                Table = dbClient.getTable();

                if (Table != null)
                {
                    foreach (DataRow Row in Table.Rows)
                    {
                        if (Convert.ToInt32(Row["enabled"]) == 1)
                        {
                            if (!this._searchResultLists.ContainsKey(Convert.ToInt32(Row["id"])))
                            {
                                this._searchResultLists.Add(Convert.ToInt32(Row["id"]), new SearchResultList(Convert.ToInt32(Row["id"]), Convert.ToString(Row["category"]), Convert.ToString(Row["category_identifier"]), Convert.ToString(Row["public_name"]), true, -1, Convert.ToInt32(Row["required_rank"]), NavigatorViewModeUtility.GetViewModeByString(Convert.ToString(Row["view_mode"])), Convert.ToString(Row["category_type"]), Convert.ToString(Row["search_allowance"]), Convert.ToInt32(Row["order_id"])));
                            }
                        }
                    }
                }

                dbClient.SetQuery("SELECT `id`,`room_id`,`caption`,`description`,`image_url`,`enabled`,`cat_id` FROM `navigator_publics` ORDER BY `order_num` ASC");
                DataTable GetPublics = dbClient.getTable();

                if (GetPublics != null)
                {
                    foreach (DataRow Row in GetPublics.Rows)
                    {
                        if (Convert.ToInt32(Row["enabled"]) == 1)
                        {
                            if (!this._featuredRooms.ContainsKey(Convert.ToInt32(Row["id"])))
                            {
                                this._featuredRooms.Add(Convert.ToInt32(Row["id"]), new FeaturedRoom(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["description"]), Convert.ToString(Row["image_url"]), Convert.ToInt32(Row["cat_id"])));
                            }
                        }
                    }
                }

                dbClient.SetQuery("SELECT `room_id`,`image` FROM `navigator_staff_picks`");
                DataTable GetPicks = dbClient.getTable();

                if (GetPicks != null)
                {
                    foreach (DataRow Row in GetPicks.Rows)
                    {
                        if (!this._staffPicks.ContainsKey(Convert.ToInt32(Row["room_id"])))
                        {
                            this._staffPicks.Add(Convert.ToInt32(Row["room_id"]), new StaffPick(Convert.ToInt32(Row["room_id"]), Convert.ToString(Row["image"])));
                        }
                    }
                }
            }

            log.Info("» Navegador de salas -> CARGADO");
        }
Esempio n. 35
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
            }
        }
Esempio n. 36
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session.GetHabbo().TimeMuted > 0)
            {
                Session.SendNotification("Oops, you're currently muted - you cannot change your motto.");
                return;
            }

            if ((DateTime.Now - Session.GetHabbo().LastMottoUpdateTime).TotalSeconds <= 2.0)
            {
                Session.GetHabbo().MottoUpdateWarnings += 1;
                if (Session.GetHabbo().MottoUpdateWarnings >= 25)
                {
                    Session.GetHabbo().SessionMottoBlocked = true;
                }
                return;
            }

            if (Session.GetHabbo().SessionMottoBlocked)
            {
                return;
            }

            Session.GetHabbo().LastMottoUpdateTime = DateTime.Now;

            string newMotto = StringCharFilter.Escape(Packet.PopString().Trim());

            if (newMotto.Length > 38)
            {
                newMotto = newMotto.Substring(0, 38);
            }

            if (newMotto == Session.GetHabbo().Motto)
            {
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("word_filter_override"))
            {
                newMotto = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(newMotto);
            }

            Session.GetHabbo().Motto = newMotto;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `motto` = @motto WHERE `id` = @userId LIMIT 1");
                dbClient.AddParameter("userId", Session.GetHabbo().Id);
                dbClient.AddParameter("motto", newMotto);
                dbClient.RunQuery();
            }

            PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.ProfileChangeMotto);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_Motto", 1);

            if (Session.GetHabbo().InRoom)
            {
                Room Room = Session.GetHabbo().CurrentRoom;
                if (Room == null)
                {
                    return;
                }

                RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                if (User == null || User.GetClient() == null)
                {
                    return;
                }

                Room.SendPacket(new UserChangeComposer(User, false));
            }
        }
Esempio n. 37
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            var result = Packet.PopString();

            CraftingRecipe recipe = null;

            foreach (CraftingRecipe Receta in BiosEmuThiago.GetGame().GetCraftingManager().CraftingRecipes.Values)
            {
                if (Receta.Result.Contains(result))
                {
                    recipe = Receta;
                    break;
                }
            }

            var Final = BiosEmuThiago.GetGame().GetCraftingManager().GetRecipe(recipe.Id);

            if (Final == null)
            {
                return;
            }
            Session.SendMessage(new CraftingRecipeComposer(Final));
            if (Final != null)
            {
                int craftingTable = Packet.PopInt();

                List <Item> items = new List <Item>();

                var count = Packet.PopInt();
                for (var i = 1; i <= count; i++)
                {
                    var id = Packet.PopInt();

                    var item = Session.GetHabbo().GetInventoryComponent().GetItem(id);
                    if (item == null || items.Contains(item))
                    {
                        return;
                    }

                    items.Add(item);
                }

                foreach (var Receta in BiosEmuThiago.GetGame().GetCraftingManager().CraftingRecipes)
                {
                    bool found = false;

                    foreach (var item in Receta.Value.ItemsNeeded)
                    {
                        if (item.Value != items.Count(item2 => item2.GetBaseItem().ItemName == item.Key))
                        {
                            found = false;
                            break;
                        }
                        found = true;
                    }

                    if (found == false)
                    {
                        continue;
                    }

                    recipe = Receta.Value;
                    break;
                }

                if (recipe == null)
                {
                    return;
                }
                ItemData resultItem = BiosEmuThiago.GetGame().GetItemManager().GetItemByName(recipe.Result);
                if (resultItem == null)
                {
                    return;
                }
                bool success = true;
                foreach (var need in recipe.ItemsNeeded)
                {
                    for (var i = 1; i <= need.Value; i++)
                    {
                        ItemData item = BiosEmuThiago.GetGame().GetItemManager().GetItemByName(need.Key);
                        if (item == null)
                        {
                            success = false;
                            continue;
                        }

                        var inv = Session.GetHabbo().GetInventoryComponent().GetFirstItemByBaseId(item.Id);
                        if (inv == null)
                        {
                            success = false;
                            continue;
                        }

                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `items` WHERE user_id = '" + Session.GetHabbo() + "'");
                            DataRow Table = dbClient.getRow();
                        }
                        if (success)
                        {
                            using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + inv.Id + "' AND `user_id` = '" + Session.GetHabbo().Id + "' LIMIT 1");
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(inv.Id);

                            Session.SendMessage(new CraftingResultComposer(recipe, true));
                            Session.SendMessage(new CraftableProductsComposer());
                            BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_CrystalCracker", 1);
                            Session.SendNotification("Opa," + Session.GetHabbo().Username + " você craftor o item " + resultItem.Id + "!\n\n Status: " + Session.GetHabbo().craftThiago + "!\n\n By: Thiago Araujo!");

                            Session.GetHabbo().GetInventoryComponent().AddNewItem(0, resultItem.Id, "", 0, true, false, 0, 0);
                            Session.SendMessage(new FurniListUpdateComposer());
                            Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                            Session.GetHabbo().craftThiago = false;
                        }
                    }
                }
            }
        }
Esempio n. 38
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void Initialize(IQueryAdapter dbClient)
        {
            Categories = new HybridDictionary();
            Offers = new HybridDictionary();
            FlatOffers = new Dictionary<uint, uint>();
            EcotronRewards = new List<EcotronReward>();
            EcotronLevels = new List<int>();
            HabboClubItems = new List<CatalogItem>();

            dbClient.SetQuery("SELECT * FROM catalog_items ORDER BY id ASC");
            DataTable itemsTable = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM catalog_pages ORDER BY id ASC");
            DataTable pagesTable = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM catalog_ecotron_items ORDER BY reward_level ASC");
            DataTable ecotronItems = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM catalog_items WHERE special_name LIKE 'HABBO_CLUB_VIP%'");
            DataTable habboClubItems = dbClient.GetTable();

            if (itemsTable != null)
            {
                foreach (DataRow dataRow in itemsTable.Rows)
                {
                    if (string.IsNullOrEmpty(dataRow["item_names"].ToString()) ||
                        string.IsNullOrEmpty(dataRow["amounts"].ToString()))
                        continue;

                    string source = dataRow["item_names"].ToString();
                    string firstItem = dataRow["item_names"].ToString().Split(';')[0];

                    Item item;

                    if (!Yupi.GetGame().GetItemManager().GetItem(firstItem, out item))
                        continue;

                    uint num = !source.Contains(';') ? item.FlatId : 0;

                    if (!dataRow.IsNull("special_name"))
                        item.PublicName = (string) dataRow["special_name"];

                    CatalogItem catalogItem = new CatalogItem(dataRow, item.PublicName);

                    if (catalogItem.GetFirstBaseItem() == null)
                        continue;

                    Offers.Add(catalogItem.Id, catalogItem);

                    if (!FlatOffers.ContainsKey(num))
                        FlatOffers.Add(num, catalogItem.Id);
                }
            }

            if (pagesTable != null)
            {
                foreach (DataRow dataRow2 in pagesTable.Rows)
                {
                    bool visible = false;
                    bool enabled = false;

                    if (dataRow2["visible"].ToString() == "1")
                        visible = true;

                    if (dataRow2["enabled"].ToString() == "1")
                        enabled = true;

                    Categories.Add((uint) dataRow2["id"],
                        new CatalogPage((uint) dataRow2["id"], short.Parse(dataRow2["parent_id"].ToString()),
                            (string) dataRow2["code_name"], (string) dataRow2["caption"], visible, enabled, false,
                            (uint) dataRow2["min_rank"], (int) dataRow2["icon_image"],
                            (string) dataRow2["page_layout"], (string) dataRow2["page_headline"],
                            (string) dataRow2["page_teaser"], (string) dataRow2["page_special"],
                            (string) dataRow2["page_text1"], (string) dataRow2["page_text2"],
                            (string) dataRow2["page_text_details"], (string) dataRow2["page_text_teaser"],
                            (string) dataRow2["page_link_description"], (string) dataRow2["page_link_pagename"],
                            (int) dataRow2["order_num"], ref Offers));
                }
            }

            if (ecotronItems != null)
            {
                foreach (DataRow dataRow3 in ecotronItems.Rows)
                {
                    EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(dataRow3["display_id"]),
                        Convert.ToUInt32(dataRow3["item_id"]), Convert.ToUInt32(dataRow3["reward_level"])));

                    if (!EcotronLevels.Contains(Convert.ToInt16(dataRow3["reward_level"])))
                        EcotronLevels.Add(Convert.ToInt16(dataRow3["reward_level"]));
                }
            }

            if (habboClubItems != null)
            {
                foreach (DataRow row in habboClubItems.Rows)
                    HabboClubItems.Add(new CatalogItem(row,
                        row.IsNull("special_name") ? "Habbo VIP" : (string) row["special_name"]));
            }
        }
Esempio n. 39
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (!session.GetHabbo().InRoom)
            {
                return;
            }

            Room room = session.GetHabbo().CurrentRoom;

            if (room == null || session.GetHabbo().CurrentRoomId != room.Id || !room.CheckRights(session, true))
            {
                return;
            }

            char[] validLetters =
            {
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
                'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', '\r'
            };

            string map = packet.PopString().ToLower().TrimEnd();

            if (map.Length > 4159) //4096 + New Lines = 4159
            {
                session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "(%%%general%%%): %%%too_large_area%%% (%%%max%%% 2048 %%%tiles%%%)"));
                return;
            }

            if (map.Any(letter => !validLetters.Contains(letter)) || string.IsNullOrEmpty(map))
            {
                session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "Oops, it appears that you have entered an invalid floor map!"));
                return;
            }

            var modelData = map.Split('\r');

            int sizeY = modelData.Length;
            int sizeX = modelData[0].Length;

            if (sizeY > 64 || sizeX > 64)
            {
                session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "The maximum height and width of a model is 64x64!"));
                return;
            }

            int  lastLineLength = 0;
            bool isValid        = true;

            foreach (var data in modelData)
            {
                if (lastLineLength == 0)
                {
                    lastLineLength = data.Length;
                    continue;
                }

                if (lastLineLength != data.Length)
                {
                    isValid = false;
                }
            }

            if (!isValid)
            {
                session.SendPacket(new RoomNotificationComposer("floorplan_editor.error", "errors", "Oops, it appears that you have entered an invalid floor map!"));
                return;
            }

            int doorX         = packet.PopInt();
            int doorY         = packet.PopInt();
            int doorDirection = packet.PopInt();
            int wallThick     = packet.PopInt();
            int floorThick    = packet.PopInt();
            int wallHeight    = packet.RemainingLength() >= 4 ? packet.PopInt() : 0;

            int doorZ = 0;

            try
            {
                doorZ = Parse(modelData[doorY][doorX]);
            }
            catch
            {
                //ignored
            }

            if (wallThick > 1)
            {
                wallThick = 1;
            }

            if (wallThick < -2)
            {
                wallThick = -2;
            }

            if (floorThick > 1)
            {
                floorThick = 1;
            }

            if (floorThick < -2)
            {
                wallThick = -2;
            }

            if (wallHeight < 0)
            {
                wallHeight = 0;
            }

            if (wallHeight > 15)
            {
                wallHeight = 15;
            }

            string modelName = "model_bc_" + room.Id;

            map += '\r' + new string('x', sizeX);

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `room_models` WHERE `id` = @model AND `custom` = '1' LIMIT 1");
                dbClient.AddParameter("model", "model_bc_" + room.Id);
                DataRow row = dbClient.GetRow();

                if (row == null)//The row is still null, let's insert instead.
                {
                    dbClient.SetQuery("INSERT INTO `room_models` (`id`,`door_x`,`door_y`, `door_z`, `door_dir`,`heightmap`,`custom`,`wall_height`) VALUES (@ModelName, @DoorX, @DoorY, @DoorZ, @DoorDirection, @Map,'1',@WallHeight)");
                    dbClient.AddParameter("ModelName", "model_bc_" + room.Id);
                    dbClient.AddParameter("DoorX", doorX);
                    dbClient.AddParameter("DoorY", doorY);
                    dbClient.AddParameter("DoorDirection", doorDirection);
                    dbClient.AddParameter("DoorZ", doorZ);
                    dbClient.AddParameter("Map", map);
                    dbClient.AddParameter("WallHeight", wallHeight);
                    dbClient.RunQuery();
                }
                else
                {
                    dbClient.SetQuery("UPDATE `room_models` SET `heightmap` = @Map, `door_x` = @DoorX, `door_y` = @DoorY, `door_z` = @DoorZ,  `door_dir` = @DoorDirection, `wall_height` = @WallHeight WHERE `id` = @ModelName LIMIT 1");
                    dbClient.AddParameter("ModelName", "model_bc_" + room.Id);
                    dbClient.AddParameter("Map", map);
                    dbClient.AddParameter("DoorX", doorX);
                    dbClient.AddParameter("DoorY", doorY);
                    dbClient.AddParameter("DoorZ", doorZ);
                    dbClient.AddParameter("DoorDirection", doorDirection);
                    dbClient.AddParameter("WallHeight", wallHeight);
                    dbClient.RunQuery();
                }

                dbClient.SetQuery("UPDATE `rooms` SET `model_name` = @ModelName, `wallthick` = @WallThick, `floorthick` = @FloorThick WHERE `id` = @roomId LIMIT 1");
                dbClient.AddParameter("roomId", room.Id);
                dbClient.AddParameter("ModelName", "model_bc_" + room.Id);
                dbClient.AddParameter("WallThick", wallThick);
                dbClient.AddParameter("FloorThick", floorThick);
                dbClient.RunQuery();
            }

            room.ModelName      = modelName;
            room.WallThickness  = wallThick;
            room.FloorThickness = floorThick;

            List <RoomUser> usersToReturn = room.GetRoomUserManager().GetRoomUsers().ToList();

            PlusEnvironment.GetGame().GetRoomManager().ReloadModel(modelName);
            PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(room.Id);


            foreach (RoomUser user in usersToReturn)
            {
                if (user == null || user.GetClient() == null)
                {
                    continue;
                }

                user.GetClient().SendPacket(new RoomForwardComposer(room.Id));
            }
        }
Esempio n. 40
0
        /// <summary>
        ///     Gets the theGroup.
        /// </summary>
        /// <param name="groupId">The theGroup identifier.</param>
        /// <returns>Guild.</returns>
        internal Group GetGroup(uint groupId)
        {
            if (Groups == null)
            {
                return(null);
            }

            if (Groups.Contains(groupId))
            {
                return((Group)Groups[groupId]);
            }

            Dictionary <uint, GroupMember> members  = new Dictionary <uint, GroupMember>();
            Dictionary <uint, GroupMember> admins   = new Dictionary <uint, GroupMember>();
            Dictionary <uint, GroupMember> requests = new Dictionary <uint, GroupMember>();

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery($"SELECT * FROM groups_data WHERE id ='{groupId}' LIMIT 1");

                DataRow row = queryReactor.GetRow();

                if (row == null)
                {
                    return(null);
                }

                queryReactor.SetQuery($"SELECT * FROM groups_forums_data WHERE group_id='{groupId}' LIMIT 1");

                DataRow row2 = queryReactor.GetRow();

                GroupForum groupForum;

                if (row2 == null)
                {
                    groupForum = new GroupForum(0, string.Empty, string.Empty, 0, 0, 0, string.Empty, 0, 0, 1, 1, 2);
                }
                else
                {
                    groupForum = new GroupForum((uint)row2["id"], row2["forum_name"].ToString(),
                                                row2["forum_description"].ToString(),
                                                (uint)row2["forum_messages_count"], double.Parse(row2["forum_score"].ToString()),
                                                (uint)row2["forum_lastposter_id"], row2["forum_lastposter_name"].ToString(),
                                                (uint)row2["forum_lastposter_timestamp"],
                                                (uint)row2["who_can_read"], (uint)row2["who_can_post"], (uint)row2["who_can_thread"],
                                                (uint)row2["who_can_mod"]);
                }


                queryReactor.SetQuery("SELECT g.user_id, u.username, u.look, g.rank, g.date_join FROM groups_members g " + $"INNER JOIN users u ON (g.user_id = u.id) WHERE g.group_id='{groupId}'");

                DataTable groupMembersTable = queryReactor.GetTable();

                queryReactor.SetQuery("SELECT g.user_id, u.username, u.look FROM groups_requests g " + $"INNER JOIN users u ON (g.user_id = u.id) WHERE group_id='{groupId}'");

                DataTable groupRequestsTable = queryReactor.GetTable();

                uint userId;

                foreach (DataRow dataRow in groupMembersTable.Rows)
                {
                    userId = (uint)dataRow["user_id"];

                    int rank = int.Parse(dataRow["rank"].ToString());

                    GroupMember membGroup = new GroupMember(userId, dataRow["username"].ToString(), dataRow["look"].ToString(),
                                                            groupId, rank, (int)dataRow["date_join"]);

                    members.Add(userId, membGroup);

                    if (rank >= 1)
                    {
                        admins.Add(userId, membGroup);
                    }
                }

                foreach (DataRow dataRow in groupRequestsTable.Rows)
                {
                    userId = (uint)dataRow["user_id"];

                    GroupMember membGroup = new GroupMember(userId, dataRow["username"].ToString(), dataRow["look"].ToString(),
                                                            groupId, 0, Yupi.GetUnixTimeStamp());

                    if (!requests.ContainsKey(userId))
                    {
                        requests.Add(userId, membGroup);
                    }
                }

                Group group = new Group((uint)row["id"], row["group_name"].ToString(), row["group_description"].ToString(), (uint)row["room_id"],
                                        row["group_badge"].ToString(), (int)row["created"], (uint)row["owner_id"], (int)row["colour1"], (int)row["colour2"], members, requests,
                                        admins, Convert.ToUInt16(row["state"]), Convert.ToUInt16(row["admindeco"]), groupForum);

                Groups.Add((uint)row["id"], group);

                return(group);
            }
        }
Esempio n. 41
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

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

            char[] validLetters =
            {
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
                'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', '\r'
            };

            string Map = Packet.PopString().ToLower().TrimEnd();

            if (Map.Length > 4159) //4096 + New Lines = 4159
            {
                Session.SendMessage(new RoomNotificationComposer("floorplan_editor.error", "Error 1", "(%%%general%%%): %%%too_large_area%%% (%%%max%%% 2048 %%%tiles%%%)"));
                return;
            }

            if (Map.Any(letter => !validLetters.Contains(letter)) || String.IsNullOrEmpty(Map))
            {
                Session.SendMessage(new RoomNotificationComposer("Foutmelding", "Oeps! Je hebt een ongeldige map aangemaakt!", "Oeps! Je hebt een ongeldige map aangemaakt!"));
                return;
            }

            var modelData = Map.Split('\r');

            int SizeY = modelData.Length;
            int SizeX = modelData[0].Length;

            if (SizeY > 64 || SizeX > 64)
            {
                Session.SendMessage(new RoomNotificationComposer("Foutmelding", "Oeps! De maximale grote van een kamer mag 64x64 tegels bevatten.", ""));
                return;
            }

            int  lastLineLength = 0;
            bool isValid        = true;

            for (int i = 0; i < modelData.Length; i++)
            {
                if (lastLineLength == 0)
                {
                    lastLineLength = modelData[i].Length;
                    continue;
                }

                if (lastLineLength != modelData[i].Length)
                {
                    isValid = false;
                }
            }

            if (!isValid)
            {
                Session.SendMessage(new RoomNotificationComposer("Foutmelding", "Oeps! Je hebt een ongeldige map aangemaakt!", ""));
                return;
            }

            int DoorX         = Packet.PopInt();
            int DoorY         = Packet.PopInt();
            int DoorDirection = Packet.PopInt();
            int WallThick     = Packet.PopInt();
            int FloorThick    = Packet.PopInt();
            int WallHeight    = Packet.PopInt();

            int DoorZ = 0;

            try
            {
                DoorZ = parse(modelData[DoorY][DoorX]);
            }
            catch { }

            if (WallThick > 1)
            {
                WallThick = 1;
            }

            if (WallThick < -2)
            {
                WallThick = -2;
            }

            if (FloorThick > 1)
            {
                FloorThick = 1;
            }

            if (FloorThick < -2)
            {
                WallThick = -2;
            }

            if (WallHeight < 0)
            {
                WallHeight = 0;
            }

            if (WallHeight > 15)
            {
                WallHeight = 15;
            }

            string ModelName = "model_bc_" + Room.Id;

            Map += '\r' + new string('x', SizeX);

            DataRow Row = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `room_models` WHERE `id` = @model AND `custom` = '1' LIMIT 1");
                dbClient.AddParameter("model", "model_bc_" + Room.Id);
                Row = dbClient.getRow();

                if (Row == null)//The row is still null, let's insert instead.
                {
                    dbClient.SetQuery("INSERT INTO `room_models` (`id`,`door_x`,`door_y`, `door_z`, `door_dir`,`heightmap`,`custom`,`wall_height`) VALUES (@ModelName, @DoorX, @DoorY, @DoorZ, @DoorDirection, @Map,'1',@WallHeight)");
                    dbClient.AddParameter("ModelName", "model_bc_" + Room.Id);
                    dbClient.AddParameter("DoorX", DoorX);
                    dbClient.AddParameter("DoorY", DoorY);
                    dbClient.AddParameter("DoorDirection", DoorDirection);
                    dbClient.AddParameter("DoorZ", DoorZ);
                    dbClient.AddParameter("Map", Map);
                    dbClient.AddParameter("WallHeight", WallHeight);
                    dbClient.RunQuery();
                }
                else
                {
                    dbClient.SetQuery("UPDATE `room_models` SET `heightmap` = @Map, `door_x` = @DoorX, `door_y` = @DoorY, `door_z` = @DoorZ,  `door_dir` = @DoorDirection, `wall_height` = @WallHeight WHERE `id` = @ModelName LIMIT 1");
                    dbClient.AddParameter("ModelName", "model_bc_" + Room.Id);
                    dbClient.AddParameter("Map", Map);
                    dbClient.AddParameter("DoorX", DoorX);
                    dbClient.AddParameter("DoorY", DoorY);
                    dbClient.AddParameter("DoorZ", DoorZ);
                    dbClient.AddParameter("DoorDirection", DoorDirection);
                    dbClient.AddParameter("WallHeight", WallHeight);
                    dbClient.RunQuery();
                }

                dbClient.SetQuery("UPDATE `rooms` SET `model_name` = @ModelName, `wallthick` = @WallThick, `floorthick` = @FloorThick WHERE `id` = '" + Room.Id + "' LIMIT 1");
                dbClient.AddParameter("ModelName", "model_bc_" + Room.Id);
                dbClient.AddParameter("WallThick", WallThick);
                dbClient.AddParameter("FloorThick", FloorThick);
                dbClient.RunQuery();
            }

            Room.RoomData.ModelName      = ModelName;
            Room.RoomData.WallThickness  = WallThick;
            Room.RoomData.FloorThickness = FloorThick;

            List <RoomUser> UsersToReturn = Room.GetRoomUserManager().GetRoomUsers().ToList();

            QuasarEnvironment.GetGame().GetRoomManager().ReloadModel(ModelName);
            QuasarEnvironment.GetGame().GetRoomManager().UnloadRoom(Room);


            foreach (RoomUser User in UsersToReturn)
            {
                if (User == null || User.GetClient() == null)
                {
                    continue;
                }

                User.GetClient().SendMessage(new RoomForwardComposer(Room.Id));
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_ExploreFloorEditor", 1);
            }
        }
Esempio n. 42
0
        public void Init()
        {
            if (this._userPresets.Count > 0)
            {
                this._userPresets.Clear();
            }
            if (this._userActionPresetCategories.Count > 0)
            {
                this._userActionPresetCategories.Clear();
            }
            if (this._userActionPresetMessages.Count > 0)
            {
                this._userActionPresetMessages.Clear();
            }
            if (this._bans.Count > 0)
            {
                this._bans.Clear();
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable PresetsTable = null;
                dbClient.SetQuery("SELECT * FROM `moderation_presets`;");
                PresetsTable = dbClient.getTable();

                if (PresetsTable != null)
                {
                    foreach (DataRow Row in PresetsTable.Rows)
                    {
                        string Type = Convert.ToString(Row["type"]).ToLower();
                        switch (Type)
                        {
                        case "user":
                            this._userPresets.Add(Convert.ToString(Row["message"]));
                            break;

                        case "room":
                            this._roomPresets.Add(Convert.ToString(Row["message"]));
                            break;
                        }
                    }
                }
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable PresetsActionCats = null;
                dbClient.SetQuery("SELECT * FROM `moderation_preset_action_categories`;");
                PresetsActionCats = dbClient.getTable();

                if (PresetsActionCats != null)
                {
                    foreach (DataRow Row in PresetsActionCats.Rows)
                    {
                        this._userActionPresetCategories.Add(Convert.ToInt32(Row["id"]), Convert.ToString(Row["caption"]));
                    }
                }
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable PresetsActionMessages = null;
                dbClient.SetQuery("SELECT * FROM `moderation_preset_action_messages`;");
                PresetsActionMessages = dbClient.getTable();

                if (PresetsActionMessages != null)
                {
                    foreach (DataRow Row in PresetsActionMessages.Rows)
                    {
                        int ParentId = Convert.ToInt32(Row["parent_id"]);

                        if (!this._userActionPresetMessages.ContainsKey(ParentId))
                        {
                            this._userActionPresetMessages.Add(ParentId, new List <ModerationPresetActionMessages>());
                        }

                        this._userActionPresetMessages[ParentId].Add(new ModerationPresetActionMessages(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["message_text"]),
                                                                                                        Convert.ToInt32(Row["mute_hours"]), Convert.ToInt32(Row["ban_hours"]), Convert.ToInt32(Row["ip_ban_hours"]), Convert.ToInt32(Row["trade_lock_days"]), Convert.ToString(Row["notice"])));
                    }
                }
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable GetBans = null;
                dbClient.SetQuery("SELECT `bantype`,`value`,`reason`,`expire` FROM `bans` WHERE `bantype` = 'machine' OR `bantype` = 'user'");
                GetBans = dbClient.getTable();

                if (GetBans != null)
                {
                    foreach (DataRow dRow in GetBans.Rows)
                    {
                        string value   = Convert.ToString(dRow["value"]);
                        string reason  = Convert.ToString(dRow["reason"]);
                        double expires = (double)dRow["expire"];
                        string type    = Convert.ToString(dRow["bantype"]);

                        ModerationBan Ban = new ModerationBan(BanTypeUtility.GetModerationBanType(type), value, reason, expires);
                        if (Ban != null)
                        {
                            if (expires > PlusEnvironment.GetUnixTimestamp())
                            {
                                if (!this._bans.ContainsKey(value))
                                {
                                    this._bans.Add(value, Ban);
                                }
                            }
                            else
                            {
                                dbClient.SetQuery("DELETE FROM `bans` WHERE `bantype` = '" + BanTypeUtility.FromModerationBanType(Ban.Type) + "' AND `value` = @Key LIMIT 1");
                                dbClient.AddParameter("Key", value);
                                dbClient.RunQuery();
                            }
                        }
                    }
                }
            }

            log.Info("Loaded " + (this._userPresets.Count + this._roomPresets.Count) + " moderation presets.");
            log.Info("Loaded " + this._userActionPresetCategories.Count + " moderation categories.");
            log.Info("Loaded " + this._userActionPresetMessages.Count + " moderation action preset messages.");
            log.Info("Cached " + this._bans.Count + " username and machine bans.");
        }
Esempio n. 43
0
        public void Init()
        {
            if (this._questions.Count > 0)
            {
                this._questions.Clear();
            }

            int QuestionsLoaded = 0;

            DataTable GetQuestions = null;

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `room_poll_questions`;");
                GetQuestions = dbClient.getTable();

                if (GetQuestions != null)
                {
                    foreach (DataRow Row in GetQuestions.Rows)
                    {
                        int PollId = Convert.ToInt32(Row["poll_id"]);

                        if (!this._questions.ContainsKey(PollId))
                        {
                            this._questions[PollId] = new Dictionary <int, RoomPollQuestion>();
                        }

                        RoomPollQuestion CatalogItem = new RoomPollQuestion(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["poll_id"]), Convert.ToString(Row["question"]), Convert.ToString(Row["question_type"]), Convert.ToInt32(Row["series_order"]), Convert.ToInt32(Row["minimum_selections"]));

                        this._questions[CatalogItem.PollId].Add(CatalogItem.Id, CatalogItem);

                        QuestionsLoaded++;
                    }
                }
            }

            if (this._polls.Count > 0)
            {
                this._polls.Clear();
            }

            DataTable GetPolls = null;

            int PollsLoaded = 0;

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `room_polls` WHERE `enabled` = 'Y'");
                GetPolls = dbClient.getTable();

                if (GetPolls != null)
                {
                    foreach (DataRow Row in GetPolls.Rows)
                    {
                        this._polls.Add(Convert.ToInt32(Row["id"]), new RoomPoll(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["room_id"]),
                                                                                 Convert.ToString(Row["type"]), Convert.ToString(Row["headline"]), Convert.ToString(Row["summary"]), Convert.ToString(Row["completion_message"]),
                                                                                 Convert.ToInt32(Row["credit_reward"]), Convert.ToInt32(Row["pixel_reward"]), Convert.ToString(Row["badge_reward"]), Convert.ToDouble(Row["expiry"]),
                                                                                 this._questions.ContainsKey(Convert.ToInt32(Row["id"])) ? this._questions[Convert.ToInt32(Row["id"])] : new Dictionary <int, RoomPollQuestion>()));

                        PollsLoaded++;
                    }
                }

                //log.Info("Loaded " + PollsLoaded + " room polls & " + QuestionsLoaded + " poll questions");
                log.Info(">> Poll's Manager -> READY!");
            }
        }
Esempio n. 44
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            int ItemId = Packet.PopInt();

            Item Item = Room.GetRoomItemHandler().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Item.Data == null)
            {
                return;
            }

            if (Item.UserID != Session.GetHabbo().Id)
            {
                return;
            }

            if (Item.Data.InteractionType != InteractionType.PURCHASABLE_CLOTHING)
            {
                Session.SendNotification("Oops, este artículo no se establece como una prenda de vestir vendible");
                return;
            }

            if (Item.Data.ClothingId == 0)
            {
                Session.SendNotification("Oops, este item no tiene la configuracion como una ropa, por favor, reportalo!");
                return;
            }

            if (!NeonEnvironment.GetGame().GetCatalog().GetClothingManager().TryGetClothing(Item.Data.ClothingId, out ClothingItem Clothing))
            {
                Session.SendNotification("Vaya.. no se ha podido encontrar esta parte de la ropa!");
                return;
            }

            //Quickly delete it from the database.
            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1");
                dbClient.AddParameter("ItemId", Item.Id);
                dbClient.RunQuery();
            }

            //Remove the item.
            Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id);

            Session.GetHabbo().GetClothing().AddClothing(Clothing.ClothingName, Clothing.PartIds);
            Session.SendMessage(new FigureSetIdsComposer(Session.GetHabbo().GetClothing().GetClothingAllParts));
            Session.SendMessage(new RoomNotificationComposer("figureset.redeemed.success"));
            Session.SendWhisper("Si por alguna razon no ve su nueva ropa, recarga el client y vuelve a ingresar!", 34);
        }
Esempio n. 45
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int User = Packet.PopInt();
            int Type = Packet.PopInt();

            if (!Session.GetHabbo().GetMessenger().FriendshipExists(User))
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oops, you can only set a relationship where a friendship exists."));
                return;
            }

            if (Type < 0 || Type > 3)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Oops, you've chosen an invalid relationship type."));
                return;
            }

            if (Session.GetHabbo().Relationships.Count > 2000)
            {
                Session.SendMessage(new BroadcastMessageAlertComposer("Sorry, you're limited to a total of 2000 relationships."));
                return;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                if (Type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    dbClient.RunQuery();

                    if (Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Remove(User);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT id FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", User);
                    int Id = dbClient.getInteger();

                    if (Id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", User);
                        dbClient.RunQuery();

                        if (Session.GetHabbo().Relationships.ContainsKey(Id))
                        {
                            Session.GetHabbo().Relationships.Remove(Id);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + Session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", User);
                    dbClient.AddParameter("type", Type);
                    int newId = Convert.ToInt32(dbClient.InsertQuery());

                    if (!Session.GetHabbo().Relationships.ContainsKey(User))
                    {
                        Session.GetHabbo().Relationships.Add(User, new Relationship(newId, User, Type));
                    }
                }

                GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(User);
                if (Client != null)
                {
                    Session.GetHabbo().GetMessenger().UpdateFriend(User, Client, true);
                }
                else
                {
                    Habbo Habbo = PlusEnvironment.GetHabboById(User);
                    if (Habbo != null)
                    {
                        MessengerBuddy Buddy = null;
                        if (Session.GetHabbo().GetMessenger().TryGetFriend(User, out Buddy))
                        {
                            Session.SendMessage(new FriendListUpdateComposer(Session, Buddy));
                        }
                    }
                }
            }
        }
Esempio n. 46
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        public void Initialize(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM navigator_flatcats WHERE enabled = '2'");
            DataTable table = dbClient.GetTable();

            dbClient.SetQuery("SELECT * FROM navigator_publics");
            DataTable table2 = dbClient.GetTable();

            dbClient.SetQuery("SELECT * FROM navigator_pubcats");
            DataTable table3 = dbClient.GetTable();

            dbClient.SetQuery("SELECT * FROM navigator_promocats");
            DataTable table4 = dbClient.GetTable();

            if (table4 != null)
            {
                PromoCategories.Clear();

                foreach (DataRow dataRow in table4.Rows)
                    PromoCategories.Add((int) dataRow["id"],  new PromoCategory((int) dataRow["id"], (string) dataRow["caption"], (int) dataRow["min_rank"], Yupi.EnumToBool((string) dataRow["visible"])));
            }

            if (table != null)
            {
                PrivateCategories.Clear();

                foreach (DataRow dataRow in table.Rows)
                    PrivateCategories.Add((int) dataRow["id"], new PublicCategory((int) dataRow["id"], (string) dataRow["caption"], (int) dataRow["min_rank"]));
            }

            if (table2 != null)
            {
                _publicItems.Clear();

                foreach (DataRow row in table2.Rows)
                {
                    _publicItems.Add(Convert.ToUInt32(row["id"]),
                        new PublicItem(Convert.ToUInt32(row["id"]), int.Parse(row["bannertype"].ToString()),
                            (string) row["caption"],
                            (string) row["description"], (string) row["image"],
                            row["image_type"].ToString().ToLower() == "internal"
                                ? PublicImageType.Internal
                                : PublicImageType.External, (uint) row["room_id"], 0, (int) row["category_parent_id"],
                            row["recommended"].ToString() == "1", (int) row["typeofdata"], string.Empty));
                }
            }

            if (table3 != null)
            {
                InCategories.Clear();

                foreach (DataRow dataRow in table3.Rows)
                    InCategories.Add((int) dataRow["id"], (string) dataRow["caption"]);
            }
        }
Esempio n. 47
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            int GroupId = Packet.PopInt();

            Group Group = null;

            if (!ButterflyEnvironment.GetGame().GetGroupManager().TryGetGroup(GroupId, out Group))
            {
                return;
            }

            if (Group.CreatorId != Session.GetHabbo().Id)
            {
                return;
            }

            int Type         = Packet.PopInt();
            int FurniOptions = Packet.PopInt();

            switch (Type)
            {
            default:
            case 0:
                Group.GroupType = GroupType.OPEN;
                break;

            case 1:
                Group.GroupType = GroupType.LOCKED;
                break;

            case 2:
                Group.GroupType = GroupType.PRIVATE;
                break;
            }

            if (Group.GroupType != GroupType.LOCKED)
            {
                if (Group.GetRequests.Count > 0)
                {
                    foreach (int UserId in Group.GetRequests.ToList())
                    {
                        Group.HandleRequest(UserId, false);
                    }

                    Group.ClearRequests();
                }
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `groups` SET `state` = @GroupState, `admindeco` = @AdminDeco WHERE `id` = @groupId LIMIT 1");
                dbClient.AddParameter("GroupState", (Group.GroupType == GroupType.OPEN ? 0 : Group.GroupType == GroupType.LOCKED ? 1 : 2).ToString());
                dbClient.AddParameter("AdminDeco", (FurniOptions == 1 ? 1 : 0).ToString());
                dbClient.AddParameter("groupId", Group.Id);
                dbClient.RunQuery();
            }

            Group.AdminOnlyDeco = FurniOptions;

            Room Room;

            if (!ButterflyEnvironment.GetGame().GetRoomManager().TryGetRoom(Group.RoomId, out Room))
            {
                return;
            }

            foreach (RoomUser User in Room.GetRoomUserManager().GetRoomUsers().ToList())
            {
                if (Room.RoomData.OwnerId == User.UserId || Group.IsAdmin(User.UserId) || !Group.IsMember(User.UserId))
                {
                    continue;
                }

                if (FurniOptions == 1)
                {
                    User.RemoveStatus("flatctrl 1");
                    User.UpdateNeeded = true;

                    User.GetClient().SendPacket(new YouAreControllerComposer(0));
                }
                else if (FurniOptions == 0 && !User.Statusses.ContainsKey("flatctrl 1"))
                {
                    User.SetStatus("flatctrl 1", "");
                    User.UpdateNeeded = true;

                    User.GetClient().SendPacket(new YouAreControllerComposer(1));
                }
            }

            Session.SendPacket(new GroupInfoComposer(Group, Session));
        }
Esempio n. 48
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Introduce el nombre del usuario que deseas ver revisar su información.");
                return;
            }

            DataRow UserData = null;
            DataRow UserInfo = null;
            string  Username = Params[1];

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM users WHERE `username` = @Username LIMIT 1");
                dbClient.AddParameter("Username", Username);
                UserData = dbClient.getRow();
            }

            if (UserData == null)
            {
                Session.SendNotification("No existe ningún usuario con el nombre " + Username + ".");
                return;
            }

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + Convert.ToInt32(UserData["id"]) + "' LIMIT 1");
                UserInfo = dbClient.getRow();
                if (UserInfo == null)
                {
                    dbClient.RunQuery("INSERT INTO `user_info` (`user_id`) VALUES ('" + Convert.ToInt32(UserData["id"]) + "')");

                    dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + Convert.ToInt32(UserData["id"]) + "' LIMIT 1");
                    UserInfo = dbClient.getRow();
                }
            }

            GameClient TargetClient = RavenEnvironment.GetGame().GetClientManager().GetClientByUsername(Username);

            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(UserInfo["trading_locked"]));

            DateTime valecrack = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);

            valecrack = valecrack.AddSeconds(Session.GetHabbo().LastOnline).ToLocalTime();

            string time = valecrack.ToString();

            StringBuilder HabboInfo = new StringBuilder();//

            HabboInfo.Append("<font color='#0489B1'><b>Información General:</b></font>\r");
            HabboInfo.Append("<font size='10'>ID: " + Convert.ToInt32(UserData["id"]) + "\r");
            HabboInfo.Append("Rango: " + Convert.ToInt32(UserData["rank"]) + "\r");
            HabboInfo.Append("Guía: " + Convert.ToInt32(UserData["guia"]) + "\r");
            HabboInfo.Append("VIP: " + Convert.ToInt32(UserData["rank_vip"]) + "\r");
            HabboInfo.Append("Email: " + Convert.ToString(UserData["mail"]) + "\r");
            HabboInfo.Append("Online: " + (TargetClient != null ? "Sí" : "No") + "\r");
            HabboInfo.Append("Última conexión: " + time + "</font>\r\r");

            HabboInfo.Append("<font color='#0489B1'><b>Información Monetaria:</b></font>\r");
            HabboInfo.Append("<font size ='10'>Créditos:<font color='#F7D358'><b> " + Convert.ToInt32(UserData["credits"]) + "</b></font>\r");
            HabboInfo.Append("Duckets:<font color='#BF00FF'><b> " + Convert.ToInt32(UserData["activity_points"]) + "</b></font>\r");
            HabboInfo.Append("Diamantes:<font color='#2E9AFE'><b> " + Convert.ToInt32(UserData["vip_points"]) + "</b></font>\r");
            HabboInfo.Append("Puntos de Juego:<font color='#FE9A2E'><b> " + Convert.ToInt32(UserData["gotw_points"]) + "</font></b></font>\r\r");

            HabboInfo.Append("<font color='#0489B1'><b>Información Moderación:</b></font>\r");
            HabboInfo.Append("<font size='10'>Baneos: " + Convert.ToInt32(UserInfo["bans"]) + "\r");
            HabboInfo.Append("Reportes Enviados: " + Convert.ToInt32(UserInfo["cfhs"]) + "\r");
            HabboInfo.Append("Abuso: " + Convert.ToInt32(UserInfo["cfhs_abusive"]) + "\r");
            HabboInfo.Append("Bloq. tradeos: " + (Convert.ToInt32(UserInfo["trading_locked"]) == 0 ? "Ninguno." : "Expira: " + (origin.ToString("dd/MM/yyyy")) + "") + "\r");
            HabboInfo.Append("Total bloqueos: " + Convert.ToInt32(UserInfo["trading_locks_count"]) + "</font>\r\r");

            if (TargetClient != null)
            {
                HabboInfo.Append("<font color = '#0489B1'><b> Localización:</b></font>\r");
                if (!TargetClient.GetHabbo().InRoom)
                {
                    HabboInfo.Append("No se encuentra en ninguna sala.\r");
                }
                else
                {
                    HabboInfo.Append("<font size='10'>Sala: " + TargetClient.GetHabbo().CurrentRoom.Name + " (" + TargetClient.GetHabbo().CurrentRoom.RoomId + ")\r");
                    HabboInfo.Append("Dueño: " + TargetClient.GetHabbo().CurrentRoom.OwnerName + "\r");
                    HabboInfo.Append("Visitantes: " + TargetClient.GetHabbo().CurrentRoom.UserCount + " de " + TargetClient.GetHabbo().CurrentRoom.UsersMax);
                }
            }
            Session.SendMessage(new RoomNotificationComposer("Información de " + Username + ":", (HabboInfo.ToString()), "usr/body/" + Username + "", "", ""));
        }
Esempio n. 49
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

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

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

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(Packet.PopInt());

            if (Item == null)
            {
                return;
            }

            if (Item.GetBaseItem() == null)
            {
                return;
            }

            string DecorationKey = string.Empty;

            switch (Item.GetBaseItem().InteractionType)
            {
            case InteractionType.FLOOR:
                DecorationKey = "floor";
                break;

            case InteractionType.WALLPAPER:
                DecorationKey = "wallpaper";
                break;

            case InteractionType.LANDSCAPE:
                DecorationKey = "landscape";
                break;
            }

            switch (DecorationKey)
            {
            case "floor":
                Room.Floor          = Item.ExtraData;
                Room.RoomData.Floor = Item.ExtraData;

                QuasarEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_DECORATION_FLOOR);
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFloor", 1);
                break;

            case "wallpaper":
                Room.Wallpaper          = Item.ExtraData;
                Room.RoomData.Wallpaper = Item.ExtraData;

                QuasarEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_DECORATION_WALL);
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoWallpaper", 1);
                break;

            case "landscape":
                Room.Landscape          = Item.ExtraData;
                Room.RoomData.Landscape = Item.ExtraData;

                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoLandscape", 1);
                break;
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `rooms` SET " + DecorationKey + " = @extradata WHERE `id` = '" + Room.RoomId + "' LIMIT 1");
                dbClient.AddParameter("extradata", Item.ExtraData);
                dbClient.RunQuery();

                dbClient.RunQuery("DELETE FROM items WHERE id=" + Item.Id + " LIMIT 1");
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);
            Room.SendMessage(new RoomPropertyComposer(DecorationKey, Item.ExtraData));
        }
Esempio n. 50
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (!session.GetHabbo().InRoom)
            {
                return;
            }

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().CurrentRoomId, out Room room))
            {
                return;
            }

            if (!room.CheckRights(session, true))
            {
                return;
            }

            Item item = session.GetHabbo().GetInventoryComponent().GetItem(packet.PopInt());

            if (item == null)
            {
                return;
            }

            if (item.GetBaseItem() == null)
            {
                return;
            }

            string decorationKey = string.Empty;

            switch (item.GetBaseItem().InteractionType)
            {
            case InteractionType.FLOOR:
                decorationKey = "floor";
                break;

            case InteractionType.WALLPAPER:
                decorationKey = "wallpaper";
                break;

            case InteractionType.LANDSCAPE:
                decorationKey = "landscape";
                break;
            }

            switch (decorationKey)
            {
            case "floor":
                room.Floor = item.ExtraData;

                PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(session, QuestType.FurniDecoFloor);
                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_RoomDecoFloor", 1);
                break;

            case "wallpaper":
                room.Wallpaper = item.ExtraData;

                PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(session, QuestType.FurniDecoWall);
                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_RoomDecoWallpaper", 1);
                break;

            case "landscape":
                room.Landscape = item.ExtraData;

                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_RoomDecoLandscape", 1);
                break;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `rooms` SET `" + decorationKey + "` = @extradata WHERE `id` = '" + room.RoomId + "' LIMIT 1");
                dbClient.AddParameter("extradata", item.ExtraData);
                dbClient.RunQuery();

                dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + item.Id + "' LIMIT 1");
            }

            session.GetHabbo().GetInventoryComponent().RemoveItem(item.Id);
            room.SendPacket(new RoomPropertyComposer(decorationKey, item.ExtraData));
        }
Esempio n. 51
0
        /// <summary>
        /// Loads the bots commands.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadBotsCommands(IQueryAdapter dbClient)
        {
            dbClient.SetQuery("SELECT * FROM bots_commands");

            BotCommands = new Dictionary<uint, BotCommand>();

            DataTable table = dbClient.GetTable();

            foreach (DataRow dataRow in table.Rows)
                BotCommands.Add(uint.Parse(dataRow["id"].ToString()), new BotCommand(dataRow));
        }
Esempio n. 52
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username);

            if (User == null)
            {
                return;
            }

            string NewName = Packet.PopString();
            string OldName = Session.GetHabbo().Username;

            if (NewName == OldName)
            {
                Session.GetHabbo().ChangeName(OldName);
                Session.SendMessage(new UpdateUsernameComposer(NewName));
                return;
            }

            if (!CanChangeName(Session.GetHabbo()))
            {
                Session.SendNotification("Oops, al parecer en este momento no puede cambiar su nombre!");
                return;
            }

            bool InUse = false;

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1");
                dbClient.AddParameter("name", NewName);
                InUse = dbClient.getInteger() == 1;
            }

            char[] Letters           = NewName.ToLower().ToCharArray();
            string AllowedCharacters = "abcdefghijklmnopqrstuvwxyz.,_-;!1234567890";

            foreach (char Chr in Letters)
            {
                if (!AllowedCharacters.Contains(Chr))
                {
                    return;
                }
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool") && NewName.ToLower().Contains("mod") || NewName.ToLower().Contains("adm") || NewName.ToLower().Contains("admin") ||
                NewName.ToLower().Contains("m0d") || NewName.ToLower().Contains("mob") || NewName.ToLower().Contains("m0b") || NewName.ToLower().Contains("MOD-") || NewName.ToLower().Contains("ADM-") || NewName.ToLower().Contains("CEO-") || NewName.ToLower().Contains("MOD") || NewName.ToLower().Contains("ADM") || NewName.ToLower().Contains("CEO") || NewName.ToLower().Contains("mg") || NewName.ToLower().Contains("bot") || NewName.ToLower().Contains("emb") || NewName.ToLower().Contains("mng") || NewName.ToLower().Contains("ADM_") || NewName.ToLower().Contains("MOD_") || NewName.ToLower().Contains("CEO_") || NewName.ToLower().Contains("GM_"))
            {
                return;
            }
            else if (NewName.Length > 15)
            {
                return;
            }
            else if (NewName.Length < 3)
            {
                return;
            }
            else if (InUse)
            {
                return;
            }
            else
            {
                if (!RavenEnvironment.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName))
                {
                    Session.SendNotification("Oops! ha ocurrido un problema mientras se actualizaba su nuevo nombre.");
                    return;
                }

                Session.GetHabbo().ChangingName = false;

                Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false);

                Session.GetHabbo().ChangeName(NewName);
                Session.GetHabbo().GetMessenger().OnStatusChanged(true);

                Session.SendMessage(new UpdateUsernameComposer(NewName));
                Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName));

                using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @name, '" + OldName + "', '" + RavenEnvironment.GetUnixTimestamp() + "')");
                    dbClient.AddParameter("name", NewName);
                    dbClient.RunQuery();
                }

                ICollection <RoomData> Rooms = Session.GetHabbo().UsersRooms;
                foreach (RoomData Data in Rooms)
                {
                    if (Data == null)
                    {
                        continue;
                    }

                    Data.OwnerName = NewName;
                }

                foreach (Room UserRoom in RavenEnvironment.GetGame().GetRoomManager().GetRooms().ToList())
                {
                    if (UserRoom == null || UserRoom.RoomData.OwnerName != NewName)
                    {
                        continue;
                    }

                    UserRoom.OwnerName          = NewName;
                    UserRoom.RoomData.OwnerName = NewName;

                    UserRoom.SendMessage(new RoomInfoUpdatedComposer(UserRoom.RoomId));
                }

                RavenEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_Name", 1);

                Session.SendMessage(new RoomForwardComposer(Room.Id));
            }
        }
Esempio n. 53
0
 /// <summary>
 /// Initializes the specified database client.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal static void Init(IQueryAdapter dbClient)
 {
     dbClient.SetQuery("SELECT * FROM pets_commands");
     _table = dbClient.GetTable();
     _petCommands = new Dictionary<string, PetCommand>();
     foreach (DataRow row in _table.Rows)
     {
         _petCommands.Add(row[1].ToString(), new PetCommand(Convert.ToInt32(row[0].ToString()), row[1].ToString()));
     }
 }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            int ItemId = Packet.PopInt();

            Item Item = Room.GetRoomItemHandler().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Item.Data == null)
            {
                return;
            }

            if (Item.UserID != Session.GetHabbo().Id)
            {
                return;
            }

            if (Item.Data.InteractionType != InteractionType.PURCHASABLE_CLOTHING)
            {
                Session.SendNotification("Ops, deu ruim ae em, chama um staff!");
                return;
            }

            if (Item.Data.BehaviourData == 0)
            {
                Session.SendNotification("Ops, este artigo não tem nenhuma configurações de roupa, por favor informe!");
                return;
            }

            ClothingItem Clothing = null;

            if (!BiosEmuThiago.GetGame().GetCatalog().GetClothingManager().TryGetClothing(Item.Data.ClothingId, out Clothing))
            {
                Session.SendNotification("Ops! essa parte da roupa não foi encontrada!");
                return;
            }

            //Quickly delete it from the database.
            using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1");
                dbClient.AddParameter("ItemId", Item.Id);
                dbClient.RunQuery();
            }

            //Remove the item.
            Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id);

            Session.GetHabbo().GetClothing().AddClothing(Clothing.ClothingName, Clothing.PartIds);
            Session.SendMessage(new FigureSetIdsComposer(Session.GetHabbo().GetClothing().GetClothingParts));
            Session.SendMessage(new RoomNotificationComposer("figureset.redeemed.success"));
            Session.SendWhisper("Por algum motivo você não pode ver as suas roupas novas, tente novamente!");
        }
Esempio n. 55
0
        /// <summary>
        ///     Loads the message presets.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadMessagePresets(IQueryAdapter dbClient)
        {
            UserMessagePresets.Clear();
            RoomMessagePresets.Clear();
            SupportTicketHints.Clear();
            ModerationTemplates.Clear();
            dbClient.SetQuery("SELECT type,message FROM moderation_presets WHERE enabled = 2");
            DataTable table = dbClient.GetTable();
            dbClient.SetQuery("SELECT word,hint FROM moderation_tickethints");
            DataTable table2 = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM moderation_templates");
            DataTable table3 = dbClient.GetTable();

            if (table == null || table2 == null)
                return;

            foreach (DataRow dataRow in table.Rows)
            {
                string item = (string) dataRow["message"];
                string a = dataRow["type"].ToString().ToLower();

                if (a != "message")
                {
                    switch (a)
                    {
                        case "roommessage":
                            RoomMessagePresets.Add(item);
                            break;
                    }
                }
                else
                    UserMessagePresets.Add(item);
            }

            foreach (DataRow dataRow2 in table2.Rows)
                SupportTicketHints.Add((string) dataRow2[0], (string) dataRow2[1]);

            foreach (DataRow dataRow3 in table3.Rows)
                ModerationTemplates.Add(uint.Parse(dataRow3["id"].ToString()),
                    new ModerationTemplate(uint.Parse(dataRow3["id"].ToString()),
                        short.Parse(dataRow3["category"].ToString()), dataRow3["cName"].ToString(),
                        dataRow3["caption"].ToString(), dataRow3["warning_message"].ToString(),
                        dataRow3["ban_message"].ToString(), short.Parse(dataRow3["ban_hours"].ToString()),
                        dataRow3["avatar_ban"].ToString() == "1", dataRow3["mute"].ToString() == "1",
                        dataRow3["trade_lock"].ToString() == "1"));
        }
Esempio n. 56
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Oops, debes elegir una opcion para desactivar. ejecuta el comando ':room list'");
                return;
            }

            if (!Room.CheckRights(Session, true))
            {
                Session.SendWhisper("Oops, solo el dueño de la sala puede ejecutar este comando");
                return;
            }

            string Option = Params[1];

            switch (Option)
            {
            case "list":
            {
                StringBuilder List = new StringBuilder("");
                List.AppendLine("Lista de comando en salas");
                List.AppendLine("-------------------------");
                List.AppendLine("Pet Morphs: " + (Room.PetMorphsAllowed == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Pull: " + (Room.PullEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Push: " + (Room.PushEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Golpes: " + (Room.GolpeEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Super Pull: " + (Room.SPullEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Super Push: " + (Room.SPushEnabled == true ? "Habilitado" : "Deshabilitado"));
                List.AppendLine("Respect: " + (Room.RespectNotificationsEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Enables: " + (Room.EnablesEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Besos: " + (Room.BesosEnabled == true ? "Habilitado" : "Deshabilitado"));
                //List.AppendLine("Quemar: " + (Room.QuemarEnabled == true ? "Habilitado" : "Deshabilitado"));
                Session.SendNotification(List.ToString());
                break;
            }

            //case "golpe":
            //{
            //    Room.GolpeEnabled = !Room.GolpeEnabled;
            //    using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //    {
            //        dbClient.SetQuery("UPDATE `rooms` SET `golpe_enabled` = @GolpeEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //        dbClient.AddParameter("GolpeEnabled", RavenEnvironment.BoolToEnum(Room.GolpeEnabled));
            //        dbClient.RunQuery();
            //    }

            //    Session.SendWhisper("Los golpes en esta sala estan " + (Room.GolpeEnabled == true ? "Habilitado!" : "Deshabilitado!"));
            //    break;
            //}

            //case "quemar":
            //    {
            //        Room.QuemarEnabled = !Room.QuemarEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `quemar_enabled` = @QuemarEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //            dbClient.AddParameter("QuemarEnabled", RavenEnvironment.BoolToEnum(Room.QuemarEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("¡El poder de quemar en esta sala está " + (Room.QuemarEnabled == true ? "habilitado!" : "deshabilitado!"));
            //        break;
            //    }

            //case "beso":
            //    {
            //        Room.BesosEnabled = !Room.BesosEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `besos_enabled` = @BesosENabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //            dbClient.AddParameter("BesosEnabled", RavenEnvironment.BoolToEnum(Room.QuemarEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("¡El poder de besar en esta sala está " + (Room.QuemarEnabled == true ? "habilitado!" : "deshabilitado!"));
            //        break;
            //    }

            //case "push":
            //    {
            //        Room.PushEnabled = !Room.PushEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `push_enabled` = @PushEnabled WHERE `id` = '" + Room.Id +"' LIMIT 1");
            //            dbClient.AddParameter("PushEnabled", RavenEnvironment.BoolToEnum(Room.PushEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("Modo Push ahora esta " + (Room.PushEnabled == true ? "Habilitado!" : "Deshabilitado!"));
            //        break;
            //    }

            //case "spush":
            //    {
            //        Room.SPushEnabled = !Room.SPushEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `spush_enabled` = @PushEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //            dbClient.AddParameter("PushEnabled", RavenEnvironment.BoolToEnum(Room.SPushEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("Modo Super Push ahora esta " + (Room.SPushEnabled == true ? "Habilitado!" : "Deshabilitado!"));
            //        break;
            //    }

            //case "spull":
            //    {
            //        Room.SPullEnabled = !Room.SPullEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `spull_enabled` = @PullEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //            dbClient.AddParameter("PullEnabled", RavenEnvironment.BoolToEnum(Room.SPullEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("Modo Super Pull ahora esta  " + (Room.SPullEnabled == true ? "Habilitado!" : "Deshabilitado!"));
            //        break;
            //    }

            //case "pull":
            //    {
            //        Room.PullEnabled = !Room.PullEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `pull_enabled` = @PullEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //            dbClient.AddParameter("PullEnabled", RavenEnvironment.BoolToEnum(Room.PullEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("Modo Pull ahora esta " + (Room.PullEnabled == true ? "Habilitado!" : "Deshabilitado!"));
            //        break;
            //    }

            //case "enable":
            //case "enables":
            //    {
            //        Room.EnablesEnabled = !Room.EnablesEnabled;
            //        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            //        {
            //            dbClient.SetQuery("UPDATE `rooms` SET `enables_enabled` = @EnablesEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
            //            dbClient.AddParameter("EnablesEnabled", RavenEnvironment.BoolToEnum(Room.EnablesEnabled));
            //            dbClient.RunQuery();
            //        }

            //        Session.SendWhisper("Los efectos en esta sala estan " + (Room.EnablesEnabled == true ? "Habilitados!" : "Deshabilitados!"));
            //        break;
            //    }

            case "respect":
            {
                Room.RespectNotificationsEnabled = !Room.RespectNotificationsEnabled;
                using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `respect_notifications_enabled` = @RespectNotificationsEnabled WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("RespectNotificationsEnabled", RavenEnvironment.BoolToEnum(Room.RespectNotificationsEnabled));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Notificaciones de Respeto estan " + (Room.RespectNotificationsEnabled == true ? "Habilitado!" : "Deshabilitado!"));
                break;
            }

            case "pets":
            case "morphs":
            {
                Room.PetMorphsAllowed = !Room.PetMorphsAllowed;
                using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `pet_morphs_allowed` = @PetMorphsAllowed WHERE `id` = '" + Room.Id + "' LIMIT 1");
                    dbClient.AddParameter("PetMorphsAllowed", RavenEnvironment.BoolToEnum(Room.PetMorphsAllowed));
                    dbClient.RunQuery();
                }

                Session.SendWhisper("Que se convierta en mascotas esta " + (Room.PetMorphsAllowed == true ? "Habilitado!" : "Deshabilitado!"));

                if (!Room.PetMorphsAllowed)
                {
                    foreach (RoomUser User in Room.GetRoomUserManager().GetRoomUsers())
                    {
                        if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null)
                        {
                            continue;
                        }

                        User.GetClient().SendWhisper("El propietario de la sala ha deshabilitado la opcion de convertirse en mascota.");
                        if (User.GetClient().GetHabbo().PetId > 0)
                        {
                            //Tell the user what is going on.
                            User.GetClient().SendWhisper("Oops, el dueño de la sala solo permite Usuarios normales, no mascotas..");

                            //Change the users Pet Id.
                            User.GetClient().GetHabbo().PetId = 0;

                            //Quickly remove the old user instance.
                            Room.SendMessage(new UserRemoveComposer(User.VirtualId));

                            //Add the new one, they won't even notice a thing!!11 8-)
                            Room.SendMessage(new UsersComposer(User));
                        }
                    }
                }
                break;
            }
            }
        }
Esempio n. 57
0
        /// <summary>
        /// Loads the models.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadModels(IQueryAdapter dbClient)
        {
            _roomModels.Clear();
            dbClient.SetQuery(
                "SELECT id,door_x,door_y,door_z,door_dir,heightmap,public_items,club_only,poolmap FROM rooms_models");
            var table = dbClient.GetTable();
            if (table == null) return;
            foreach (DataRow dataRow in table.Rows)
            {
                var key = (string)dataRow["id"];
                if (key.StartsWith("model_floorplan_")) continue;
                var staticFurniMap = (string)dataRow["public_items"];
                _roomModels.Add(key,
                    new RoomModel((int)dataRow["door_x"], (int)dataRow["door_y"], (double)dataRow["door_z"],
                        (int)dataRow["door_dir"], (string)dataRow["heightmap"], staticFurniMap,
                        AzureEmulator.EnumToBool(dataRow["club_only"].ToString()), (string)dataRow["poolmap"]));
            }
            dbClient.SetQuery("SELECT roomid,door_x,door_y,door_z,door_dir,heightmap FROM rooms_models_customs");
            var dataCustom = dbClient.GetTable();

            if (dataCustom == null) return;

            foreach (DataRow row in dataCustom.Rows)
            {
                var modelName = string.Format("custom_{0}", row["roomid"]);
                _roomModels.Add(modelName,
                    new RoomModel((int)row["door_x"], (int)row["door_y"], (double)row["door_z"],
                        (int)row["door_dir"],
                        (string)row["heightmap"], "", false, ""));
            }
        }
Esempio n. 58
0
 /// <summary>
 /// Initializes the voted rooms.
 /// </summary>
 /// <param name="dbClient">The database client.</param>
 internal void InitVotedRooms(IQueryAdapter dbClient)
 {
     dbClient.SetQuery(
         "SELECT * FROM rooms_data WHERE score > 0 AND roomtype = 'private' ORDER BY score DESC LIMIT 40");
     var table = dbClient.GetTable();
     foreach (
         var data in
             from DataRow dataRow in table.Rows select FetchRoomData(Convert.ToUInt32(dataRow["id"]), dataRow))
         QueueVoteAdd(data);
 }
Esempio n. 59
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter the username of the user you'd like to IP ban & account ban.");
                return;
            }

            Habbo Habbo = RavenEnvironment.GetHabboByUsername(Params[1]);

            if (Habbo == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user in the database.");
                return;
            }

            if (Habbo.GetPermissions().HasRight("mod_tool") && !Session.GetHabbo().GetPermissions().HasRight("mod_ban_any") && Session.GetHabbo().Username != "Anegrado" && Session.GetHabbo().Username != "lKarus")
            {
                Session.SendWhisper("Oops, you cannot ban that user.");
                return;
            }

            String IPAddress = String.Empty;
            Double Expire    = RavenEnvironment.GetUnixTimestamp() + 78892200;
            string Username  = Habbo.Username;

            using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_info` SET `bans` = `bans` + '1' WHERE `user_id` = '" + Habbo.Id + "' LIMIT 1");

                dbClient.SetQuery("SELECT `ip_last` FROM `users` WHERE `id` = '" + Habbo.Id + "' LIMIT 1");
                IPAddress = dbClient.getString();
            }

            string Reason = null;

            if (Params.Length >= 3)
            {
                Reason = CommandManager.MergeParams(Params, 2);
            }
            else
            {
                Reason = "No reason specified.";
            }

            if (!string.IsNullOrEmpty(IPAddress))
            {
                RavenEnvironment.GetGame().GetModerationManager().BanUser(Session.GetHabbo().Username, ModerationBanType.IP, IPAddress, Reason, Expire);
            }
            RavenEnvironment.GetGame().GetModerationManager().BanUser(Session.GetHabbo().Username, ModerationBanType.USERNAME, Habbo.Username, Reason, Expire);

            GameClient TargetClient = RavenEnvironment.GetGame().GetClientManager().GetClientByUsername(Username);

            if (TargetClient != null)
            {
                TargetClient.Disconnect();
            }


            Session.SendWhisper("Success, you have IP and account banned the user '" + Username + "' for '" + Reason + "'!");
        }
Esempio n. 60
-1
        /// <summary>
        ///     Saves the furniture.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        /// <param name="session">The session.</param>
        public void SaveFurniture(IQueryAdapter dbClient, GameClient session = null)
        {
            try
            {
                if (!_updatedItems.Any() && !_removedItems.Any() && _room.GetRoomUserManager().PetCount <= 0)
                    return;

                foreach (uint itemId in _removedItems)
                    dbClient.RunFastQuery($"UPDATE items_rooms SET room_id='0', x='0', y='0', z='0', rot='0' WHERE id = {itemId}");

                foreach (RoomItem roomItem in _updatedItems.Select(GetItem).Where(roomItem => roomItem != null))
                {
                    if (roomItem.GetBaseItem() != null && roomItem.GetBaseItem().IsGroupItem)
                    {
                        try
                        {
                            string[] gD = roomItem.GroupData.Split(';');

                            roomItem.ExtraData = roomItem.ExtraData + ";" + gD[1] + ";" + gD[2] + ";" + gD[3];
                        }
                        catch
                        {
                            roomItem.ExtraData = string.Empty;
                        }
                    }

                    if (roomItem.RoomId == 0)
                        continue;

                    if (roomItem.GetBaseItem().Name.Contains("wallpaper_single") ||
                        roomItem.GetBaseItem().Name.Contains("floor_single") ||
                        roomItem.GetBaseItem().Name.Contains("landscape_single"))
                    {
                        dbClient.RunFastQuery($"DELETE FROM items_rooms WHERE id = {roomItem.Id} LIMIT 1");

                        continue;
                    }

                    if (roomItem.IsFloorItem)
                    {
                        dbClient.SetQuery(
                            $"UPDATE items_rooms SET room_id={roomItem.RoomId}, extra_data=@extraData, x={roomItem.X}, y={roomItem.Y}, z='{roomItem.Z.ToString(CultureInfo.InvariantCulture).Replace(',', '.')}', rot={roomItem.Rot} WHERE id={roomItem.Id}");
                        dbClient.AddParameter("extraData",
                            !string.IsNullOrEmpty(roomItem.ExtraData) ? roomItem.ExtraData : string.Empty);
                        dbClient.RunQuery();
                    }
                    else
                    {
                        dbClient.SetQuery(
                            $"UPDATE items_rooms SET room_id={roomItem.RoomId}, extra_data=@extraData, wall_pos=@wallPos WHERE id={roomItem.Id}");
                        dbClient.AddParameter("extraData",
                            !string.IsNullOrEmpty(roomItem.ExtraData) ? roomItem.ExtraData : string.Empty);
                        dbClient.AddParameter("wallPos", roomItem.WallCoord);
                        dbClient.RunQuery();
                    }
                }

                _room.GetRoomUserManager().AppendPetsUpdateString(dbClient);

                session?.GetHabbo().GetInventoryComponent().RunDbUpdate();

                _updatedItems.Clear();
                _removedItems.Clear();
            }
            catch (Exception ex)
            {
                ServerLogManager.LogCriticalException("Error during saving furniture for room " + _room.RoomId +
                                                      ". Stack: " + ex);
            }
        }