예제 #1
0
        private void ReloadOffers(GameClient session)
        {
            int    minCost     = -1;
            int    maxCost     = -1;
            string searchQuery = "";
            int    filterMode  = 1;


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

            builder.Append("WHERE `state` = '1' AND `timestamp` >= " + PlusEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestampString());
            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;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.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 + "%");
                if (searchQuery.Length >= 1)
                {
                    builder.Append(" AND `public_name` LIKE @search_query");
                }
                table = dbClient.GetTable();
            }

            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Clear();
            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Clear();
            if (table != null)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Contains(Convert.ToInt32(row["offer_id"])))
                    {
                        MarketOffer item = 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"]));
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Add(Convert.ToInt32(row["offer_id"]));
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Add(item);
                    }
                }
            }

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

            foreach (MarketOffer item in PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems)
            {
                if (dictionary.ContainsKey(item.SpriteId))
                {
                    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
                {
                    dictionary.Add(item.SpriteId, item);
                    dictionary2.Add(item.SpriteId, 1);
                }
            }

            session.SendPacket(new MarketPlaceOffersComposer(dictionary, dictionary2));
        }
예제 #2
0
        public void LoadFurniture()
        {
            if (this._floorItems.Count > 0)
            {
                this._floorItems.Clear();
            }
            if (this._wallItems.Count > 0)
            {
                this._wallItems.Clear();
            }

            List <Item> Items = ItemLoader.GetItemsForRoom(this._room.Id, this._room);

            foreach (Item Item in Items.ToList())
            {
                if (Item == null)
                {
                    continue;
                }

                if (Item.UserID == 0)
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `items` SET `user_id` = @UserId WHERE `id` = @ItemId LIMIT 1");
                        dbClient.AddParameter("ItemId", Item.Id);
                        dbClient.AddParameter("UserId", this._room.OwnerId);
                        dbClient.RunQuery();
                    }
                }

                if (Item.IsFloorItem)
                {
                    if (!_room.GetGameMap().ValidTile(Item.GetX, Item.GetY))
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = '" + Item.Id + "' LIMIT 1");
                        }

                        GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(Item.UserID);
                        if (Client != null)
                        {
                            Client.GetHabbo().GetInventoryComponent().AddNewItem(Item.Id, Item.BaseItem, Item.ExtraData, Item.GroupId, true, true, Item.LimitedNo, Item.LimitedTot);
                            Client.GetHabbo().GetInventoryComponent().UpdateItems(false);
                        }
                        continue;
                    }

                    if (!this._floorItems.ContainsKey(Item.Id))
                    {
                        this._floorItems.TryAdd(Item.Id, Item);
                    }
                }
                else if (Item.IsWallItem)
                {
                    if (string.IsNullOrWhiteSpace(Item.wallCoord))
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("UPDATE `items` SET `wall_pos` = @WallPosition WHERE `id` = '" + Item.Id + "' LIMIT 1");
                            dbClient.AddParameter("WallPosition", ":w=0,2 l=11,53 l");
                            dbClient.RunQuery();
                        }

                        Item.wallCoord = ":w=0,2 l=11,53 l";
                    }

                    try
                    {
                        Item.wallCoord = WallPositionCheck(":" + Item.wallCoord.Split(':')[1]);
                    }
                    catch
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("UPDATE `items` SET `wall_pos` = @WallPosition WHERE `id` = '" + Item.Id + "' LIMIT 1");
                            dbClient.AddParameter("WallPosition", ":w=0,2 l=11,53 l");
                            dbClient.RunQuery();
                        }

                        Item.wallCoord = ":w=0,2 l=11,53 l";
                    }

                    if (!this._wallItems.ContainsKey(Item.Id))
                    {
                        this._wallItems.TryAdd(Item.Id, Item);
                    }
                }
            }

            foreach (Item Item in _floorItems.Values.ToList())
            {
                if (Item.IsRoller)
                {
                    mGotRollers = true;
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)
                {
                    if (_room.MoodlightData == null)
                    {
                        _room.MoodlightData = new MoodlightData(Item.Id);
                    }
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.TONER)
                {
                    if (_room.TonerData == null)
                    {
                        _room.TonerData = new TonerData(Item.Id);
                    }
                }
                else if (Item.IsWired)
                {
                    if (_room == null)
                    {
                        continue;
                    }

                    if (_room.GetWired() == null)
                    {
                        continue;
                    }

                    _room.GetWired().LoadWiredBox(Item);
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.HOPPER)
                {
                    HopperCount++;
                }
            }
        }
예제 #3
0
        public void ProgressUserQuest(GameClient session, QuestType type, int data = 0)
        {
            if (session == null || session.Habbo == null || session.Habbo.GetStats().QuestId <= 0)
            {
                return;
            }

            Quest quest = GetQuest(session.Habbo.GetStats().QuestId);

            if (quest == null || quest.GoalType != type)
            {
                return;
            }

            int  currentProgress = session.Habbo.GetQuestProgress(quest.Id);
            int  totalProgress   = currentProgress;
            bool completeQuest   = false;

            switch (type)
            {
            default:

                totalProgress++;

                if (totalProgress >= quest.GoalData)
                {
                    completeQuest = true;
                }

                break;

            case QuestType.ExploreFindItem:

                if (data != quest.GoalData)
                {
                    return;
                }

                totalProgress = Convert.ToInt32(quest.GoalData);
                completeQuest = true;
                break;

            case QuestType.StandOn:

                if (data != quest.GoalData)
                {
                    return;
                }

                totalProgress = Convert.ToInt32(quest.GoalData);
                completeQuest = true;
                break;

            case QuestType.XmasParty:
                totalProgress++;
                if (totalProgress == quest.GoalData)
                {
                    completeQuest = true;
                }
                break;

            case QuestType.GiveItem:

                if (data != quest.GoalData)
                {
                    return;
                }

                totalProgress = Convert.ToInt32(quest.GoalData);
                completeQuest = true;
                break;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_quests` SET `progress` = '" + totalProgress + "' WHERE `user_id` = '" + session.Habbo.Id + "' AND `quest_id` = '" + quest.Id + "' LIMIT 1");

                if (completeQuest)
                {
                    dbClient.RunQuery("UPDATE `user_stats` SET `quest_id` = '0' WHERE `id` = '" + session.Habbo.Id + "' LIMIT 1");
                }
            }

            session.Habbo.quests[session.Habbo.GetStats().QuestId] = totalProgress;
            session.SendPacket(new QuestStartedComposer(session, quest));

            if (completeQuest)
            {
                session.Habbo.GetMessenger().BroadcastAchievement(session.Habbo.Id, Users.Messenger.MessengerEventTypes.QuestCompleted, quest.Category + "." + quest.Name);

                session.Habbo.GetStats().QuestId = 0;
                session.Habbo.QuestLastCompleted = quest.Id;
                session.SendPacket(new QuestCompletedComposer(session, quest));
                session.Habbo.Duckets += quest.Reward;
                session.SendPacket(new HabboActivityPointNotificationComposer(session.Habbo.Duckets, quest.Reward));
                GetList(session, null);
            }
        }
예제 #4
0
        public void Init(ItemDataManager ItemDataManager)
        {
            if (_pages.Count > 0)
            {
                _pages.Clear();
            }
            if (_botPresets.Count > 0)
            {
                _botPresets.Clear();
            }
            if (_items.Count > 0)
            {
                _items.Clear();
            }
            if (_deals.Count > 0)
            {
                _deals.Clear();
            }
            if (_promotions.Count > 0)
            {
                _promotions.Clear();
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`amount`,`page_id`,`limited_sells`,`limited_stack`,`offer_active`,`extradata`,`badge`,`offer_id` FROM `catalog_items`");
                DataTable CatalogueItems = dbClient.GetTable();

                if (CatalogueItems != null)
                {
                    foreach (DataRow Row in CatalogueItems.Rows)
                    {
                        if (Convert.ToInt32(Row["amount"]) <= 0)
                        {
                            continue;
                        }

                        int ItemId  = Convert.ToInt32(Row["id"]);
                        int PageId  = Convert.ToInt32(Row["page_id"]);
                        int BaseId  = Convert.ToInt32(Row["item_id"]);
                        int OfferId = Convert.ToInt32(Row["offer_id"]);

                        if (!ItemDataManager.GetItem(BaseId, out ItemData Data))
                        {
                            log.Error("Couldn't load Catalog Item " + ItemId + ", no furniture record found.");
                            continue;
                        }

                        if (!_items.ContainsKey(PageId))
                        {
                            _items[PageId] = new Dictionary <int, CatalogItem>();
                        }

                        if (OfferId != -1 && !_itemOffers.ContainsKey(OfferId))
                        {
                            _itemOffers.Add(OfferId, PageId);
                        }

                        List <int> limitedNumbers = GetLimitedNumbers(
                            Convert.ToInt32(Row["id"]),
                            Convert.ToInt32(Row["limited_stack"]));
                        limitedNumbers.Shuffle();

                        _items[PageId].Add(Convert.ToInt32(Row["id"]), new CatalogItem(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["item_id"]),
                                                                                       Data, Convert.ToString(Row["catalog_name"]), Convert.ToInt32(Row["page_id"]), Convert.ToInt32(Row["cost_credits"]), Convert.ToInt32(Row["cost_pixels"]), Convert.ToInt32(Row["cost_diamonds"]),
                                                                                       Convert.ToInt32(Row["amount"]), limitedNumbers, Convert.ToInt32(Row["limited_stack"]), PlusEnvironment.EnumToBool(Row["offer_active"].ToString()),
                                                                                       Convert.ToString(Row["extradata"]), Convert.ToString(Row["badge"]), Convert.ToInt32(Row["offer_id"])));
                    }
                }

                dbClient.SetQuery("SELECT `id`, `items`, `name`, `room_id` FROM `catalog_deals`");
                DataTable GetDeals = dbClient.GetTable();

                if (GetDeals != null)
                {
                    foreach (DataRow Row in GetDeals.Rows)
                    {
                        int    Id     = Convert.ToInt32(Row["id"]);
                        string Items  = Convert.ToString(Row["items"]);
                        string Name   = Convert.ToString(Row["name"]);
                        int    RoomId = Convert.ToInt32(Row["room_id"]);

                        CatalogDeal Deal = new CatalogDeal(Id, Items, Name, RoomId, ItemDataManager);

                        if (!_deals.ContainsKey(Id))
                        {
                            _deals.Add(Deal.Id, Deal);
                        }
                    }
                }


                dbClient.SetQuery("SELECT `id`,`parent_id`,`caption`,`page_link`,`visible`,`enabled`,`min_rank`,`min_vip`,`icon_image`,`page_layout`,`page_strings_1`,`page_strings_2` FROM `catalog_pages` ORDER BY `order_num`");
                DataTable CatalogPages = dbClient.GetTable();

                if (CatalogPages != null)
                {
                    foreach (DataRow Row in CatalogPages.Rows)
                    {
                        _pages.Add(Convert.ToInt32(Row["id"]), new CatalogPage(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Row["enabled"].ToString(), Convert.ToString(Row["caption"]),
                                                                               Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["icon_image"]), Convert.ToInt32(Row["min_rank"]), Convert.ToInt32(Row["min_vip"]), Row["visible"].ToString(), Convert.ToString(Row["page_layout"]),
                                                                               Convert.ToString(Row["page_strings_1"]), Convert.ToString(Row["page_strings_2"]),
                                                                               _items.ContainsKey(Convert.ToInt32(Row["id"])) ? _items[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogItem>(), ref _itemOffers));
                    }
                }

                dbClient.SetQuery("SELECT `id`,`name`,`figure`,`motto`,`gender`,`ai_type` FROM `catalog_bot_presets`");
                DataTable bots = dbClient.GetTable();

                if (bots != null)
                {
                    foreach (DataRow row in bots.Rows)
                    {
                        _botPresets.Add(Convert.ToInt32(row[0]), new CatalogBot(Convert.ToInt32(row[0]), Convert.ToString(row[1]), Convert.ToString(row[2]), Convert.ToString(row[3]), Convert.ToString(row[4]), Convert.ToString(row[5])));
                    }
                }

                dbClient.SetQuery("SELECT * FROM `catalog_promotions`");
                DataTable GetPromotions = dbClient.GetTable();

                if (GetPromotions != null)
                {
                    foreach (DataRow row in GetPromotions.Rows)
                    {
                        if (!_promotions.ContainsKey(Convert.ToInt32(row["id"])))
                        {
                            _promotions.Add(Convert.ToInt32(row["id"]), new CatalogPromotion(Convert.ToInt32(row["id"]), Convert.ToString(row["title"]), Convert.ToString(row["image"]), Convert.ToInt32(row["unknown"]), Convert.ToString(row["page_link"]), Convert.ToInt32(row["parent_id"])));
                        }
                    }
                }

                _petRaceManager.Init();
                _clothingManager.Init();
            }

            log.Info("Catalog Manager -> LOADED");
        }
예제 #5
0
        public bool RequestBuddy(string UserQuery)
        {
            int  userID;
            bool hasFQDisabled;

            GameClient client = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `id`,`block_newfriends` FROM `users` WHERE `username` = @query LIMIT 1");
                    dbClient.AddParameter("query", UserQuery.ToLower());
                    Row = dbClient.GetRow();
                }

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

                userID        = Convert.ToInt32(Row["id"]);
                hasFQDisabled = PlusEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID        = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().AllowFriendRequests;
            }

            if (hasFQDisabled)
            {
                GetClient().SendPacket(new MessengerErrorComposer(39, 3));
                return(false);
            }

            int ToId = userID;

            if (RequestExists(ToId))
            {
                return(true);
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("REPLACE INTO `messenger_requests` (`from_id`,`to_id`) VALUES ('" + _userId + "','" + ToId + "')");
            }

            PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(GetClient(), QuestType.AddFriends);

            GameClient ToUser = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

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

            MessengerRequest Request = new MessengerRequest(ToId, _userId, PlusEnvironment.GetGame().GetClientManager().GetNameById(_userId));

            ToUser.GetHabbo().GetMessenger().OnNewRequest(_userId);

            UserCache ThisUser = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_userId);

            if (ThisUser != null)
            {
                ToUser.SendPacket(new NewBuddyRequestComposer(ThisUser));
            }

            _requests.Add(ToId, Request);
            return(true);
        }
예제 #6
0
        public bool ProgressAchievement(GameClient session, string group, int progress, bool fromBeginning = false)
        {
            if (!_achievements.ContainsKey(group) || session == null)
            {
                return(false);
            }

            Achievement data = null;

            data = _achievements[group];

            UserAchievement userData = session.GetHabbo().GetAchievementData(group);

            if (userData == null)
            {
                userData = new UserAchievement(group, 0, 0);
                session.GetHabbo().Achievements.TryAdd(group, userData);
            }

            int TotalLevels = data.Levels.Count;

            if (userData != null && userData.Level == TotalLevels)
            {
                return(false); // done, no more.
            }
            int TargetLevel = (userData != null ? userData.Level + 1 : 1);

            if (TargetLevel > TotalLevels)
            {
                TargetLevel = TotalLevels;
            }

            AchievementLevel TargetLevelData = data.Levels[TargetLevel];
            int NewProgress = 0;

            if (fromBeginning)
            {
                NewProgress = progress;
            }
            else
            {
                NewProgress = (userData != null ? userData.Progress + progress : progress);
            }

            int NewLevel  = (userData != null ? userData.Level : 0);
            int NewTarget = NewLevel + 1;

            if (NewTarget > TotalLevels)
            {
                NewTarget = TotalLevels;
            }

            if (NewProgress >= TargetLevelData.Requirement)
            {
                NewLevel++;
                NewTarget++;

                int ProgressRemainder = NewProgress - TargetLevelData.Requirement;

                NewProgress = 0;

                if (TargetLevel == 1)
                {
                    session.GetHabbo().GetBadgeComponent().GiveBadge(group + TargetLevel, true, session);
                }
                else
                {
                    session.GetHabbo().GetBadgeComponent().RemoveBadge(Convert.ToString(group + (TargetLevel - 1)));
                    session.GetHabbo().GetBadgeComponent().GiveBadge(group + TargetLevel, true, session);
                }

                if (NewTarget > TotalLevels)
                {
                    NewTarget = TotalLevels;
                }


                session.SendPacket(new AchievementUnlockedComposer(data, TargetLevel, TargetLevelData.RewardPoints, TargetLevelData.RewardPixels));
                session.GetHabbo().GetMessenger().BroadcastAchievement(session.GetHabbo().Id, Users.Messenger.MessengerEventTypes.AchievementUnlocked, group + TargetLevel);

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("REPLACE INTO `user_achievements` VALUES ('" + session.GetHabbo().Id + "', @group, '" + NewLevel + "', '" + NewProgress + "')");
                    dbClient.AddParameter("group", group);
                    dbClient.RunQuery();
                }

                userData.Level    = NewLevel;
                userData.Progress = NewProgress;

                session.GetHabbo().Duckets += TargetLevelData.RewardPixels;
                session.GetHabbo().GetStats().AchievementPoints += TargetLevelData.RewardPoints;
                session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Duckets, TargetLevelData.RewardPixels));
                session.SendPacket(new AchievementScoreComposer(session.GetHabbo().GetStats().AchievementPoints));

                AchievementLevel NewLevelData = data.Levels[NewTarget];
                session.SendPacket(new AchievementProgressedComposer(data, NewTarget, NewLevelData, TotalLevels, session.GetHabbo().GetAchievementData(group)));

                return(true);
            }
            else
            {
                userData.Level    = NewLevel;
                userData.Progress = NewProgress;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("REPLACE INTO `user_achievements` VALUES ('" + session.GetHabbo().Id + "', @group, '" + NewLevel + "', '" + NewProgress + "')");
                    dbClient.AddParameter("group", group);
                    dbClient.RunQuery();
                }

                session.SendPacket(new AchievementProgressedComposer(data, TargetLevel, TargetLevelData, TotalLevels, session.GetHabbo().GetAchievementData(group)));
            }
            return(false);
        }
예제 #7
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int userId = Packet.PopInt();

            if (userId == 0 || userId == Session.GetHabbo().Id)
            {
                return;
            }

            string message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString());

            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            if (Session.GetHabbo().TimeMuted > 0)
            {
                Session.SendNotification("Opa, você está mudo - você não pode enviar mensagens.");
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("advertisement_filter_override"))
            {
                string Phrase = "";
                if (PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckBannedWords(message, out Phrase))
                {
                    Session.GetHabbo().AdvertisingStrikes++;

                    if (Session.GetHabbo().AdvertisingStrikes < 2)
                    {
                        Session.SendMessage(new RoomNotificationComposer("Atenção!", "Por favor, pare de anunciar outros sites que não são afiliados ou oferecidos pelo HabboRPG. Você será silenciado se você fizer isso de novo!<br><br>Frase da Lista Negra: '" + Phrase + "'", "frank10", "ok", "event:"));
                        return;
                    }

                    if (Session.GetHabbo().AdvertisingStrikes >= 2)
                    {
                        Session.GetHabbo().TimeMuted = 3600;

                        using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE `users` SET `time_muted` = '3600' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1");
                        }

                        Session.SendMessage(new RoomNotificationComposer("Você ficou mudo!", "Desculpe, mas você foi automaticamente silenciado por divulgar o hotel '" + Phrase + "'.<br><br>A equipe de moderação foi notificada e ações serão tomadas dentro de sua conta!", "frank10", "ok", "event:"));

                        List <string> Messages = new List <string>();
                        Messages.Add(message);
                        PlusEnvironment.GetGame().GetModerationTool().SendNewTicket(Session, 9, Session.GetHabbo().Id, "[Servidor] O civil já recebeu uma advertência; " + Phrase + ".", Messages);
                        return;
                    }

                    return;
                }
            }

            int  TextCost;
            bool CanAfford;

            if (Session.GetRoleplay().PhoneType == 1)
            {
                TextCost = 3;
            }
            else if (Session.GetRoleplay().PhoneType == 2)
            {
                TextCost = 2;
            }
            else if (Session.GetRoleplay().PhoneType == 3)
            {
                TextCost = 1;
            }
            else
            {
                TextCost = 3;
            }

            if (Session.GetHabbo().Duckets < TextCost)
            {
                CanAfford = false;
            }
            else
            {
                CanAfford = true;
            }

            Session.GetHabbo().GetMessenger().SendInstantMessage(userId, message, CanAfford, TextCost);
        }
예제 #8
0
        public void Init()
        {
            Permissions.Clear();
            _commands.Clear();
            PermissionGroups.Clear();
            PermissionGroupRights.Clear();
            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `permissions`");
                var GetPermissions = dbClient.GetTable();
                if (GetPermissions != null)
                {
                    foreach (DataRow Row in GetPermissions.Rows)
                    {
                        Permissions.Add(Convert.ToInt32(Row["id"]),
                                        new Permission(Convert.ToInt32(Row["id"]), Convert.ToString(Row["permission"]),
                                                       Convert.ToString(Row["description"])));
                    }
                }
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `permissions_commands`");
                var GetCommands = dbClient.GetTable();
                if (GetCommands != null)
                {
                    foreach (DataRow Row in GetCommands.Rows)
                    {
                        _commands.Add(Convert.ToString(Row["command"]),
                                      new PermissionCommand(Convert.ToString(Row["command"]),
                                                            Convert.ToInt32(Row["group_id"]),
                                                            Convert.ToInt32(Row["subscription_id"])));
                    }
                }
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `permissions_groups`");
                var GetPermissionGroups = dbClient.GetTable();
                if (GetPermissionGroups != null)
                {
                    foreach (DataRow Row in GetPermissionGroups.Rows)
                    {
                        PermissionGroups.Add(Convert.ToInt32(Row["id"]),
                                             new PermissionGroup(Convert.ToString("name"), Convert.ToString("description"),
                                                                 Convert.ToString("badge")));
                    }
                }
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `permissions_rights`");
                var GetPermissionRights = dbClient.GetTable();
                if (GetPermissionRights != null)
                {
                    foreach (DataRow Row in GetPermissionRights.Rows)
                    {
                        var GroupId      = Convert.ToInt32(Row["group_id"]);
                        var PermissionId = Convert.ToInt32(Row["permission_id"]);
                        if (!PermissionGroups.ContainsKey(GroupId))
                        {
                            continue; // permission group does not exist
                        }

                        Permission Permission = null;
                        if (!Permissions.TryGetValue(PermissionId, out Permission))
                        {
                            continue; // permission does not exist
                        }

                        if (PermissionGroupRights.ContainsKey(GroupId))
                        {
                            PermissionGroupRights[GroupId].Add(Permission.PermissionName);
                        }
                        else
                        {
                            var RightsSet = new List <string> {
                                Permission.PermissionName
                            };
                            PermissionGroupRights.Add(GroupId, RightsSet);
                        }
                    }
                }
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `permissions_subscriptions`");
                var GetPermissionSubscriptions = dbClient.GetTable();
                if (GetPermissionSubscriptions != null)
                {
                    foreach (DataRow Row in GetPermissionSubscriptions.Rows)
                    {
                        var        PermissionId   = Convert.ToInt32(Row["permission_id"]);
                        var        SubscriptionId = Convert.ToInt32(Row["subscription_id"]);
                        Permission Permission     = null;
                        if (!Permissions.TryGetValue(PermissionId, out Permission))
                        {
                            continue; // permission does not exist
                        }

                        if (PermissionSubscriptionRights.ContainsKey(SubscriptionId))
                        {
                            PermissionSubscriptionRights[SubscriptionId].Add(Permission.PermissionName);
                        }
                        else
                        {
                            var RightsSet = new List <string> {
                                Permission.PermissionName
                            };
                            PermissionSubscriptionRights.Add(SubscriptionId, RightsSet);
                        }
                    }
                }
            }

            log.Info("Loaded " + Permissions.Count + " permissions.");
            log.Info("Loaded " + PermissionGroups.Count + " permissions groups.");
            log.Info("Loaded " + PermissionGroupRights.Count + " permissions group rights.");
            log.Info("Loaded " + PermissionSubscriptionRights.Count + " permissions subscription rights.");
        }
예제 #9
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session?.GetHabbo() == null || !session.GetHabbo().InRoom)
            {
                return;
            }

            var room = session.GetHabbo().CurrentRoom;

            if (room == null)
            {
                return;
            }

            var itemId = packet.PopInt();
            var item   = room.GetRoomItemHandler().GetItem(itemId);

            if (item?.Data == null || item.UserId != session.GetHabbo().Id || item.Data.InteractionType != InteractionType.GnomeBox)
            {
                return;
            }

            var petName = packet.PopString();

            if (string.IsNullOrEmpty(petName))
            {
                session.SendPacket(new CheckGnomeNameComposer(petName, 1));
                return;
            }

            if (!PlusEnvironment.IsValidAlphaNumeric(petName))
            {
                session.SendPacket(new CheckGnomeNameComposer(petName, 1));
                return;
            }

            //Quickly delete it from the database.
            using (var dbClient = PlusEnvironment.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);

            //Apparently we need this for success.
            session.SendPacket(new CheckGnomeNameComposer(petName, 0));

            //Create the pet here.
            var pet = PetUtility.CreatePet(session.GetHabbo().Id, petName, 26, "30", "ffffff");

            if (pet == null)
            {
                session.SendNotification("Oops, an error occoured. Please report this!");
                return;
            }

            pet.RoomId        = session.GetHabbo().CurrentRoomId;
            pet.GnomeClothing = RandomClothing();

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `bots_petdata` SET `gnome_clothing` = @GnomeClothing WHERE `id` = @PetId LIMIT 1");
                dbClient.AddParameter("GnomeClothing", pet.GnomeClothing);
                dbClient.AddParameter("PetId", pet.PetId);
                dbClient.RunQuery();
            }

            ItemData petFood;

            if (!PlusEnvironment.GetGame().GetItemManager().GetItem(320, out petFood))
            {
                return;
            }

            var food = ItemFactory.CreateSingleItemNullable(petFood, session.GetHabbo(), "");

            if (food == null)
            {
                return;
            }

            session.GetHabbo().GetInventoryComponent().TryAddItem(food);
            session.SendPacket(new FurniListNotificationComposer(food.Id, 1));
        }
예제 #10
0
        public static void Search(ServerPacket packet, SearchResultList result, string query, GameClient session, int limit)
        {
            if (session == null)
            {
                return;
            }

            switch (result.CategoryType)
            {
            default:
            case NavigatorCategoryType.MyHistory:
            case NavigatorCategoryType.Featured:
                packet.WriteInteger(0);
                break;

            case NavigatorCategoryType.Query:
            {
                #region Query
                if (query.ToLower().StartsWith("owner:"))
                {
                    if (query.Length > 0)
                    {
                        int       UserId   = 0;
                        DataTable GetRooms = null;
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            if (query.ToLower().StartsWith("owner:"))
                            {
                                dbClient.SetQuery("SELECT `id` FROM `users` WHERE `username` = @username LIMIT 1");
                                dbClient.AddParameter("username", query.Remove(0, 6));
                                UserId = dbClient.GetInteger();

                                dbClient.SetQuery("SELECT * FROM `rooms` WHERE `owner` = '" + UserId + "' and `state` != 'invisible' ORDER BY `users_now` DESC LIMIT 50");
                                GetRooms = dbClient.GetTable();
                            }
                        }

                        List <RoomData> Results = new List <RoomData>();
                        if (GetRooms != null)
                        {
                            foreach (DataRow Row in GetRooms.Rows)
                            {
                                RoomData Data = null;
                                if (!RoomFactory.TryGetData(Convert.ToInt32(Row["id"]), out Data))
                                {
                                    continue;
                                }

                                if (!Results.Contains(Data))
                                {
                                    Results.Add(Data);
                                }
                            }

                            GetRooms = null;
                        }

                        packet.WriteInteger(Results.Count);
                        foreach (RoomData Data in Results.ToList())
                        {
                            RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                        }

                        Results = null;
                    }
                }
                else if (query.ToLower().StartsWith("tag:"))
                {
                    query = query.Remove(0, 4);
                    ICollection <Room> TagMatches = PlusEnvironment.GetGame().GetRoomManager().SearchTaggedRooms(query);

                    packet.WriteInteger(TagMatches.Count);
                    foreach (RoomData Data in TagMatches.ToList())
                    {
                        RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                    }

                    TagMatches = null;
                }
                else if (query.ToLower().StartsWith("group:"))
                {
                    query = query.Remove(0, 6);
                    ICollection <Room> GroupRooms = PlusEnvironment.GetGame().GetRoomManager().SearchGroupRooms(query);

                    packet.WriteInteger(GroupRooms.Count);
                    foreach (RoomData Data in GroupRooms.ToList())
                    {
                        RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                    }

                    GroupRooms = null;
                }
                else
                {
                    if (query.Length > 0)
                    {
                        DataTable Table = null;
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT `id`,`caption`,`description`,`roomtype`,`owner`,`state`,`category`,`users_now`,`users_max`,`model_name`,`score`,`allow_pets`,`allow_pets_eat`,`room_blocking_disabled`,`allow_hidewall`,`password`,`wallpaper`,`floor`,`landscape`,`floorthick`,`wallthick`,`mute_settings`,`kick_settings`,`ban_settings`,`chat_mode`,`chat_speed`,`chat_size`,`trade_settings`,`group_id`,`tags`,`push_enabled`,`pull_enabled`,`enables_enabled`,`respect_notifications_enabled`,`pet_morphs_allowed`,`spush_enabled`,`spull_enabled`,`sale_price` FROM rooms WHERE `caption` LIKE @query ORDER BY `users_now` DESC LIMIT 50");
                            dbClient.AddParameter("query", query + "%");
                            Table = dbClient.GetTable();
                        }

                        List <RoomData> Results = new List <RoomData>();
                        if (Table != null)
                        {
                            foreach (DataRow Row in Table.Rows)
                            {
                                if (Convert.ToString(Row["state"]) == "invisible")
                                {
                                    continue;
                                }

                                RoomData Data = null;
                                if (!RoomFactory.TryGetData(Convert.ToInt32(Row["id"]), out Data))
                                {
                                    continue;
                                }

                                if (!Results.Contains(Data))
                                {
                                    Results.Add(Data);
                                }
                            }

                            Table = null;
                        }

                        packet.WriteInteger(Results.Count);
                        foreach (RoomData Data in Results.ToList())
                        {
                            RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                        }

                        Results = null;
                    }
                }
                #endregion

                break;
            }

            case NavigatorCategoryType.Popular:
            {
                List <Room> PopularRooms = PlusEnvironment.GetGame().GetRoomManager().GetPopularRooms(-1, limit);

                packet.WriteInteger(PopularRooms.Count);
                foreach (RoomData Data in PopularRooms.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                PopularRooms = null;
                break;
            }

            case NavigatorCategoryType.Recommended:
            {
                List <Room> RecommendedRooms = PlusEnvironment.GetGame().GetRoomManager().GetRecommendedRooms(limit);

                packet.WriteInteger(RecommendedRooms.Count);
                foreach (RoomData Data in RecommendedRooms.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                RecommendedRooms = null;
                break;
            }

            case NavigatorCategoryType.Category:
            {
                List <Room> GetRoomsByCategory = PlusEnvironment.GetGame().GetRoomManager().GetRoomsByCategory(result.Id, limit);

                packet.WriteInteger(GetRoomsByCategory.Count);
                foreach (RoomData Data in GetRoomsByCategory.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                GetRoomsByCategory = null;
                break;
            }

            case NavigatorCategoryType.MyRooms:
            {
                ICollection <RoomData> rooms = RoomFactory.GetRoomsDataByOwnerSortByName(session.GetHabbo().Id).OrderByDescending(x => x.UsersNow).ToList();

                packet.WriteInteger(rooms.Count);
                foreach (RoomData Data in rooms.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                break;
            }

            case NavigatorCategoryType.MyFavourites:
            {
                List <RoomData> Favourites = new List <RoomData>();


                foreach (int Id in session.GetHabbo().FavoriteRooms.ToArray())
                {
                    RoomData Data = null;
                    if (!RoomFactory.TryGetData(Id, out Data))
                    {
                        continue;
                    }

                    if (!Favourites.Contains(Data))
                    {
                        Favourites.Add(Data);
                    }
                }


                packet.WriteInteger(Favourites.Count);
                foreach (RoomData Data in Favourites.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                Favourites = null;
                break;
            }

            case NavigatorCategoryType.MyGroups:
            {
                List <RoomData> MyGroups = new List <RoomData>();

                foreach (Group Group in PlusEnvironment.GetGame().GetGroupManager().GetGroupsForUser(session.GetHabbo().Id).ToList())
                {
                    if (Group == null)
                    {
                        continue;
                    }

                    RoomData Data = null;
                    if (!RoomFactory.TryGetData(Group.RoomId, out Data))
                    {
                        continue;
                    }

                    if (!MyGroups.Contains(Data))
                    {
                        MyGroups.Add(Data);
                    }
                }

                MyGroups = MyGroups.Take(limit).ToList();

                packet.WriteInteger(MyGroups.Count);
                foreach (RoomData Data in MyGroups.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                MyGroups = null;

                break;
            }

            case NavigatorCategoryType.MyFriendsRooms:
            {
                List <int> RoomIds = new List <int>();

                if (session == null || session.GetHabbo() == null || session.GetHabbo().GetMessenger() == null || session.GetHabbo().GetMessenger().GetFriends() == null)
                {
                    return;
                }

                foreach (MessengerBuddy buddy in session.GetHabbo().GetMessenger().GetFriends().Where(p => p.InRoom))
                {
                    if (buddy == null || !buddy.InRoom || buddy.UserId == session.GetHabbo().Id)
                    {
                        continue;
                    }

                    if (!RoomIds.Contains(buddy.CurrentRoom.Id))
                    {
                        RoomIds.Add(buddy.CurrentRoom.Id);
                    }
                }

                List <Room> MyFriendsRooms = PlusEnvironment.GetGame().GetRoomManager().GetRoomsByIds(RoomIds.ToList());

                packet.WriteInteger(MyFriendsRooms.Count);
                foreach (RoomData Data in MyFriendsRooms.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                MyFriendsRooms = null;
                break;
            }

            case NavigatorCategoryType.MyRights:
            {
                List <RoomData> MyRights = new List <RoomData>();

                if (session != null)
                {
                    DataTable GetRights = null;
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("SELECT `room_id` FROM `room_rights` WHERE `user_id` = @UserId LIMIT @FetchLimit");
                        dbClient.AddParameter("UserId", session.GetHabbo().Id);
                        dbClient.AddParameter("FetchLimit", limit);
                        GetRights = dbClient.GetTable();

                        foreach (DataRow Row in GetRights.Rows)
                        {
                            RoomData Data = null;
                            if (!RoomFactory.TryGetData(Convert.ToInt32(Row["room_id"]), out Data))
                            {
                                continue;
                            }

                            if (!MyRights.Contains(Data))
                            {
                                MyRights.Add(Data);
                            }
                        }
                    }
                }

                packet.WriteInteger(MyRights.Count);
                foreach (RoomData Data in MyRights.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                MyRights = null;
                break;
            }

            case NavigatorCategoryType.TopPromotions:
            {
                List <Room> GetPopularPromotions = PlusEnvironment.GetGame().GetRoomManager().GetOnGoingRoomPromotions(16, limit);

                packet.WriteInteger(GetPopularPromotions.Count);
                foreach (RoomData Data in GetPopularPromotions.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                GetPopularPromotions = null;

                break;
            }

            case NavigatorCategoryType.PromotionCategory:
            {
                List <Room> GetPromotedRooms = PlusEnvironment.GetGame().GetRoomManager().GetPromotedRooms(result.OrderId, limit);

                packet.WriteInteger(GetPromotedRooms.Count);
                foreach (RoomData Data in GetPromotedRooms.ToList())
                {
                    RoomAppender.WriteRoom(packet, Data, Data.Promotion);
                }

                GetPromotedRooms = null;

                break;
            }
            }
        }
예제 #11
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            int roomId = packet.PopInt();

            if (!PlusEnvironment.GetGame().GetRoomManager().TryLoadRoom(roomId, out Room room))
            {
                return;
            }

            string     name        = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            string     description = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            RoomAccess access      = RoomAccessUtility.ToRoomAccess(packet.PopInt());
            string     password    = packet.PopString();
            int        maxUsers    = packet.PopInt();
            int        categoryId  = packet.PopInt();
            int        tagCount    = packet.PopInt();

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

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

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

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

            int tradeSettings       = packet.PopInt();//2 = All can trade, 1 = owner only, 0 = no trading.
            int allowPets           = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int allowPetsEat        = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int roomBlockingEnabled = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int hidewall            = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int wallThickness       = packet.PopInt();
            int floorThickness      = packet.PopInt();
            int whoMute             = packet.PopInt(); // mute
            int whoKick             = packet.PopInt(); // kick
            int whoBan = packet.PopInt();              // ban

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (access == RoomAccess.Password && password.Length == 0)
            {
                access = RoomAccess.Open;
            }

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

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

            if (!PlusEnvironment.GetGame().GetNavigator().TryGetSearchResultList(categoryId, out SearchResultList searchResultList))
            {
                categoryId = 36;
            }

            if (searchResultList.CategoryType != NavigatorCategoryType.Category || searchResultList.RequiredRank > session.GetHabbo().Rank || (session.GetHabbo().Id != room.OwnerId && session.GetHabbo().Rank >= searchResultList.RequiredRank))
            {
                categoryId = 36;
            }

            if (tagCount > 2)
            {
                return;
            }

            room.AllowPets           = allowPets;
            room.AllowPetsEating     = allowPetsEat;
            room.RoomBlockingEnabled = roomBlockingEnabled;
            room.Hidewall            = hidewall;

            room.Name        = name;
            room.Access      = access;
            room.Description = description;
            room.Category    = categoryId;
            room.Password    = password;

            room.WhoCanBan  = whoBan;
            room.WhoCanKick = whoKick;
            room.WhoCanMute = whoMute;

            room.ClearTags();
            room.AddTagRange(tags);
            room.UsersMax = maxUsers;

            room.WallThickness  = wallThickness;
            room.FloorThickness = floorThickness;

            room.ChatMode     = chatMode;
            room.ChatSize     = chatSize;
            room.ChatSpeed    = chatSpeed;
            room.ChatDistance = chatDistance;
            room.ExtraFlood   = extraFlood;

            room.TradeSettings = tradeSettings;

            string accessStr;

            switch (access)
            {
            default:
                accessStr = "open";
                break;

            case RoomAccess.Password:
                accessStr = "password";
                break;

            case RoomAccess.Doorbell:
                accessStr = "locked";
                break;

            case RoomAccess.Invisible:
                accessStr = "invisible";
                break;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `rooms` SET `caption` = @caption, `description` = @description, `password` = @password, `category` = @categoryId, `state` = @state, `tags` = @tags, `users_max` = @maxUsers, `allow_pets` = @allowPets, `allow_pets_eat` = @allowPetsEat, `room_blocking_disabled` = @roomBlockingDisabled, `allow_hidewall` = @allowHidewall, `floorthick` = @floorThick, `wallthick` = @wallThick, `mute_settings` = @muteSettings, `kick_settings` = @kickSettings, `ban_settings` = @banSettings, `chat_mode` = @chatMode, `chat_size` = @chatSize, `chat_speed` = @chatSpeed, `chat_extra_flood` = @extraFlood, `chat_hearing_distance` = @chatDistance, `trade_settings` = @tradeSettings WHERE `id` = @roomId LIMIT 1");
                dbClient.AddParameter("categoryId", categoryId);
                dbClient.AddParameter("maxUsers", maxUsers);
                dbClient.AddParameter("allowPets", allowPets);
                dbClient.AddParameter("allowPetsEat", allowPetsEat);
                dbClient.AddParameter("roomBlockingDisabled", roomBlockingEnabled);
                dbClient.AddParameter("allowHidewall", room.Hidewall);
                dbClient.AddParameter("floorThick", room.FloorThickness);
                dbClient.AddParameter("wallThick", room.WallThickness);
                dbClient.AddParameter("muteSettings", room.WhoCanMute);
                dbClient.AddParameter("kickSettings", room.WhoCanKick);
                dbClient.AddParameter("banSettings", room.WhoCanBan);
                dbClient.AddParameter("chatMode", room.ChatMode);
                dbClient.AddParameter("chatSize", room.ChatSize);
                dbClient.AddParameter("chatSpeed", room.ChatSpeed);
                dbClient.AddParameter("extraFlood", room.ExtraFlood);
                dbClient.AddParameter("chatDistance", room.ChatDistance);
                dbClient.AddParameter("tradeSettings", room.TradeSettings);
                dbClient.AddParameter("roomId", room.Id);
                dbClient.AddParameter("caption", room.Name);
                dbClient.AddParameter("description", room.Description);
                dbClient.AddParameter("password", room.Password);
                dbClient.AddParameter("state", accessStr);
                dbClient.AddParameter("tags", formattedTags.ToString());
                dbClient.RunQuery();
            }

            room.GetGameMap().GenerateMaps();

            if (session.GetHabbo().CurrentRoom == null)
            {
                session.SendPacket(new RoomSettingsSavedComposer(room.RoomId));
                session.SendPacket(new RoomInfoUpdatedComposer(room.RoomId));
                session.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));
            }
            else
            {
                room.SendPacket(new RoomSettingsSavedComposer(room.RoomId));
                room.SendPacket(new RoomInfoUpdatedComposer(room.RoomId));
                room.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));
            }

            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModDoorModeSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModWalkthroughSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatScrollSpeedSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatFloodFilterSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatHearRangeSeen", 1);
        }
예제 #12
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            string Gender       = Packet.PopString().ToUpper();
            string Look         = PlusEnvironment.GetGame().GetAntiMutant().RunLook(Packet.PopString());
            int    ClothingRoom = Convert.ToInt32(RoleplayData.GetData("clothing", "roomid"));

            if (Session.GetRoomUser() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            if (Session.GetRoomUser().RoomId != ClothingRoom)
            {
                Session.SendNotification("Você deve estar dentro da Loja de roupas para mudar suas roupas! [Quarto ID: " + ClothingRoom + "]");
                return;
            }

            if (Session.GetRoleplay().IsWorking)
            {
                Session.SendNotification("Você não pode mudar sua roupa enquanto está trabalhando!");
                return;
            }

            if (Look == Session.GetHabbo().Look)
            {
                Session.SendWhisper("Você já está vestido assim!", 1);
                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;
            }

            if (Session.GetRoleplay().PurchasingClothing)
            {
                Session.GetRoleplay().PurchasingClothing = false;
                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;
            }

            //PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.PROFILE_CHANGE_LOOK);

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

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

            Session.SendMessage(new AvatarAspectUpdateMessageComposer(Look, Gender));

            //PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_AvatarLooks", 1);
            //if (Session.GetHabbo().Look.Contains("ha-1006"))
            //PlusEnvironment.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));
                }
            }

            if (Session.GetHabbo().GetMessenger() != null)
            {
                Session.GetHabbo().GetMessenger().OnStatusChanged(true);
            }

            Session.GetRoleplay().OriginalOutfit = Session.GetHabbo().Look;
        }
예제 #13
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 = PlusEnvironment.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 = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                { dbClient.RunQuery("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 = PlusEnvironment.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", PlusEnvironment.BoolToEnum(Convert.ToBoolean(MixChat)));
                        dbClient.RunQuery();
                    }
                }
                #endregion

                #region Handle Speech
                RoomBot.RandomSpeech.Clear();
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `text` FROM `bots_speech` WHERE `bot_id` = @id");
                    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 = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("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("Come on, atleast give the bot a name!");
                    return;
                }
                else if (DataString.Length >= 16)
                {
                    Session.SendWhisper("Come on, the bot doesn't need a name that long!");
                    return;
                }

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

                Bot.BotData.Name = DataString;
                using (IQueryAdapter dbClient = PlusEnvironment.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
            }
        }
예제 #14
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            int offerId = packet.PopInt();

            DataRow row;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `state`,`timestamp`,`total_price`,`extra_data`,`item_id`,`furni_id`,`user_id`,`limited_number`,`limited_stack` FROM `catalog_marketplace_offers` WHERE `offer_id` = @OfferId LIMIT 1");
                dbClient.AddParameter("OfferId", offerId);
                row = dbClient.GetRow();
            }

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

            if (Convert.ToString(row["state"]) == "2")
            {
                session.SendNotification("Oops, this offer is no longer available.");
                ReloadOffers(session);
                return;
            }

            if (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestamp() > (Convert.ToDouble(row["timestamp"])))
            {
                session.SendNotification("Oops, this offer has expired..");
                ReloadOffers(session);
                return;
            }

            if (!PlusEnvironment.GetGame().GetItemManager().GetItem(Convert.ToInt32(row["item_id"]), out ItemData item))
            {
                session.SendNotification("Item isn't in the hotel anymore.");
                ReloadOffers(session);
                return;
            }
            else
            {
                if (Convert.ToInt32(row["user_id"]) == session.Habbo.Id)
                {
                    session.SendNotification("To prevent average boosting you cannot purchase your own marketplace offers.");
                    return;
                }

                if (Convert.ToInt32(row["total_price"]) > session.Habbo.Credits)
                {
                    session.SendNotification("Oops, you do not have enough credits for this.");
                    return;
                }

                session.Habbo.Credits -= Convert.ToInt32(row["total_price"]);
                session.SendPacket(new CreditBalanceComposer(session.Habbo.Credits));


                Item giveItem = ItemFactory.CreateSingleItem(item, session.Habbo, Convert.ToString(row["extra_data"]), Convert.ToString(row["extra_data"]), Convert.ToInt32(row["furni_id"]), Convert.ToInt32(row["limited_number"]), Convert.ToInt32(row["limited_stack"]));
                if (giveItem != null)
                {
                    session.Habbo.GetInventoryComponent().TryAddItem(giveItem);
                    session.SendPacket(new FurniListNotificationComposer(giveItem.Id, 1));

                    session.SendPacket(new Outgoing.Catalog.PurchaseOKComposer());
                    session.SendPacket(new FurniListAddComposer(giveItem));
                    session.SendPacket(new FurniListUpdateComposer());
                }


                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `catalog_marketplace_offers` SET `state` = '2' WHERE `offer_id` = '" + offerId + "' LIMIT 1");

                    int id;
                    dbClient.SetQuery("SELECT `id` FROM `catalog_marketplace_data` WHERE `sprite` = " + item.SpriteId + " LIMIT 1;");
                    id = dbClient.GetInteger();

                    if (id > 0)
                    {
                        dbClient.RunQuery("UPDATE `catalog_marketplace_data` SET `sold` = `sold` + 1, `avgprice` = (avgprice + " + Convert.ToInt32(row["total_price"]) + ") WHERE `id` = " + id + " LIMIT 1;");
                    }
                    else
                    {
                        dbClient.RunQuery("INSERT INTO `catalog_marketplace_data` (`sprite`, `sold`, `avgprice`) VALUES ('" + item.SpriteId + "', '1', '" + Convert.ToInt32(row["total_price"]) + "')");
                    }


                    if (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.ContainsKey(item.SpriteId) && PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.ContainsKey(item.SpriteId))
                    {
                        int num3 = PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts[item.SpriteId];
                        int num4 = (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages[item.SpriteId] += Convert.ToInt32(row["total_price"]));

                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.Remove(item.SpriteId);
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.Add(item.SpriteId, num4);
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.Remove(item.SpriteId);
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.Add(item.SpriteId, num3 + 1);
                    }
                    else
                    {
                        if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.ContainsKey(item.SpriteId))
                        {
                            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.Add(item.SpriteId, Convert.ToInt32(row["total_price"]));
                        }

                        if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.ContainsKey(item.SpriteId))
                        {
                            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.Add(item.SpriteId, 1);
                        }
                    }
                }
            }

            ReloadOffers(session);
        }
예제 #15
0
        public bool TryExecute(string[] parameters)
        {
            int userId = 0;

            if (!int.TryParse(parameters[0].ToString(), out userId))
            {
                return(false);
            }

            GameClient client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(userId);

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

            // Validate the currency type
            if (string.IsNullOrEmpty(Convert.ToString(parameters[1])))
            {
                return(false);
            }

            string currency = Convert.ToString(parameters[1]);

            int amount = 0;

            if (!int.TryParse(parameters[2].ToString(), out amount))
            {
                return(false);
            }

            switch (currency)
            {
            default:
                return(false);

            case "coins":
            case "credits":
            {
                client.GetHabbo().Credits += amount;

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

                client.SendPacket(new CreditBalanceComposer(client.GetHabbo().Credits));
                break;
            }

            case "pixels":
            case "duckets":
            {
                client.GetHabbo().Duckets += amount;

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `users` SET `activity_points` = @duckets WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("duckets", client.GetHabbo().Duckets);
                    dbClient.AddParameter("id", userId);
                    dbClient.RunQuery();
                }

                client.SendPacket(new HabboActivityPointNotificationComposer(client.GetHabbo().Duckets, amount));
                break;
            }

            case "diamonds":
            {
                client.GetHabbo().Diamonds += amount;

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `users` SET `vip_points` = @diamonds WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("diamonds", client.GetHabbo().Diamonds);
                    dbClient.AddParameter("id", userId);
                    dbClient.RunQuery();
                }

                client.SendPacket(new HabboActivityPointNotificationComposer(client.GetHabbo().Diamonds, 0, 5));
                break;
            }

            case "gotw":
            {
                client.GetHabbo().GOTWPoints += amount;

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `users` SET `gotw_points` = @gotw WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("gotw", client.GetHabbo().GOTWPoints);
                    dbClient.AddParameter("id", userId);
                    dbClient.RunQuery();
                }

                client.SendPacket(new HabboActivityPointNotificationComposer(client.GetHabbo().GOTWPoints, 0, 103));
                break;
            }
            }
            return(true);
        }
예제 #16
0
        public void OnTrigger(GameClients.GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
            {
                String[] Stuff = Item.ExtraData.Split(Convert.ToChar(5));
                Session.Habbo.Gender = Stuff[0].ToUpper();
                Dictionary <String, String> NewFig = new Dictionary <String, String>();
                NewFig.Clear();
                foreach (String Man in Stuff[1].Split('.'))
                {
                    foreach (String Fig in Session.Habbo.Look.Split('.'))
                    {
                        if (Fig.Split('-')[0] == Man.Split('-')[0])
                        {
                            if (NewFig.ContainsKey(Fig.Split('-')[0]) && !NewFig.ContainsValue(Man))
                            {
                                NewFig.Remove(Fig.Split('-')[0]);
                                NewFig.Add(Fig.Split('-')[0], Man);
                            }
                            else if (!NewFig.ContainsKey(Fig.Split('-')[0]) && !NewFig.ContainsValue(Man))
                            {
                                NewFig.Add(Fig.Split('-')[0], Man);
                            }
                        }
                        else
                        {
                            if (!NewFig.ContainsKey(Fig.Split('-')[0]))
                            {
                                NewFig.Add(Fig.Split('-')[0], Fig);
                            }
                        }
                    }
                }

                string Final = "";
                foreach (String Str in NewFig.Values)
                {
                    Final += Str + ".";
                }


                Session.Habbo.Look = Final.TrimEnd('.');

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

                Room Room = Session.Habbo.CurrentRoom;
                if (Room != null)
                {
                    RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.Habbo.Username);
                    if (User != null)
                    {
                        Session.SendPacket(new UserChangeComposer(User, true));
                        Session.Habbo.CurrentRoom.SendPacket(new UserChangeComposer(User, false));
                    }
                }
            }
        }
예제 #17
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            int roomId = packet.PopInt();

            if (roomId == 0)
            {
                return;
            }

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

            if (room.OwnerId != session.GetHabbo().Id&& !session.GetHabbo().GetPermissions().HasRight("room_delete_any"))
            {
                return;
            }

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

            foreach (Item item in room.GetRoomItemHandler().GetWallAndFloor.ToList())
            {
                if (item == null)
                {
                    continue;
                }

                if (item.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("DELETE FROM `room_items_moodlight` WHERE `item_id` = @itemId LIMIT 1");
                        dbClient.AddParameter("itemId", item.Id);
                        dbClient.RunQuery();
                    }
                }

                itemsToRemove.Add(item);
            }

            foreach (Item item in itemsToRemove)
            {
                GameClient targetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(item.UserID);
                if (targetClient != null && targetClient.GetHabbo() != null)//Again, do we have an active client?
                {
                    room.GetRoomItemHandler().RemoveFurniture(targetClient, item.Id);
                    targetClient.GetHabbo().GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, item.GroupId, true, true, item.LimitedNo, item.LimitedTot);
                    targetClient.GetHabbo().GetInventoryComponent().UpdateItems(false);
                }
                else//No, query time.
                {
                    room.GetRoomItemHandler().RemoveFurniture(null, item.Id);
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = @itemId LIMIT 1");
                        dbClient.AddParameter("itemId", item.Id);
                        dbClient.RunQuery();
                    }
                }
            }

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

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("DELETE FROM `user_roomvisits` WHERE `room_id` = '" + roomId + "'");
                dbClient.RunQuery("DELETE FROM `rooms` WHERE `id` = '" + roomId + "' LIMIT 1");
                dbClient.RunQuery("DELETE FROM `user_favorites` WHERE `room_id` = '" + roomId + "'");
                dbClient.RunQuery("DELETE FROM `items` WHERE `room_id` = '" + roomId + "'");
                dbClient.RunQuery("DELETE FROM `room_rights` WHERE `room_id` = '" + roomId + "'");
                dbClient.RunQuery("UPDATE `users` SET `home_room` = '0' WHERE `home_room` = '" + roomId + "'");
            }

            PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(room.Id);
        }
예제 #18
0
        public static void Search(ServerPacket Message, SearchResultList SearchResult, string SearchData, GameClient Session, int FetchLimit)
        {
            //Switching by categorys.
            switch (SearchResult.CategoryType)
            {
            default:
                Message.WriteInteger(0);
                break;

            case NavigatorCategoryType.QUERY:
            {
                #region Query
                if (SearchData.ToLower().StartsWith("owner:"))
                {
                    if (SearchData.Length > 0)
                    {
                        int       UserId   = 0;
                        DataTable GetRooms = null;
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            if (SearchData.ToLower().StartsWith("owner:"))
                            {
                                dbClient.SetQuery("SELECT `id` FROM `users` WHERE `username` = @username LIMIT 1");
                                dbClient.AddParameter("username", SearchData.Remove(0, 6));
                                UserId = dbClient.GetInteger();

                                dbClient.SetQuery("SELECT * FROM `rooms` WHERE `owner` = '" + UserId + "' and `state` != 'invisible' ORDER BY `users_now` DESC LIMIT 50");
                                GetRooms = dbClient.GetTable();
                            }
                        }

                        List <RoomData> Results = new List <RoomData>();
                        if (GetRooms != null)
                        {
                            foreach (DataRow Row in GetRooms.Rows)
                            {
                                RoomData RoomData = PlusEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToInt32(Row["id"]), Row);
                                if (RoomData != null && !Results.Contains(RoomData))
                                {
                                    Results.Add(RoomData);
                                }
                            }
                        }

                        Message.WriteInteger(Results.Count);
                        foreach (RoomData Data in Results.ToList())
                        {
                            RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                        }
                    }
                }
                else if (SearchData.ToLower().StartsWith("tag:"))
                {
                    SearchData = SearchData.Remove(0, 4);
                    ICollection <RoomData> TagMatches = PlusEnvironment.GetGame().GetRoomManager().SearchTaggedRooms(SearchData);

                    Message.WriteInteger(TagMatches.Count);
                    foreach (RoomData Data in TagMatches.ToList())
                    {
                        RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                    }
                }
                else if (SearchData.ToLower().StartsWith("group:"))
                {
                    SearchData = SearchData.Remove(0, 6);
                    ICollection <RoomData> GroupRooms = PlusEnvironment.GetGame().GetRoomManager().SearchGroupRooms(SearchData);

                    Message.WriteInteger(GroupRooms.Count);
                    foreach (RoomData Data in GroupRooms.ToList())
                    {
                        RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                    }
                }
                else
                {
                    if (SearchData.Length > 0)
                    {
                        DataTable Table = null;
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT `id`,`caption`,`description`,`roomtype`,`owner`,`state`,`category`,`users_now`,`users_max`,`model_name`,`score`,`allow_pets`,`allow_pets_eat`,`room_blocking_disabled`,`allow_hidewall`,`password`,`wallpaper`,`floor`,`landscape`,`floorthick`,`wallthick`,`mute_settings`,`kick_settings`,`ban_settings`,`chat_mode`,`chat_speed`,`chat_size`,`trade_settings`,`group_id`,`tags`,`push_enabled`,`pull_enabled`,`enables_enabled`,`respect_notifications_enabled`,`pet_morphs_allowed`,`spush_enabled`,`spull_enabled` FROM rooms WHERE `caption` LIKE @query ORDER BY `users_now` DESC LIMIT 50");
                            dbClient.AddParameter("query", "%" + SearchData + "%");
                            Table = dbClient.GetTable();
                        }

                        List <RoomData> Results = new List <RoomData>();
                        if (Table != null)
                        {
                            foreach (DataRow Row in Table.Rows)
                            {
                                if (Convert.ToString(Row["state"]) == "invisible")
                                {
                                    continue;
                                }

                                RoomData RData = PlusEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToInt32(Row["id"]), Row);
                                if (RData != null && !Results.Contains(RData))
                                {
                                    Results.Add(RData);
                                }
                            }
                        }

                        Message.WriteInteger(Results.Count);
                        foreach (RoomData Data in Results.ToList())
                        {
                            RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                        }
                    }
                }
                #endregion

                break;
            }

            case NavigatorCategoryType.FEATURED:
                #region Featured
                List <RoomData>            Rooms    = new List <RoomData>();
                ICollection <FeaturedRoom> Featured = PlusEnvironment.GetGame().GetNavigator().GetFeaturedRooms();
                foreach (FeaturedRoom FeaturedItem in Featured.ToList())
                {
                    if (FeaturedItem == null)
                    {
                        continue;
                    }

                    RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(FeaturedItem.RoomId);
                    if (Data == null)
                    {
                        continue;
                    }

                    if (!Rooms.Contains(Data))
                    {
                        Rooms.Add(Data);
                    }
                }

                Message.WriteInteger(Rooms.Count);
                foreach (RoomData Data in Rooms.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                #endregion
                break;

            case NavigatorCategoryType.POPULAR:
            {
                List <RoomData> PopularRooms = PlusEnvironment.GetGame().GetRoomManager().GetPopularRooms(-1, FetchLimit);

                Message.WriteInteger(PopularRooms.Count);
                foreach (RoomData Data in PopularRooms.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;
            }

            case NavigatorCategoryType.RECOMMENDED:
            {
                List <RoomData> RecommendedRooms = PlusEnvironment.GetGame().GetRoomManager().GetRecommendedRooms(FetchLimit);

                Message.WriteInteger(RecommendedRooms.Count);
                foreach (RoomData Data in RecommendedRooms.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;
            }

            case NavigatorCategoryType.CATEGORY:
            {
                List <RoomData> GetRoomsByCategory = PlusEnvironment.GetGame().GetRoomManager().GetRoomsByCategory(SearchResult.Id, FetchLimit);

                Message.WriteInteger(GetRoomsByCategory.Count);
                foreach (RoomData Data in GetRoomsByCategory.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;
            }

            case NavigatorCategoryType.MY_ROOMS:

                Message.WriteInteger(Session.GetHabbo().UsersRooms.Count);
                foreach (RoomData Data in Session.GetHabbo().UsersRooms.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;

            case NavigatorCategoryType.MY_FAVORITES:
                List <RoomData> Favourites = new List <RoomData>();
                foreach (int Id in Session.GetHabbo().FavoriteRooms.ToArray())
                {
                    RoomData Room = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id);
                    if (Room == null)
                    {
                        continue;
                    }

                    if (!Favourites.Contains(Room))
                    {
                        Favourites.Add(Room);
                    }
                }

                Favourites = Favourites.Take(FetchLimit).ToList();

                Message.WriteInteger(Favourites.Count);
                foreach (RoomData Data in Favourites.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;

            case NavigatorCategoryType.MY_GROUPS:
                List <RoomData> MyGroups = new List <RoomData>();

                foreach (Group Group in PlusEnvironment.GetGame().GetGroupManager().GetGroupsForUser(Session.GetHabbo().Id).ToList())
                {
                    if (Group == null)
                    {
                        continue;
                    }

                    RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId);
                    if (Data == null)
                    {
                        continue;
                    }

                    if (!MyGroups.Contains(Data))
                    {
                        MyGroups.Add(Data);
                    }
                }

                MyGroups = MyGroups.Take(FetchLimit).ToList();

                Message.WriteInteger(MyGroups.Count);
                foreach (RoomData Data in MyGroups.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;

            case NavigatorCategoryType.MY_FRIENDS_ROOMS:
                List <RoomData> MyFriendsRooms = new List <RoomData>();
                foreach (MessengerBuddy buddy in Session.GetHabbo().GetMessenger().GetFriends().Where(p => p.InRoom))
                {
                    if (buddy == null || !buddy.InRoom || buddy.UserId == Session.GetHabbo().Id)
                    {
                        continue;
                    }

                    if (!MyFriendsRooms.Contains(buddy.CurrentRoom.RoomData))
                    {
                        MyFriendsRooms.Add(buddy.CurrentRoom.RoomData);
                    }
                }

                Message.WriteInteger(MyFriendsRooms.Count);
                foreach (RoomData Data in MyFriendsRooms.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;

            case NavigatorCategoryType.MY_RIGHTS:
                List <RoomData> MyRights = new List <RoomData>();

                DataTable GetRights = null;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `room_id` FROM `room_rights` WHERE `user_id` = @UserId LIMIT @FetchLimit");
                    dbClient.AddParameter("UserId", Session.GetHabbo().Id);
                    dbClient.AddParameter("FetchLimit", FetchLimit);
                    GetRights = dbClient.GetTable();

                    foreach (DataRow Row in GetRights.Rows)
                    {
                        RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(Convert.ToInt32(Row["room_id"]));
                        if (Data == null)
                        {
                            continue;
                        }

                        if (!MyRights.Contains(Data))
                        {
                            MyRights.Add(Data);
                        }
                    }
                }

                Message.WriteInteger(MyRights.Count);
                foreach (RoomData Data in MyRights.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;

            case NavigatorCategoryType.TOP_PROMOTIONS:
            {
                List <RoomData> GetPopularPromotions = PlusEnvironment.GetGame().GetRoomManager().GetOnGoingRoomPromotions(16, FetchLimit);

                Message.WriteInteger(GetPopularPromotions.Count);
                foreach (RoomData Data in GetPopularPromotions.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;
            }

            case NavigatorCategoryType.PROMOTION_CATEGORY:
            {
                List <RoomData> GetPromotedRooms = PlusEnvironment.GetGame().GetRoomManager().GetPromotedRooms(SearchResult.Id, FetchLimit);

                Message.WriteInteger(GetPromotedRooms.Count);
                foreach (RoomData Data in GetPromotedRooms.ToList())
                {
                    RoomAppender.WriteRoom(Message, Data, Data.Promotion);
                }
                break;
            }
            }
        }
예제 #19
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            int  GroupId  = Packet.PopInt();
            int  ThreadId = Packet.PopInt();
            bool Pin      = Packet.PopBoolean();
            bool Lock     = Packet.PopBoolean();

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery(string.Format("SELECT * FROM groups_forums_posts WHERE group_id = '{0}' AND id = '{1}' LIMIT 1;", GroupId, ThreadId));
                DataRow Row = dbClient.getRow();

                Group Group = GroupManager.GetJob(GroupId);

                if (Row != null)
                {
                    if ((uint)Row["poster_id"] == Session.GetHabbo().Id || Group.IsAdmin(Session.GetHabbo().Id))
                    {
                        dbClient.SetQuery(string.Format("UPDATE groups_forums_posts SET pinned = @pin , locked = @lock WHERE id = {0};", ThreadId));
                        dbClient.AddParameter("pin", (Pin) ? "1" : "0");
                        dbClient.AddParameter("lock", (Lock) ? "1" : "0");
                        dbClient.RunQuery();
                    }
                }

                var Thread = new GroupForumPost(Row);

                if (Thread.Pinned != Pin)
                {
                    Session.SendMessage(new RoomNotificationComposer((Pin) ? "forums.thread.pinned" : "forums.thread.unpinned"));
                }

                if (Thread.Locked != Lock)
                {
                    Session.SendMessage(new RoomNotificationComposer((Lock) ? "forums.thread.locked" : "forums.thread.unlocked"));
                }

                if (Thread.ParentId != 0)
                {
                    return;
                }

                Session.SendMessage(new GroupForumThreadUpdateMessageComposer(Group, Thread, Pin, Lock));

                dbClient.SetQuery("SELECT * FROM groups_forums_posts WHERE group_id = @gid AND parent_id = 0 ORDER BY timestamp DESC");
                dbClient.AddParameter("gid", GroupId);

                DataTable Table = dbClient.getTable();

                if (Table == null)
                {
                    Session.SendMessage(new GroupForumThreadRootMessageComposer(Group, 1, 0, 0, null, Session));
                    return;
                }

                int b       = (Table.Rows.Count <= 20) ? Table.Rows.Count : 20;
                var Threads = new List <GroupForumPost>();

                int i = 1;

                while (i <= b)
                {
                    DataRow Row2 = Table.Rows[i - 1];

                    if (Row2 == null)
                    {
                        b--;
                        continue;
                    }

                    var thread = new GroupForumPost(Row2);

                    Threads.Add(thread);

                    i++;
                }

                Threads = Threads.OrderByDescending(x => x.Pinned).ToList();

                Session.SendMessage(new GroupForumThreadRootMessageComposer(Group, 2, 0, b, Threads, Session));
            }
        }
예제 #20
0
        public void Execute(GameClient Session, 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 = PlusEnvironment.GetHabboByUsername(Params[1]);

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

            if (Habbo.GetPermissions().HasRight("mod_soft_ban") && !Session.Habbo.GetPermissions().HasRight("mod_ban_any"))
            {
                Session.SendWhisper("Oops, you cannot ban that user.");
                return;
            }

            double Expire = 0;
            string Hours  = Params[2];

            if (String.IsNullOrEmpty(Hours) || Hours == "perm")
            {
                Expire = PlusEnvironment.GetUnixTimestamp() + 78892200;
            }
            else
            {
                Expire = (PlusEnvironment.GetUnixTimestamp() + (Convert.ToDouble(Hours) * 3600));
            }

            string Reason = null;

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

            string Username = Habbo.Username;

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

            PlusEnvironment.GetGame().GetModerationManager().BanUser(Session.Habbo.Username, ModerationBanType.Username, Habbo.Username, Reason, Expire);

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

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

            Session.SendWhisper("Success, you have account banned the user '" + Username + "' for " + Hours + " hour(s) with the reason '" + Reason + "'!");
        }
예제 #21
0
        /// <summary>
        /// Called for each time the timer ticks.
        /// </summary>
        /// <param name="State"></param>
        public void Run(object State)
        {
            try
            {
                if (_disabled)
                {
                    return;
                }

                if (_timerRunning)
                {
                    _timerLagging = true;
                    log.Warn("<Player " + _player.Id + "> Server can't keep up, Player timer is lagging behind.");
                    return;
                }

                _resetEvent.Reset();

                // BEGIN CODE

                #region Muted Checks
                if (_player.TimeMuted > 0)
                {
                    _player.TimeMuted -= 60;
                }
                #endregion

                #region Console Checks
                if (_player.MessengerSpamTime > 0)
                {
                    _player.MessengerSpamTime -= 60;
                }
                if (_player.MessengerSpamTime <= 0)
                {
                    _player.MessengerSpamCount = 0;
                }
                #endregion

                _player.TimeAFK += 1;

                #region Respect checking
                if (_player.GetStats().RespectsTimestamp != DateTime.Today.ToString("MM/dd"))
                {
                    _player.GetStats().RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + (_player.Rank == 1 && _player.VIPRank == 0 ? 10 : _player.VIPRank == 1 ? 15 : 20) + "', `dailyPetRespectPoints` = '" + (_player.Rank == 1 && _player.VIPRank == 0 ? 10 : _player.VIPRank == 1 ? 15 : 20) + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "' WHERE `id` = '" + _player.Id + "' LIMIT 1");
                    }

                    _player.GetStats().DailyRespectPoints    = (_player.Rank == 1 && _player.VIPRank == 0 ? 10 : _player.VIPRank == 1 ? 15 : 20);
                    _player.GetStats().DailyPetRespectPoints = (_player.Rank == 1 && _player.VIPRank == 0 ? 10 : _player.VIPRank == 1 ? 15 : 20);

                    if (_player.GetClient() != null)
                    {
                        _player.GetClient().SendPacket(new UserObjectComposer(_player));
                    }
                }
                #endregion

                #region Reset Scripting Warnings
                if (_player.GiftPurchasingWarnings < 15)
                {
                    _player.GiftPurchasingWarnings = 0;
                }

                if (_player.MottoUpdateWarnings < 15)
                {
                    _player.MottoUpdateWarnings = 0;
                }

                if (_player.ClothingUpdateWarnings < 15)
                {
                    _player.ClothingUpdateWarnings = 0;
                }
                #endregion


                if (_player.GetClient() != null)
                {
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_player.GetClient(), "ACH_AllTimeHotelPresence", 1);
                }

                _player.CheckCreditsTimer();
                _player.Effects().CheckEffectExpiry(_player);

                // END CODE

                // Reset the values
                _timerRunning = false;
                _timerLagging = false;

                _resetEvent.Set();
            }
            catch { }
        }
예제 #22
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            int UserId = Packet.PopInt();
            int RoomId = Packet.PopInt();
            int Time   = Packet.PopInt();

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            if (((Room.WhoCanMute == 0 && !Room.CheckRights(Session, true) && Room.Group == null) || (Room.WhoCanMute == 1 && !Room.CheckRights(Session)) && Room.Group == null && !Session.GetHabbo().GetPermissions().HasRight("ambassador")) || (Room.Group != null && !Room.CheckRights(Session, false, true) && !Session.GetHabbo().GetPermissions().HasRight("ambassador")))
            {
                return;
            }

            RoomUser Target = Room.GetRoomUserManager().GetRoomUserByHabbo(UserId);

            if (Target == null)
            {
                return;
            }
            else if (Target.GetClient().GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                return;
            }

            if (Session.GetHabbo().GetPermissions().HasRight("ambassador"))
            {
                if (Target.GetClient().GetHabbo().TimeMuted > 0)
                {
                    Session.SendWhisper("Desculpe, mas este usuário está em silêncio por " + String.Format("{0:N0}", Math.Floor((Target.GetClient().GetHabbo().TimeMuted / 60))) + " minuto(s) - então você não pode mutá-lo novamente.", 1);
                    return;
                }

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `users` SET `time_muted` = '" + (Time * 60) + "' WHERE `id` = '" + Target.GetClient().GetHabbo().Id + "' LIMIT 1");
                }

                Target.GetClient().GetHabbo().TimeMuted = (Time * 60);

                Target.GetClient().SendNotification("Você foi silenciado por " + String.Format("{0:N0}", Time) + " minutos por um embaixador porque seu comportamento foi apropriado.");
                Session.SendWhisper("Você silenciou com sucesso " + Target.GetClient().GetHabbo().Username + " por " + String.Format("{0:N0}", Time) + " minuto(s).", 1);

                PlusEnvironment.GetGame().GetChatManager().GetCommands().LogCommand(Session.GetHabbo().Id, "mute " + Target.GetClient().GetHabbo().Username + " " + Time, Session.GetHabbo().MachineId, "ambassador");
                return;
            }
            else
            {
                if (Room.MutedUsers.ContainsKey(UserId))
                {
                    if (Room.MutedUsers[UserId] < PlusEnvironment.GetUnixTimestamp())
                    {
                        Room.MutedUsers.Remove(UserId);
                    }
                    else
                    {
                        return;
                    }
                }

                Room.MutedUsers.Add(UserId, (PlusEnvironment.GetUnixTimestamp() + (Time * 60)));

                Target.GetClient().SendWhisper("O proprietário do quarto silenciou você por " + Time + " minutos!", 1);
                //PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModMuteSeen", 1);
            }
        }
예제 #23
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.Habbo == null || !session.Habbo.GetPermissions().HasRight("mod_soft_ban"))
            {
                return;
            }

            int    userId  = packet.PopInt();
            string message = packet.PopString();
            double length  = packet.PopInt() * 3600 + PlusEnvironment.GetUnixTimestamp();

            packet.PopString(); //unk1
            packet.PopString(); //unk2
            bool ipBan      = packet.PopBoolean();
            bool machineBan = packet.PopBoolean();

            if (machineBan)
            {
                ipBan = false;
            }

            Habbo habbo = PlusEnvironment.GetHabboById(userId);

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

            if (habbo.GetPermissions().HasRight("mod_tool") && !session.Habbo.GetPermissions().HasRight("mod_ban_any"))
            {
                session.SendWhisper("Oops, you cannot ban that user.");
                return;
            }

            message = message != null ? message : "No reason specified.";

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

            if (ipBan == false && machineBan == false)
            {
                PlusEnvironment.GetGame().GetModerationManager().BanUser(session.Habbo.Username, ModerationBanType.Username, habbo.Username, message, length);
            }
            else if (ipBan)
            {
                PlusEnvironment.GetGame().GetModerationManager().BanUser(session.Habbo.Username, ModerationBanType.IP, habbo.Username, message, length);
            }
            else
            {
                PlusEnvironment.GetGame().GetModerationManager().BanUser(session.Habbo.Username, ModerationBanType.IP, habbo.Username, message, length);
                PlusEnvironment.GetGame().GetModerationManager().BanUser(session.Habbo.Username, ModerationBanType.Username, habbo.Username, message, length);
                PlusEnvironment.GetGame().GetModerationManager().BanUser(session.Habbo.Username, ModerationBanType.Machine, habbo.Username, message, length);
            }

            GameClient targetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(habbo.Username);

            if (targetClient != null)
            {
                targetClient.Disconnect();
            }
        }
예제 #24
0
        public void Parse(HabboHotel.GameClients.GameClient session, ClientPacket packet)
        {
            if (!session.GetHabbo().InRoom)
            {
                return;
            }

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

            int  itemId = packet.PopInt();
            Item item   = room.GetRoomItemHandler().GetItem(itemId);

            if (item == null)
            {
                return;
            }

            int petId = packet.PopInt();

            if (!room.GetRoomUserManager().TryGetPet(petId, out RoomUser petUser))
            {
                return;
            }

            if (petUser.PetData == null || petUser.PetData.OwnerId != session.GetHabbo().Id)
            {
                return;
            }

            if (item.Data.InteractionType == InteractionType.HORSE_SADDLE_1)
            {
                petUser.PetData.Saddle = 9;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `bots_petdata` SET `have_saddle` = '9' WHERE `id` = '" + petUser.PetData.PetId + "' LIMIT 1");
                    dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + item.Id + "' LIMIT 1");
                }

                //We only want to use this if we're successful.
                room.GetRoomItemHandler().RemoveFurniture(session, item.Id);
            }
            else if (item.Data.InteractionType == InteractionType.HORSE_SADDLE_2)
            {
                petUser.PetData.Saddle = 10;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `bots_petdata` SET `have_saddle` = '10' WHERE `id` = '" + petUser.PetData.PetId + "' LIMIT 1");
                    dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + item.Id + "' LIMIT 1");
                }

                //We only want to use this if we're successful.
                room.GetRoomItemHandler().RemoveFurniture(session, item.Id);
            }
            else if (item.Data.InteractionType == InteractionType.HORSE_HAIRSTYLE)
            {
                int    parse    = 100;
                string hairType = item.GetBaseItem().ItemName.Split('_')[2];

                parse = parse + int.Parse(hairType);

                petUser.PetData.PetHair = parse;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `bots_petdata` SET `pethair` = '" + petUser.PetData.PetHair + "' WHERE `id` = '" + petUser.PetData.PetId + "' LIMIT 1");
                    dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + item.Id + "' LIMIT 1");
                }

                //We only want to use this if we're successful.
                room.GetRoomItemHandler().RemoveFurniture(session, item.Id);
            }
            else if (item.Data.InteractionType == InteractionType.HORSE_HAIR_DYE)
            {
                int    hairDye  = 48;
                string hairType = item.GetBaseItem().ItemName.Split('_')[2];

                hairDye = hairDye + int.Parse(hairType);
                petUser.PetData.HairDye = hairDye;

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `bots_petdata` SET `hairdye` = '" + petUser.PetData.HairDye + "' WHERE `id` = '" + petUser.PetData.PetId + "' LIMIT 1");
                    dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + item.Id + "' LIMIT 1");
                }

                //We only want to use this if we're successful.
                room.GetRoomItemHandler().RemoveFurniture(session, item.Id);
            }
            else if (item.Data.InteractionType == InteractionType.HORSE_BODY_DYE)
            {
                string race     = item.GetBaseItem().ItemName.Split('_')[2];
                int    parse    = int.Parse(race);
                int    raceLast = 2 + (parse * 4) - 4;
                if (parse == 13)
                {
                    raceLast = 61;
                }
                else if (parse == 14)
                {
                    raceLast = 65;
                }
                else if (parse == 15)
                {
                    raceLast = 69;
                }
                else if (parse == 16)
                {
                    raceLast = 73;
                }
                petUser.PetData.Race = raceLast.ToString();

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `bots_petdata` SET `race` = '" + petUser.PetData.Race + "' WHERE `id` = '" + petUser.PetData.PetId + "' LIMIT 1");
                    dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + item.Id + "' LIMIT 1");
                }

                //We only want to use this if we're successful.
                room.GetRoomItemHandler().RemoveFurniture(session, item.Id);
            }

            //Update the Pet and the Pet figure information.
            room.SendPacket(new UsersComposer(petUser));
            room.SendPacket(new PetHorseFigureInformationComposer(petUser));
        }
예제 #25
0
        public void SendInstantMessage(int ToId, string Message)
        {
            if (ToId == 0)
            {
                return;
            }

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

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

            if (!FriendshipExists(ToId))
            {
                GetClient().SendPacket(new InstantMessageErrorComposer(MessengerMessageErrors.NotFriends, ToId));
                return;
            }

            if (GetClient().GetHabbo().MessengerSpamCount >= 12)
            {
                GetClient().GetHabbo().MessengerSpamTime  = PlusEnvironment.GetUnixTimestamp() + 60;
                GetClient().GetHabbo().MessengerSpamCount = 0;
                GetClient().SendNotification("You cannot send a message, you have flooded the console.\n\nYou can send a message in 60 seconds.");
                return;
            }
            else if (GetClient().GetHabbo().MessengerSpamTime > PlusEnvironment.GetUnixTimestamp())
            {
                double Time = GetClient().GetHabbo().MessengerSpamTime - PlusEnvironment.GetUnixTimestamp();
                GetClient().SendNotification("You cannot send a message, you have flooded the console.\n\nYou can send a message in " + Time + " seconds.");
                return;
            }


            GetClient().GetHabbo().MessengerSpamCount++;

            GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

            if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().GetMessenger() == null)
            {
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    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", GetClient().GetHabbo().Id);
                    dbClient.AddParameter("msg", Message);
                    dbClient.RunQuery();
                }
                return;
            }

            if (!Client.GetHabbo().AllowConsoleMessages || Client.GetHabbo().GetIgnores().IgnoredUserIds().Contains(GetClient().GetHabbo().Id))
            {
                GetClient().SendPacket(new InstantMessageErrorComposer(MessengerMessageErrors.FriendBusy, ToId));
                return;
            }

            if (GetClient().GetHabbo().TimeMuted > 0)
            {
                GetClient().SendPacket(new InstantMessageErrorComposer(MessengerMessageErrors.yourMuted, ToId));
                return;
            }

            if (Client.GetHabbo().TimeMuted > 0)
            {
                GetClient().SendPacket(new InstantMessageErrorComposer(MessengerMessageErrors.FriendMuted, ToId));
            }

            if (String.IsNullOrEmpty(Message))
            {
                return;
            }

            Client.SendPacket(new NewConsoleMessageComposer(_userId, Message));
            LogPM(_userId, ToId, Message);
        }
예제 #26
0
        public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false, bool ToDB = true, Item SpaceItem = null, double newZ = 1000.0, bool PlacedByRoleplay = false)
        {
            double origZ       = newZ;
            bool   CheckHeight = newZ == 1000.0 ? true : false;
            bool   NeedsReAdd  = false;

            if (newItem && Item.ExtraData == "")
            {
                Item.ExtraData = "0";
            }

            if (newItem)
            {
                if (Item.IsWired)
                {
                    if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Where(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps).Count() > 0)
                    {
                        return(false);
                    }
                }
            }

            List <Item> ItemsOnTile = GetFurniObjects(newX, newY);

            if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Where(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id).Count() > 0)
            {
                return(false);
            }

            if (!newItem)
            {
                NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item);
            }

            Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);

            if (!PlacedByRoleplay)
            {
                if (!_room.GetGameMap().ValidTile(newX, newY) || (_room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().Walkable&& !Item.GetBaseItem().IsSeat))
                {
                    if (NeedsReAdd)
                    {
                        _room.GetGameMap().AddToMap(Item);
                    }
                    return(false);
                }

                foreach (ThreeDCoord Tile in AffectedTiles.Values)
                {
                    if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) || (_room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().Walkable&& !Item.GetBaseItem().IsSeat))
                    {
                        if (NeedsReAdd)
                        {
                            _room.GetGameMap().AddToMap(Item);
                        }
                        return(false);
                    }
                }
            }

            if (SpaceItem != null && Session != null)
            {
                bool CanPlaceHere = true;

                if (AffectedTiles.Values.Select(x => new Point(x.X, x.Y)).Where(x => !SpaceItem.GetAffectedTiles.Contains(x)).ToList().Count > 0)
                {
                    CanPlaceHere = false;
                }

                if (_room.OwnerId == Session.GetHabbo().Id || _room.CheckRights(Session) || Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
                {
                    CanPlaceHere = true;
                }

                if (!CanPlaceHere)
                {
                    return(false);
                }
            }

            // Start calculating new Z coordinate
            newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];

            if (Session != null)
            {
                if (Session.GetHabbo().DebugStacking == true)
                {
                    newZ = Session.GetHabbo().StackHeight;
                }
            }

            if (!OnRoller && !PlacedByRoleplay)
            {
                // Make sure this tile is open and there are no users here
                if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN && !Item.GetBaseItem().IsSeat&& !Item.GetBaseItem().Walkable)
                {
                    return(false);
                }

                foreach (ThreeDCoord Tile in AffectedTiles.Values)
                {
                    if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.OPEN && !Item.GetBaseItem().IsSeat&& !Item.GetBaseItem().Walkable)
                    {
                        if (NeedsReAdd)
                        {
                            _room.GetGameMap().AddToMap(Item);
                        }
                        return(false);
                    }
                }

                // And that we have no users
                if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller && !Item.GetBaseItem().Walkable)
                {
                    foreach (ThreeDCoord Tile in AffectedTiles.Values)
                    {
                        if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0)
                        {
                            if (NeedsReAdd)
                            {
                                _room.GetGameMap().AddToMap(Item);
                            }
                            return(false);
                        }
                    }
                }
            }

            // Find affected objects
            var ItemsAffected = new List <Item>();
            var ItemsComplete = new List <Item>();

            foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList())
            {
                List <Item> Temp = GetFurniObjects(Tile.X, Tile.Y);

                if (Temp != null)
                {
                    ItemsAffected.AddRange(Temp);
                }
            }


            ItemsComplete.AddRange(ItemsOnTile);
            ItemsComplete.AddRange(ItemsAffected);

            if (!OnRoller)
            {
                // Check for items in the stack that do not allow stacking on top of them
                foreach (Item I in ItemsComplete.ToList())
                {
                    if (I == null)
                    {
                        continue;
                    }

                    if (I.Id == Item.Id)
                    {
                        continue;
                    }

                    if (I.GetBaseItem() == null)
                    {
                        continue;
                    }

                    if (!I.GetBaseItem().Stackable)
                    {
                        if (NeedsReAdd)
                        {
                            //AddItem(Item);
                            _room.GetGameMap().AddToMap(Item);
                        }
                        return(false);
                    }
                }
            }

            //if (!Item.IsRoller)
            {
                // If this is a rotating action, maintain item at current height
                if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                {
                    if (Session != null)
                    {
                        if (Session.GetHabbo().DebugStacking == true)
                        {
                            newZ = Session.GetHabbo().StackHeight;
                        }
                        else
                        {
                            newZ = Item.GetZ;
                        }
                    }
                    else
                    {
                        newZ = Item.GetZ;
                    }
                }

                Double StackingTile = 0;


                // Are there any higher objects in the stack!?
                foreach (Item I in ItemsComplete.ToList())
                {
                    if (I == null)
                    {
                        continue;
                    }

                    if (I.Id == Item.Id)
                    {
                        continue; // cannot stack on self
                    }
                    if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL)
                    {
                        StackingTile = I.GetZ;
                    }

                    if (I.TotalHeight > newZ)
                    {
                        if (Session != null)
                        {
                            if (Session.GetHabbo().DebugStacking == true)
                            {
                                newZ = Session.GetHabbo().StackHeight;
                            }
                            else
                            {
                                newZ = StackingTile != 0 ? StackingTile : I.TotalHeight;
                            }
                        }
                        else
                        {
                            newZ = StackingTile != 0 ? StackingTile : I.TotalHeight;
                        }
                    }
                }
            }

            // Verify the rotation is correct
            if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot)
            {
                newRot = 0;
            }

            Item.Rotation = newRot;
            int oldX = Item.GetX;
            int oldY = Item.GetY;

            if (!CheckHeight)
            {
                newZ = origZ;
            }

            Item.SetState(newX, newY, newZ, AffectedTiles);

            if (!OnRoller && Session != null)
            {
                Item.Interactor.OnPlace(Session, Item);
            }

            if (newItem)
            {
                if (_floorItems.ContainsKey(Item.Id))
                {
                    if (Session != null)
                    {
                        Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_item_placed"));
                    }
                    _room.GetGameMap().RemoveFromMap(Item);
                    return(true);
                }

                if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id))
                {
                    _floorItems.TryAdd(Item.Id, Item);
                }
                else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id))
                {
                    _wallItems.TryAdd(Item.Id, Item);
                }

                if (sendMessage)
                {
                    _room.SendMessage(new ObjectAddComposer(Item, _room));
                }
            }
            else
            {
                UpdateItem(Item);
                if (!OnRoller && sendMessage)
                {
                    _room.SendMessage(new ObjectUpdateComposer(Item, Item.UserID));
                }
            }
            _room.GetGameMap().AddToMap(Item);

            if (Item.GetBaseItem().IsSeat)
            {
                updateRoomUserStatuses = true;
            }

            if (updateRoomUserStatuses)
            {
                _room.GetRoomUserManager().UpdateUserStatusses();
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL)
            {
                _room.RemoveTent(Item.Id, Item);
                _room.AddTent(Item.Id);
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
            }
            return(true);
        }
예제 #27
0
        public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false, double height = -1)
        {
            bool NeedsReAdd = false;

            if (newItem)
            {
                if (Item.IsWired)
                {
                    if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Count(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps) > 0)
                    {
                        return(false);
                    }
                }
            }

            List <Item> ItemsOnTile = GetFurniObjects(newX, newY);

            if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Count(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id) > 0)
            {
                return(false);
            }

            if (!newItem)
            {
                NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item);
            }

            Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);

            if (!_room.GetGameMap().ValidTile(newX, newY) || _room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat)
            {
                if (NeedsReAdd)
                {
                    _room.GetGameMap().AddToMap(Item);
                }
                return(false);
            }

            foreach (ThreeDCoord Tile in AffectedTiles.Values)
            {
                if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) ||
                    (_room.GetGameMap().SquareHasUsers(Tile.X, Tile.Y) && !Item.GetBaseItem().IsSeat))
                {
                    if (NeedsReAdd)
                    {
                        _room.GetGameMap().AddToMap(Item);
                    }
                    return(false);
                }
            }

            // Start calculating new Z coordinate
            Double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];

            if (height == -1)
            {
                if (!OnRoller)
                {
                    // Make sure this tile is open and there are no users here
                    if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.Open && !Item.GetBaseItem().IsSeat)
                    {
                        return(false);
                    }

                    foreach (ThreeDCoord Tile in AffectedTiles.Values)
                    {
                        if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.Open &&
                            !Item.GetBaseItem().IsSeat)
                        {
                            if (NeedsReAdd)
                            {
                                //AddItem(Item);
                                _room.GetGameMap().AddToMap(Item);
                            }
                            return(false);
                        }
                    }

                    // And that we have no users
                    if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller)
                    {
                        foreach (ThreeDCoord Tile in AffectedTiles.Values)
                        {
                            if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0)
                            {
                                if (NeedsReAdd)
                                {
                                    _room.GetGameMap().AddToMap(Item);
                                }
                                return(false);
                            }
                        }
                    }
                }

                // Find affected objects
                var ItemsAffected = new List <Item>();
                var ItemsComplete = new List <Item>();

                foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList())
                {
                    List <Item> Temp = GetFurniObjects(Tile.X, Tile.Y);

                    if (Temp != null)
                    {
                        ItemsAffected.AddRange(Temp);
                    }
                }


                ItemsComplete.AddRange(ItemsOnTile);
                ItemsComplete.AddRange(ItemsAffected);

                if (!OnRoller)
                {
                    // Check for items in the stack that do not allow stacking on top of them
                    foreach (Item I in ItemsComplete.ToList())
                    {
                        if (I == null)
                        {
                            continue;
                        }

                        if (I.Id == Item.Id)
                        {
                            continue;
                        }

                        if (I.GetBaseItem() == null)
                        {
                            continue;
                        }

                        if (!I.GetBaseItem().Stackable)
                        {
                            if (NeedsReAdd)
                            {
                                //AddItem(Item);
                                _room.GetGameMap().AddToMap(Item);
                            }
                            return(false);
                        }
                    }
                }

                //if (!Item.IsRoller)
                {
                    // If this is a rotating action, maintain item at current height
                    if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                    {
                        newZ = Item.GetZ;
                    }

                    // Are there any higher objects in the stack!?
                    foreach (Item i in ItemsComplete.ToList())
                    {
                        if (i == null)
                        {
                            continue;
                        }
                        if (i.Id == Item.Id)
                        {
                            continue;
                        }

                        if (i.GetBaseItem().InteractionType == InteractionType.STACKTOOL)
                        {
                            newZ = i.GetZ;
                            break;
                        }
                        if (i.TotalHeight > newZ)
                        {
                            newZ = i.TotalHeight;
                        }
                    }
                }

                // Verify the rotation is correct
                if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot)
                {
                    newRot = 0;
                }
            }
            else
            {
                newZ = height;
            }

            Item.Rotation = newRot;
            int oldX = Item.GetX;
            int oldY = Item.GetY;

            Item.SetState(newX, newY, newZ, AffectedTiles);

            if (!OnRoller && Session != null)
            {
                Item.Interactor.OnPlace(Session, Item);
            }


            if (newItem)
            {
                if (_floorItems.ContainsKey(Item.Id))
                {
                    if (Session != null)
                    {
                        Session.SendNotification(PlusEnvironment.GetLanguageManager().TryGetValue("room.item.already_placed"));
                    }
                    _room.GetGameMap().RemoveFromMap(Item);
                    return(true);
                }

                if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id))
                {
                    _floorItems.TryAdd(Item.Id, Item);
                }
                else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id))
                {
                    _wallItems.TryAdd(Item.Id, Item);
                }

                if (sendMessage)
                {
                    _room.SendPacket(new ObjectAddComposer(Item));
                }
            }
            else
            {
                UpdateItem(Item);
                if (!OnRoller && sendMessage)
                {
                    _room.SendPacket(new ObjectUpdateComposer(Item, _room.OwnerId));
                }
            }
            _room.GetGameMap().AddToMap(Item);

            if (Item.GetBaseItem().IsSeat)
            {
                updateRoomUserStatuses = true;
            }

            if (updateRoomUserStatuses)
            {
                _room.GetRoomUserManager().UpdateUserStatusses();
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL)
            {
                _room.RemoveTent(Item.Id);
                _room.AddTent(Item.Id);
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
            }
            return(true);
        }
예제 #28
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session?.GetHabbo() == null)
            {
                return;
            }

            // Run a quick check to see if we have any existing tickets.
            if (PlusEnvironment.GetGame().GetModerationManager().UserHasTickets(session.GetHabbo().Id))
            {
                var pendingTicket = PlusEnvironment.GetGame().GetModerationManager().GetTicketBySenderId(session.GetHabbo().Id);
                if (pendingTicket != null)
                {
                    session.SendPacket(new CallForHelpPendingCallsComposer(pendingTicket));
                    return;
                }
            }

            var chats = new List <string>();

            var message        = StringCharFilter.Escape(packet.PopString().Trim());
            var category       = packet.PopInt();
            var reportedUserId = packet.PopInt();
            var type           = packet.PopInt(); // Unsure on what this actually is.

            var reportedUser = PlusEnvironment.GetHabboById(reportedUserId);

            if (reportedUser == null)
            {
                // User doesn't exist.
                return;
            }

            var messagecount = packet.PopInt();

            for (var i = 0; i < messagecount; i++)
            {
                packet.PopInt();
                chats.Add(packet.PopString());
            }

            var ticket = new ModerationTicket(1, type, category, UnixTimestamp.GetNow(), 1, session.GetHabbo(), reportedUser, message, session.GetHabbo().CurrentRoom, chats);

            if (!PlusEnvironment.GetGame().GetModerationManager().TryAddTicket(ticket))
            {
                return;
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                // TODO: Come back to this.

                /*dbClient.SetQuery("INSERT INTO `moderation_tickets` (`score`,`type`,`status`,`sender_id`,`reported_id`,`moderator_id`,`message`,`room_id`,`room_name`,`timestamp`) VALUES (1, '" + Category + "', 'open', '" + Session.GetHabbo().Id + "', '" + ReportedUserId + "', '0', @message, '0', '', '" + PlusEnvironment.GetUnixTimestamp() + "')");
                 * dbClient.AddParameter("message", Message);
                 * dbClient.RunQuery();*/

                dbClient.RunQuery("UPDATE `user_info` SET `cfhs` = `cfhs` + '1' WHERE `user_id` = '" + session.GetHabbo().Id + "' LIMIT 1");
            }

            PlusEnvironment.GetGame().GetClientManager().ModAlert("A new support ticket has been submitted!");
            PlusEnvironment.GetGame().GetClientManager().SendPacket(new ModeratorSupportTicketComposer(session.GetHabbo().Id, ticket), "mod_tool");
        }
예제 #29
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            String photoUrl = PlusEnvironment.GetGame().GetCameraManager().GetPhotoForHabbo(Session.GetHabbo());

            if (String.IsNullOrEmpty(photoUrl))
            {
                return;
            }

            if (Session.GetHabbo().Duckets < 1)
            {
                Session.SendPacket(new RoomNotificationComposer("camera", "errors", "${catalog.alert.notenough.activitypoints.description.0}"));
                return;
            }

            string roomId    = photoUrl.Split('-')[0];
            string timestamp = photoUrl.Split('-')[1];

            int posterId = 777954881;

            Int32.TryParse(CameraUtils.Value("camera.poster.id"), out posterId);

            if (!PlusEnvironment.GetGame().GetItemManager().GetItem(posterId, out ItemData Item))
            {
                return;
            }
            if (Item == null)
            {
                return;
            }

            int photoId;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `camera_photos` (creator_id, creator_name, file_name, reports, deleted, ip_address, created_at) VALUES (@uid,@name,@fileName,@reports,@deleted,@ip_address,@created_at)");
                dbClient.AddParameter("uid", Session.GetHabbo().Id);
                dbClient.AddParameter("name", Session.GetHabbo().Username);
                dbClient.AddParameter("fileName", photoUrl);
                dbClient.AddParameter("reports", 0);
                dbClient.AddParameter("deleted", "0");
                dbClient.AddParameter("ip_address", Session.GetConnection().GetIp());
                dbClient.AddParameter("created_at", timestamp);
                photoId = Convert.ToInt32(dbClient.InsertQuery());
            }

            Item photoPoster = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "{\"w\":\"" + StringCharFilter.EscapeJSONString(photoUrl) + "\", \"n\":\"" + StringCharFilter.EscapeJSONString(Session.GetHabbo().Username) + "\", \"s\":\"" + Session.GetHabbo().Id + "\", \"u\":\"" + photoId + "\", \"t\":\"" + timestamp + "\"}", "");

            if (photoPoster != null)
            {
                Session.GetHabbo().GetInventoryComponent().TryAddItem(photoPoster);

                Session.SendPacket(new FurniListAddComposer(photoPoster));
                Session.SendPacket(new FurniListUpdateComposer());
                Session.SendPacket(new FurniListNotificationComposer(photoPoster.Id, 1));
                Session.GetHabbo().Duckets--;
                Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, -1));

                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_CameraPhotoCount", 1);
            }

            Session.SendPacket(new CameraPurchaseSuccesfullComposer());

            Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
        }
예제 #30
0
파일: RoomData.cs 프로젝트: xjoao97/HabboRP
        public void Fill(DataRow Row)
        {
            Id          = Convert.ToInt32(Row["id"]);
            Name        = Convert.ToString(Row["caption"]);
            Description = Convert.ToString(Row["description"]);
            Type        = Convert.ToString(Row["roomtype"]);
            OwnerId     = Convert.ToInt32(Row["owner"]);

            OwnerName = "";
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `username` FROM `users` WHERE `id` = @owner LIMIT 1");
                dbClient.AddParameter("owner", OwnerId);
                string result = dbClient.getString();
                if (!String.IsNullOrEmpty(result))
                {
                    OwnerName = result;
                }
            }

            this.Access = RoomAccessUtility.ToRoomAccess(Row["state"].ToString().ToLower());

            Category = Convert.ToInt32(Row["category"]);
            if (!string.IsNullOrEmpty(Row["users_now"].ToString()))
            {
                UsersNow = Convert.ToInt32(Row["users_now"]);
            }
            else
            {
                UsersNow = 0;
            }
            UsersMax            = Convert.ToInt32(Row["users_max"]);
            ModelName           = Convert.ToString(Row["model_name"]);
            Score               = Convert.ToInt32(Row["score"]);
            Tags                = new List <string>();
            AllowPets           = Convert.ToInt32(Row["allow_pets"].ToString());
            AllowPetsEating     = Convert.ToInt32(Row["allow_pets_eat"].ToString());
            RoomBlockingEnabled = Convert.ToInt32(Row["room_blocking_disabled"].ToString());
            Hidewall            = Convert.ToInt32(Row["allow_hidewall"].ToString());
            Password            = Convert.ToString(Row["password"]);
            Wallpaper           = Convert.ToString(Row["wallpaper"]);
            Floor               = Convert.ToString(Row["floor"]);
            Landscape           = Convert.ToString(Row["landscape"]);
            FloorThickness      = Convert.ToInt32(Row["floorthick"]);
            WallThickness       = Convert.ToInt32(Row["wallthick"]);
            WhoCanMute          = Convert.ToInt32(Row["mute_settings"]);
            WhoCanKick          = Convert.ToInt32(Row["kick_settings"]);
            WhoCanBan           = Convert.ToInt32(Row["ban_settings"]);
            chatMode            = Convert.ToInt32(Row["chat_mode"]);
            chatSpeed           = Convert.ToInt32(Row["chat_speed"]);
            chatSize            = Convert.ToInt32(Row["chat_size"]);
            TradeSettings       = Convert.ToInt32(Row["trade_settings"]);
            int   GroupId = Convert.ToInt32(Row["group_id"]);
            Group G       = null;

            if (GroupId < 1000)
            {
                G = GroupManager.GetJob(GroupId);
            }
            else
            {
                G = GroupManager.GetGang(GroupId);
            }

            if (G != null)
            {
                Group = G;
            }
            else
            {
                Group = null;
            }

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                Tags.Add(Tag);
            }

            mModel = PlusEnvironment.GetGame().GetRoomManager().GetModel(ModelName);

            this.PushEnabled    = PlusEnvironment.EnumToBool(Row["push_enabled"].ToString());
            this.PullEnabled    = PlusEnvironment.EnumToBool(Row["pull_enabled"].ToString());
            this.SPushEnabled   = PlusEnvironment.EnumToBool(Row["spush_enabled"].ToString());
            this.SPullEnabled   = PlusEnvironment.EnumToBool(Row["spull_enabled"].ToString());
            this.EnablesEnabled = PlusEnvironment.EnumToBool(Row["enables_enabled"].ToString());
            this.RespectNotificationsEnabled = PlusEnvironment.EnumToBool(Row["respect_notifications_enabled"].ToString());
            this.PetMorphsAllowed            = PlusEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString());
        }