public MoodlightData(int ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM room_items_moodlight WHERE item_id = '" + ItemId + "' LIMIT 1");
                Row = dbClient.getRow();
            }

            if (Row == null)
            {
                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("INSERT INTO `room_items_moodlight` (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES (" + ItemId + ",0,1,'#000000,255,0','#000000,255,0','#000000,255,0')");
                    dbClient.SetQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM room_items_moodlight WHERE item_id=" + ItemId + " LIMIT 1");
                    Row = dbClient.getRow();
                }
            }

            Enabled       = QuasarEnvironment.EnumToBool(Row["enabled"].ToString());
            CurrentPreset = Convert.ToInt32(Row["current_preset"]);
            Presets       = new List <MoodlightPreset>();

            Presets.Add(GeneratePreset(Convert.ToString(Row["preset_one"])));
            Presets.Add(GeneratePreset(Convert.ToString(Row["preset_two"])));
            Presets.Add(GeneratePreset(Convert.ToString(Row["preset_three"])));
        }
Esempio n. 2
0
        public void OnNewFriendship(int friendID)
        {
            GameClient friend = QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;

            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE `id` = @friendid LIMIT 1");
                    dbClient.AddParameter("friendid", friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, Convert.ToString(dRow["username"]), Convert.ToString(dRow["look"]), Convert.ToString(dRow["motto"]), Convert.ToInt32(dRow["last_online"]),
                                               QuasarEnvironment.EnumToBool(dRow["hide_online"].ToString()), QuasarEnvironment.EnumToBool(dRow["hide_inroom"].ToString()));
            }
            else
            {
                Habbo user = friend.GetHabbo();


                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, 0, user.AppearOffline, user.AllowPublicRoomStatus);
                newFriend.UpdateUser(friend);
            }

            if (!_friends.ContainsKey(friendID))
            {
                _friends.Add(friendID, newFriend);
            }

            GetClient().SendMessage(SerializeUpdate(newFriend));
        }
        public static MoodlightPreset GeneratePreset(string Data)
        {
            String[] Bits = Data.Split(',');

            if (!IsValidColor(Bits[0]))
            {
                Bits[0] = "#000000";
            }

            return(new MoodlightPreset(Bits[0], int.Parse(Bits[1]), QuasarEnvironment.EnumToBool(Bits[2])));
        }
 public static Habbo GenerateHabbo(DataRow Row, DataRow UserInfo)
 {
     return(new Habbo(Convert.ToInt32(Row["id"]), Convert.ToString(Row["username"]), Convert.ToInt32(Row["rank"]), Convert.ToString(Row["motto"]), Convert.ToString(Row["look"]),
                      Convert.ToString(Row["gender"]), Convert.ToInt32(Row["credits"]), Convert.ToInt32(Row["activity_points"]),
                      Convert.ToInt32(Row["home_room"]), QuasarEnvironment.EnumToBool(Row["block_newfriends"].ToString()), Convert.ToInt32(Row["last_online"]),
                      QuasarEnvironment.EnumToBool(Row["hide_online"].ToString()), QuasarEnvironment.EnumToBool(Row["hide_inroom"].ToString()),
                      Convert.ToDouble(Row["account_created"]), Convert.ToInt32(Row["vip_points"]), Convert.ToString(Row["machine_id"]), Convert.ToString(Row["volume"]),
                      QuasarEnvironment.EnumToBool(Row["chat_preference"].ToString()), QuasarEnvironment.EnumToBool(Row["focus_preference"].ToString()), QuasarEnvironment.EnumToBool(Row["pets_muted"].ToString()), QuasarEnvironment.EnumToBool(Row["bots_muted"].ToString()),
                      QuasarEnvironment.EnumToBool(Row["advertising_report_blocked"].ToString()), Convert.ToDouble(Row["last_change"].ToString()), Convert.ToInt32(Row["gotw_points"]), Convert.ToInt32(Row["user_points"]),
                      QuasarEnvironment.EnumToBool(Convert.ToString(Row["ignore_invites"])), Convert.ToDouble(Row["time_muted"]), Convert.ToDouble(UserInfo["trading_locked"]),
                      QuasarEnvironment.EnumToBool(Row["allow_gifts"].ToString()), Convert.ToInt32(Row["friend_bar_state"]), QuasarEnvironment.EnumToBool(Row["disable_forced_effects"].ToString()),
                      QuasarEnvironment.EnumToBool(Row["allow_mimic"].ToString()), Convert.ToInt32(Row["rank_vip"]), Convert.ToByte(Row["guia"].ToString()), Convert.ToByte(Row["hulptroepen"].ToString()), (Row["nux_user"].ToString() == "true"),
                      Convert.ToInt32(Row["pumpkins"]), Convert.ToInt32(Row["camera_count"].ToString())));
 }
Esempio n. 5
0
        public void LoadModels()
        {
            if (this._roomModels.Count > 0)
            {
                _roomModels.Clear();
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT id,door_x,door_y,door_z,door_dir,heightmap,public_items,club_only,poolmap,`wall_height` FROM `room_models` WHERE `custom` = '0'");
                DataTable Data = dbClient.getTable();

                if (Data == null)
                {
                    return;
                }

                foreach (DataRow Row in Data.Rows)
                {
                    string Modelname       = Convert.ToString(Row["id"]);
                    string staticFurniture = Convert.ToString(Row["public_items"]);

                    _roomModels.Add(Modelname, new RoomModel(Convert.ToInt32(Row["door_x"]), Convert.ToInt32(Row["door_y"]), (Double)Row["door_z"], Convert.ToInt32(Row["door_dir"]),
                                                             Convert.ToString(Row["heightmap"]), Convert.ToString(Row["public_items"]), QuasarEnvironment.EnumToBool(Row["club_only"].ToString()), Convert.ToString(Row["poolmap"]), Convert.ToInt32(Row["wall_height"])));
                }
            }
        }
Esempio n. 6
0
        public void LoadModel(string Id)
        {
            DataRow Row = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT id,door_x,door_y,door_z,door_dir,heightmap,public_items,club_only,poolmap,`wall_height` FROM `room_models` WHERE `custom` = '1' AND `id` = '" + Id + "' LIMIT 1");
                Row = dbClient.getRow();

                if (Row == null)
                {
                    return;
                }

                string Modelname = Convert.ToString(Row["id"]);
                if (!this._roomModels.ContainsKey(Id))
                {
                    this._roomModels.Add(Modelname, new RoomModel(Convert.ToInt32(Row["door_x"]), Convert.ToInt32(Row["door_y"]), Convert.ToDouble(Row["door_z"]), Convert.ToInt32(Row["door_dir"]),
                                                                  Convert.ToString(Row["heightmap"]), Convert.ToString(Row["public_items"]), QuasarEnvironment.EnumToBool(Row["club_only"].ToString()), Convert.ToString(Row["poolmap"]), Convert.ToInt32(Row["wall_height"])));
                }
            }
        }
        public void Init()
        {
            if (this._items.Count > 0)
            {
                this._items.Clear();
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`item_name`,`public_name`,`type`,`width`,`length`,`stack_height`,`can_stack`,`can_sit`,`is_walkable`,`sprite_id`,`allow_recycle`,`allow_trade`,`allow_marketplace_sell`,`allow_gift`,`allow_inventory_stack`,`interaction_type`,`interaction_modes_count`,`vending_ids`,`height_adjustable`,`effect_id`,`wired_id`,`is_rare`,`clothing_id`, `extra_rot` FROM `furniture`");
                DataTable ItemData = dbClient.getTable();

                if (ItemData != null)
                {
                    foreach (DataRow Row in ItemData.Rows)
                    {
                        try
                        {
                            int             id                  = Convert.ToInt32(Row["id"]);
                            int             spriteID            = Convert.ToInt32(Row["sprite_id"]);
                            string          itemName            = Convert.ToString(Row["item_name"]);
                            string          PublicName          = Convert.ToString(Row["public_name"]);
                            string          type                = Row["type"].ToString();
                            int             width               = Convert.ToInt32(Row["width"]);
                            int             length              = Convert.ToInt32(Row["length"]);
                            double          height              = Convert.ToDouble(Row["stack_height"]);
                            bool            allowStack          = QuasarEnvironment.EnumToBool(Row["can_stack"].ToString());
                            bool            allowWalk           = QuasarEnvironment.EnumToBool(Row["is_walkable"].ToString());
                            bool            allowSit            = QuasarEnvironment.EnumToBool(Row["can_sit"].ToString());
                            bool            allowRecycle        = QuasarEnvironment.EnumToBool(Row["allow_recycle"].ToString());
                            bool            allowTrade          = QuasarEnvironment.EnumToBool(Row["allow_trade"].ToString());
                            bool            allowMarketplace    = Convert.ToInt32(Row["allow_marketplace_sell"]) == 1;
                            bool            allowGift           = Convert.ToInt32(Row["allow_gift"]) == 1;
                            bool            allowInventoryStack = QuasarEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString());
                            InteractionType interactionType     = InteractionTypes.GetTypeFromString(Convert.ToString(Row["interaction_type"]));
                            int             cycleCount          = Convert.ToInt32(Row["interaction_modes_count"]);
                            string          vendingIDS          = Convert.ToString(Row["vending_ids"]);
                            string          heightAdjustable    = Convert.ToString(Row["height_adjustable"]);
                            int             EffectId            = Convert.ToInt32(Row["effect_id"]);
                            int             WiredId             = Convert.ToInt32(Row["wired_id"]);
                            bool            IsRare              = QuasarEnvironment.EnumToBool(Row["is_rare"].ToString());
                            int             ClothingId          = Convert.ToInt32(Row["clothing_id"]);
                            bool            ExtraRot            = QuasarEnvironment.EnumToBool(Row["extra_rot"].ToString());

                            if (!this._gifts.ContainsKey(spriteID))
                            {
                                this._gifts.Add(spriteID, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot));
                            }

                            if (!this._items.ContainsKey(id))
                            {
                                this._items.Add(id, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            Console.ReadKey();
                            Logging.WriteLine("Could not load item #" + Convert.ToInt32(Row[0]) + ", please verify the data is okay.");
                        }
                    }
                }
            }

            string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");

            Console.WriteLine(CurrentTime + "» Catalogus » Items » Geladen!");
        }
Esempio n. 8
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            if (Session.GetHabbo().InRoom)
            {
                Room OldRoom;

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

                if (OldRoom.GetRoomUserManager() != null)
                {
                    OldRoom.GetRoomUserManager().RemoveUserFromRoom(Session, false, false);
                }
            }

            if (!Room.GetRoomUserManager().AddAvatarToRoom(Session))
            {
                Room.GetRoomUserManager().RemoveUserFromRoom(Session, false, false);
                return;//TODO: Remove?
            }

            Room.SendObjects(Session);

            //Status updating for messenger, do later as buggy.

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

            if (Session.GetHabbo().GetStats().QuestID > 0)
            {
                QuasarEnvironment.GetGame().GetQuestManager().QuestReminder(Session, Session.GetHabbo().GetStats().QuestID);
            }

            Session.SendMessage(new RoomEntryInfoComposer(Room.RoomId, Room.CheckRights(Session, true)));
            Session.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, QuasarEnvironment.EnumToBool(Room.Hidewall.ToString())));

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

            if (ThisUser != null && Session.GetHabbo().PetId == 0)
            {
                Room.SendMessage(new UserChangeComposer(ThisUser, false));
            }

            Session.SendMessage(new RoomEventComposer(Room.RoomData, Room.RoomData.Promotion));


            if (Room.poolQuestion != string.Empty)
            {
                Session.SendMessage(new QuickPollMessageComposer(Room.poolQuestion));

                if (Room.yesPoolAnswers.Contains(Session.GetHabbo().Id) || Room.noPoolAnswers.Contains(Session.GetHabbo().Id))
                {
                    Session.SendMessage(new QuickPollResultsMessageComposer(Room.yesPoolAnswers.Count, Room.noPoolAnswers.Count));
                }
            }


            if (Room.GetWired() != null)
            {
                Room.GetWired().TriggerEvent(WiredBoxType.TriggerRoomEnter, Session.GetHabbo());
            }

            if (Room.ForSale && Room.SalePrice > 0 && (Room.GetRoomUserManager().GetRoomUserByHabbo(Room.OwnerName) != null))
            {
                Session.SendWhisper("Deze kamer staat te koop voor " + Room.SalePrice + " Duckets. Gebruik de command :koopkamer als je de kamer wilt overnemen.");
            }
            else if (Room.ForSale && Room.GetRoomUserManager().GetRoomUserByHabbo(Room.OwnerName) == null)
            {
                foreach (RoomUser _User in Room.GetRoomUserManager().GetRoomUsers())
                {
                    if (_User.GetClient() != null && _User.GetClient().GetHabbo() != null && _User.GetClient().GetHabbo().Id != Session.GetHabbo().Id)
                    {
                        _User.GetClient().SendWhisper("Oeps! Deze kamer is toevallig net uit de verkoop gehaald.");
                    }
                }
                Room.ForSale   = false;
                Room.SalePrice = 0;
            }

            if (QuasarEnvironment.GetUnixTimestamp() < Session.GetHabbo().FloodTime&& Session.GetHabbo().FloodTime != 0)
            {
                Session.SendMessage(new FloodControlComposer((int)Session.GetHabbo().FloodTime - (int)QuasarEnvironment.GetUnixTimestamp()));
            }


            QuasarEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.SOCIAL_VISIT);
        }
        /// <summary>
        /// Initializes the EffectsComponent.
        /// </summary>
        /// <param name="UserId"></param>
        public bool Init(Habbo Habbo)
        {
            if (_effects.Count > 0)
            {
                return(false);
            }

            DataTable GetEffects = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `user_effects` WHERE `user_id` = @id;");
                dbClient.AddParameter("id", Habbo.Id);
                GetEffects = dbClient.getTable();

                if (GetEffects != null)
                {
                    foreach (DataRow Row in GetEffects.Rows)
                    {
                        if (this._effects.TryAdd(Convert.ToInt32(Row["id"]), new AvatarEffect(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["effect_id"]), Convert.ToDouble(Row["total_duration"]), QuasarEnvironment.EnumToBool(Row["is_activated"].ToString()), Convert.ToDouble(Row["activated_stamp"]), Convert.ToInt32(Row["quantity"]))))
                        {
                            //umm?
                        }
                    }
                }
            }

            this._habbo         = Habbo;
            this._currentEffect = 0;
            return(true);
        }
        public void Init(ItemDataManager ItemDataManager)
        {
            if (this._televisions.Count > 0)
            {
                _televisions.Clear();
            }
            if (this._pages.Count > 0)
            {
                this._pages.Clear();
            }
            if (this._botPresets.Count > 0)
            {
                this._botPresets.Clear();
            }
            if (this._items.Count > 0)
            {
                this._items.Clear();
            }
            if (this._deals.Count > 0)
            {
                this._deals.Clear();
            }
            if (this._predesignedItems.Count > 0)
            {
                this._predesignedItems.Clear();
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.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`,`cost_honor`,`predesigned_id`,`cost_pumpkins` FROM `catalog_items`");
                DataTable CatalogueItems = dbClient.getTable();
                string    CurrentTime    = DateTime.Now.ToString("HH:mm:ss" + " | ");
                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"]);
                        uint PredesignedId = Convert.ToUInt32(Row["predesigned_id"]);
                        if (BaseId == 0 && PredesignedId > 0)
                        {
                            var roomPack = _predesignedManager.predesignedRoom[PredesignedId];
                            if (roomPack == null)
                            {
                                continue;
                            }
                            if (roomPack.CatalogItems.Contains(";"))
                            {
                                var cataItems = new Dictionary <int, int>();
                                var itemArray = roomPack.CatalogItems.Split(new char[] { ';' });
                                foreach (var item in itemArray)
                                {
                                    var      items           = item.Split(',');
                                    ItemData PredesignedData = null;
                                    if (!ItemDataManager.GetItem(Convert.ToInt32(items[0]), out PredesignedData))
                                    {
                                        Console.WriteLine(CurrentTime + "» Kan item [" + ItemId + "] niet laden - geen 'Furniture' record gevonden.");
                                        continue;
                                    }

                                    cataItems.Add(Convert.ToInt32(items[0]), Convert.ToInt32(items[1]));
                                }

                                this._predesignedItems[PageId] = new PredesignedContent(ItemId, cataItems);
                            }
                        }

                        ItemData Data = null;
                        if (PredesignedId <= 0)
                        {
                            if (!ItemDataManager.GetItem(BaseId, out Data))
                            {
                                Console.WriteLine(CurrentTime + "» Kan item [" + ItemId + "] niet laden - geen 'Furniture' record gevonden.");
                                continue;
                            }
                        }

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

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

                        this._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"]), Convert.ToInt32(Row["limited_sells"]), Convert.ToInt32(Row["limited_stack"]), QuasarEnvironment.EnumToBool(Row["offer_active"].ToString()),
                                                                                            Convert.ToString(Row["extradata"]), Convert.ToString(Row["badge"]), Convert.ToInt32(Row["offer_id"]), Convert.ToInt32(Row["cost_honor"]),
                                                                                            Convert.ToInt32(Row["predesigned_id"]), Convert.ToInt32(Row["cost_pumpkins"])));
                    }
                }

                dbClient.SetQuery("SELECT * FROM `catalog_deals`");
                DataTable GetDeals = dbClient.getTable();

                if (GetDeals != null)
                {
                    foreach (DataRow Row in GetDeals.Rows)
                    {
                        int    Id      = Convert.ToInt32(Row["id"]);
                        int    PageId  = Convert.ToInt32(Row["page_id"]);
                        string Items   = Convert.ToString(Row["items"]);
                        string Name    = Convert.ToString(Row["name"]);
                        int    Credits = Convert.ToInt32(Row["cost_credits"]);
                        int    Pixels  = Convert.ToInt32(Row["cost_pixels"]);

                        if (!this._deals.ContainsKey(PageId))
                        {
                            this._deals[PageId] = new Dictionary <int, CatalogDeal>();
                        }

                        CatalogDeal Deal = new CatalogDeal(Id, PageId, Items, Name, Credits, Pixels, ItemDataManager);
                        this._deals[PageId].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)
                    {
                        this._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"]),
                                                                                    this._items.ContainsKey(Convert.ToInt32(Row["id"])) ? this._items[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogItem>(),
                                                                                    this._deals.ContainsKey(Convert.ToInt32(Row["id"])) ? this._deals[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogDeal>(),
                                                                                    this._predesignedItems.ContainsKey(Convert.ToInt32(Row["id"])) ? this._predesignedItems[Convert.ToInt32(Row["id"])] : null,
                                                                                    ref this._itemOffers));
                    }
                }

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

                // Added
                if (this._televisions.Count > 0)
                {
                    _televisions.Clear();
                }

                DataTable getData = null;
                {
                    dbClient.SetQuery("SELECT * FROM `items_youtube` ORDER BY `id` DESC");
                    getData = dbClient.getTable();

                    if (getData != null)
                    {
                        foreach (DataRow Row in getData.Rows)
                        {
                            this._televisions.Add(Convert.ToInt32(Row["id"]), new TelevisionItem(Convert.ToInt32(Row["id"]), Row["youtube_id"].ToString(), Row["title"].ToString(), Row["description"].ToString(), QuasarEnvironment.EnumToBool(Row["enabled"].ToString())));
                        }
                    }
                }

                if (bots != null)
                {
                    foreach (DataRow Row in bots.Rows)
                    {
                        this._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])));
                    }
                }

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

            string CurrentTime1 = DateTime.Now.ToString("HH:mm:ss" + " | ");

            Console.WriteLine(CurrentTime1 + "» Catalogus " + this._televisions.Count + " Youtube Tv's");
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine(CurrentTime1 + "» Catalogus » Geladen!");
            Console.ResetColor();
        }
Esempio n. 11
0
        public bool RequestBuddy(string UserQuery)
        {
            int  userID;
            bool hasFQDisabled;

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

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = QuasarEnvironment.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 = QuasarEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID        = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().AllowFriendRequests;
            }

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

            int ToId = userID;

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

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

            QuasarEnvironment.GetGame().GetQuestManager().ProgressUserQuest(GetClient(), QuestType.ADD_FRIENDS);

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

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

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

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

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

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

            _requests.Add(ToId, Request);
            return(true);
        }
Esempio n. 12
0
        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 = QuasarEnvironment.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"]);

            Group G = null;

            if (QuasarEnvironment.GetGame().GetGroupManager().TryGetGroup(Convert.ToInt32(Row["group_id"]), out G))
            {
                Group = G;
            }
            else
            {
                Group = null;
            }

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

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

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

            WiredScoreBordDay   = new Dictionary <int, KeyValuePair <int, string> >();
            WiredScoreBordWeek  = new Dictionary <int, KeyValuePair <int, string> >();
            WiredScoreBordMonth = new Dictionary <int, KeyValuePair <int, string> >();

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                List <bool> SuperCheck = new List <bool>()
                {
                    false,
                    false,
                    false
                };

                DateTime now           = DateTime.Now;
                int      getdaytoday   = Convert.ToInt32(now.ToString("MMddyyyy"));
                int      getmonthtoday = Convert.ToInt32(now.ToString("MM"));
                int      getweektoday  = CultureInfo.GetCultureInfo("Nl-nl").Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

                this.WiredScoreFirstBordInformation = new List <int>()
                {
                    getdaytoday,
                    getmonthtoday,
                    getweektoday
                };

                dbClient.SetQuery("SELECT * FROM wired_scorebord WHERE roomid = @id ORDER BY `punten` DESC ");
                dbClient.AddParameter("id", this.Id);
                foreach (DataRow row in dbClient.getTable().Rows)
                {
                    int    userid    = Convert.ToInt32(row["userid"]);
                    string username  = Convert.ToString(row["username"]);
                    int    Punten    = Convert.ToInt32(row["punten"]);
                    string soort     = Convert.ToString(row["soort"]);
                    int    timestamp = Convert.ToInt32(row["timestamp"]);
                    if ((!(soort == "day") || this.WiredScoreBordDay.ContainsKey(userid) ? false : !SuperCheck[0]))
                    {
                        if (timestamp != getdaytoday)
                        {
                            SuperCheck[0] = false;
                        }
                        if (!SuperCheck[0])
                        {
                            this.WiredScoreBordDay.Add(userid, new KeyValuePair <int, string>(Punten, username));
                        }
                    }
                    if ((!(soort == "month") || this.WiredScoreBordMonth.ContainsKey(userid) ? false : !SuperCheck[1]))
                    {
                        if (timestamp != getmonthtoday)
                        {
                            SuperCheck[1] = false;
                        }
                        this.WiredScoreBordMonth.Add(userid, new KeyValuePair <int, string>(Punten, username));
                    }
                    if ((!(soort == "week") || this.WiredScoreBordWeek.ContainsKey(userid) ? false : !SuperCheck[2]))
                    {
                        if (timestamp != getweektoday)
                        {
                            SuperCheck[2] = false;
                        }
                        this.WiredScoreBordWeek.Add(userid, new KeyValuePair <int, string>(Punten, username));
                    }
                }
                if (SuperCheck[0])
                {
                    dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", this.Id, "' AND `soort`='day'"));
                    this.WiredScoreBordDay.Clear();
                }
                if (SuperCheck[1])
                {
                    dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", this.Id, "' AND `soort`='month'"));
                    this.WiredScoreBordMonth.Clear();
                }
                if (SuperCheck[2])
                {
                    dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", this.Id, "' AND `soort`='week'"));
                    this.WiredScoreBordDay.Clear();
                }
            }
        }
Esempio n. 13
0
        public void Init()
        {
            if (this._televisions.Count > 0)
            {
                _televisions.Clear();
            }

            DataTable getData = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `items_youtube` ORDER BY `id` DESC");
                getData = dbClient.getTable();

                if (getData != null)
                {
                    foreach (DataRow Row in getData.Rows)
                    {
                        this._televisions.Add(Convert.ToInt32(Row["id"]), new TelevisionItem(Convert.ToInt32(Row["id"]), Row["youtube_id"].ToString(), Row["title"].ToString(), Row["description"].ToString(), QuasarEnvironment.EnumToBool(Row["enabled"].ToString())));
                    }
                }
            }

            // string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");
            // Console.WriteLine(CurrentTime + "» Catalogus " + this._televisions.Count + " Youtube Tv's");
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            DynamicRoomModel Model = Room.GetGameMap().Model;

            if (Model == null)
            {
                return;
            }

            ICollection <Item> FloorItems = Room.GetRoomItemHandler().GetFloor;

            Session.SendMessage(new FloorPlanFloorMapComposer(FloorItems));
            Session.SendMessage(new FloorPlanSendDoorComposer(Model.DoorX, Model.DoorY, Model.DoorOrientation));
            Session.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, QuasarEnvironment.EnumToBool(Room.Hidewall.ToString())));
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room;

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

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


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

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

            Bot Bot = null;

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

            int BotCount = 0;

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

                BotCount += 1;
            }

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

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

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

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

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

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

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

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

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

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


            Bot ToRemove = null;

            if (!Session.GetHabbo().GetInventoryComponent().TryRemoveBot(BotId, out ToRemove))
            {
                Console.WriteLine("Fout bij het verwijderen van de bot: " + ToRemove.Id);
                return;
            }
            Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots()));
            QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_ExploreBot", 1, false);
        }
Esempio n. 16
0
        public static UserData GetUserData(string SessionTicket, out byte errorCode)
        {
            int       UserId;
            DataRow   dUserInfo       = null;
            DataTable dAchievements   = null;
            DataTable dFavouriteRooms = null;
            DataTable dIgnores        = null;
            DataTable dBadges         = null;
            DataTable dEffects        = null;
            DataTable dFriends        = null;
            DataTable dRequests       = null;
            DataTable dRooms          = null;
            DataTable dQuests         = null;
            DataTable dRelations      = null;
            DataTable talentsTable    = null;
            DataRow   UserInfo        = null;
            DataTable Subscriptions   = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `users` WHERE `auth_ticket` = @sso LIMIT 1");
                dbClient.AddParameter("sso", SessionTicket);
                dUserInfo = dbClient.getRow();

                if (dUserInfo == null)
                {
                    errorCode = 1;
                    return(null);
                }

                UserId = Convert.ToInt32(dUserInfo["id"]);
                if (QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId) != null)
                {
                    errorCode = 2;
                    QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId).Disconnect();
                    return(null);
                }

                dbClient.SetQuery("SELECT `group`,`level`,`progress` FROM `user_achievements` WHERE `userid` = '" + UserId + "'");
                dAchievements = dbClient.getTable();

                dbClient.SetQuery("SELECT room_id FROM user_favorites WHERE `user_id` = '" + UserId + "'");
                dFavouriteRooms = dbClient.getTable();

                dbClient.SetQuery("SELECT ignore_id FROM user_ignores WHERE `user_id` = '" + UserId + "'");
                dIgnores = dbClient.getTable();

                dbClient.SetQuery("SELECT `badge_id`,`badge_slot` FROM user_badges WHERE `user_id` = '" + UserId + "'");
                dBadges = dbClient.getTable();

                dbClient.SetQuery("SELECT `effect_id`,`total_duration`,`is_activated`,`activated_stamp` FROM user_effects WHERE `user_id` = '" + UserId + "'");
                dEffects = dbClient.getTable();

                dbClient.SetQuery(
                    "SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online " +
                    "FROM users " +
                    "JOIN messenger_friendships " +
                    "ON users.id = messenger_friendships.user_one_id " +
                    "WHERE messenger_friendships.user_two_id = " + UserId + " " +
                    "UNION ALL " +
                    "SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online " +
                    "FROM users " +
                    "JOIN messenger_friendships " +
                    "ON users.id = messenger_friendships.user_two_id " +
                    "WHERE messenger_friendships.user_one_id = " + UserId);
                dFriends = dbClient.getTable();

                dbClient.SetQuery("SELECT messenger_requests.from_id,messenger_requests.to_id,users.username FROM users JOIN messenger_requests ON users.id = messenger_requests.from_id WHERE messenger_requests.to_id = " + UserId);
                dRequests = dbClient.getTable();

                dbClient.SetQuery("SELECT * FROM rooms WHERE `owner` = '" + UserId + "' LIMIT 150");
                dRooms = dbClient.getTable();

                dbClient.SetQuery("SELECT * FROM users_talents WHERE userid = '" + UserId + "'");
                talentsTable = dbClient.getTable();

                dbClient.SetQuery("SELECT `quest_id`,`progress` FROM user_quests WHERE `user_id` = '" + UserId + "'");
                dQuests = dbClient.getTable();

                dbClient.SetQuery("SELECT * FROM `user_relationships` WHERE `user_id` = @id");
                dbClient.AddParameter("id", UserId);
                dRelations = dbClient.getTable();

                dbClient.SetQuery("SELECT * FROM user_subscriptions WHERE user_id = '" + UserId + "'");
                Subscriptions = dbClient.getTable();

                dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1");
                UserInfo = dbClient.getRow();
                if (UserInfo == null)
                {
                    dbClient.RunQuery("INSERT INTO `user_info` (`user_id`) VALUES ('" + UserId + "')");

                    dbClient.SetQuery("SELECT * FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1");
                    UserInfo = dbClient.getRow();
                }

                dbClient.runFastQuery("UPDATE users SET online='1' WHERE id=" + UserId + " LIMIT 1");
            }

            ConcurrentDictionary <string, UserAchievement> Achievements = new ConcurrentDictionary <string, UserAchievement>();

            foreach (DataRow dRow in dAchievements.Rows)
            {
                Achievements.TryAdd(Convert.ToString(dRow["group"]), new UserAchievement(Convert.ToString(dRow["group"]), Convert.ToInt32(dRow["level"]), Convert.ToInt32(dRow["progress"])));
            }

            List <int> favouritedRooms = new List <int>();

            foreach (DataRow dRow in dFavouriteRooms.Rows)
            {
                favouritedRooms.Add(Convert.ToInt32(dRow["room_id"]));
            }

            List <int> ignores = new List <int>();

            foreach (DataRow dRow in dIgnores.Rows)
            {
                ignores.Add(Convert.ToInt32(dRow["ignore_id"]));
            }

            List <Badge> badges = new List <Badge>();

            foreach (DataRow dRow in dBadges.Rows)
            {
                badges.Add(new Badge(Convert.ToString(dRow["badge_id"]), Convert.ToInt32(dRow["badge_slot"])));
            }

            Dictionary <int, MessengerBuddy> friends = new Dictionary <int, MessengerBuddy>();

            foreach (DataRow dRow in dFriends.Rows)
            {
                int    friendID         = Convert.ToInt32(dRow["id"]);
                string friendName       = Convert.ToString(dRow["username"]);
                string friendLook       = Convert.ToString(dRow["look"]);
                string friendMotto      = Convert.ToString(dRow["motto"]);
                int    friendLastOnline = Convert.ToInt32(dRow["last_online"]);
                bool   friendHideOnline = QuasarEnvironment.EnumToBool(dRow["hide_online"].ToString());
                bool   friendHideRoom   = QuasarEnvironment.EnumToBool(dRow["hide_inroom"].ToString());

                if (friendID == UserId)
                {
                    continue;
                }

                if (!friends.ContainsKey(friendID))
                {
                    friends.Add(friendID, new MessengerBuddy(friendID, friendName, friendLook, friendMotto, friendLastOnline, friendHideOnline, friendHideRoom));
                }
            }

            Dictionary <int, MessengerRequest> requests = new Dictionary <int, MessengerRequest>();

            foreach (DataRow dRow in dRequests.Rows)
            {
                int receiverID = Convert.ToInt32(dRow["from_id"]);
                int senderID   = Convert.ToInt32(dRow["to_id"]);

                string requestUsername = Convert.ToString(dRow["username"]);

                if (receiverID != UserId)
                {
                    if (!requests.ContainsKey(receiverID))
                    {
                        requests.Add(receiverID, new MessengerRequest(UserId, receiverID, requestUsername));
                    }
                }
                else
                {
                    if (!requests.ContainsKey(senderID))
                    {
                        requests.Add(senderID, new MessengerRequest(UserId, senderID, requestUsername));
                    }
                }
            }

            List <RoomData> rooms = new List <RoomData>();

            foreach (DataRow dRow in dRooms.Rows)
            {
                rooms.Add(QuasarEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToInt32(dRow["id"]), dRow));
            }

            Dictionary <int, int> quests = new Dictionary <int, int>();

            foreach (DataRow dRow in dQuests.Rows)
            {
                int questId = Convert.ToInt32(dRow["quest_id"]);

                if (quests.ContainsKey(questId))
                {
                    quests.Remove(questId);
                }

                quests.Add(questId, Convert.ToInt32(dRow["progress"]));
            }

            Dictionary <int, Relationship> Relationships = new Dictionary <int, Relationship>();

            foreach (DataRow Row in dRelations.Rows)
            {
                if (friends.ContainsKey(Convert.ToInt32(Row[2])))
                {
                    Relationships.Add(Convert.ToInt32(Row[2]), new Relationship(Convert.ToInt32(Row[0]), Convert.ToInt32(Row[2]), Convert.ToInt32(Row[3].ToString())));
                }
            }

            Dictionary <int, UserTalent> talents = new Dictionary <int, UserTalent>();

            if (talentsTable != null)
            {
                foreach (DataRow row in talentsTable.Rows)
                {
                    int num2  = (int)row["talent_id"];
                    int state = (int)row["talent_state"];

                    talents.Add(num2, new UserTalent(num2, state));
                }
            }

            Dictionary <string, Subscription> subscriptions = new Dictionary <string, Subscription>();

            foreach (DataRow dataRow in Subscriptions.Rows)
            {
                string str        = (string)dataRow["subscription_id"];
                int    TimeExpire = (int)dataRow["timestamp_expire"];

                subscriptions.Add(str, new Subscription(str, TimeExpire));
            }


            Habbo user = HabboFactory.GenerateHabbo(dUserInfo, UserInfo);

            dUserInfo       = null;
            dAchievements   = null;
            dFavouriteRooms = null;
            dIgnores        = null;
            dBadges         = null;
            dEffects        = null;
            dFriends        = null;
            dRequests       = null;
            dRooms          = null;
            dRelations      = null;

            errorCode = 0;
            return(new UserData(UserId, Achievements, favouritedRooms, ignores, badges, friends, requests, rooms, quests, user, Relationships, talents, subscriptions));
        }
        public void InitBots()
        {
            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`room_id`,`name`,`motto`,`look`,`x`,`y`,`z`,`rotation`,`gender`,`user_id`,`ai_type`,`walk_mode`,`automatic_chat`,`speaking_interval`,`mix_sentences`,`chat_bubble` FROM `bots` WHERE `room_id` = '" + RoomId + "' AND `ai_type` != 'pet'");
                DataTable Data = dbClient.getTable();
                if (Data == null)
                {
                    return;
                }

                foreach (DataRow Bot in Data.Rows)
                {
                    dbClient.SetQuery("SELECT `text` FROM `bots_speech` WHERE `bot_id` = '" + Convert.ToInt32(Bot["id"]) + "'");
                    DataTable BotSpeech = dbClient.getTable();

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

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

                    _roomUserManager.DeployBot(new RoomBot(Convert.ToInt32(Bot["id"]), Convert.ToInt32(Bot["room_id"]), Convert.ToString(Bot["ai_type"]), Convert.ToString(Bot["walk_mode"]), Convert.ToString(Bot["name"]), Convert.ToString(Bot["motto"]), Convert.ToString(Bot["look"]), int.Parse(Bot["x"].ToString()), int.Parse(Bot["y"].ToString()), int.Parse(Bot["z"].ToString()), int.Parse(Bot["rotation"].ToString()), 0, 0, 0, 0, ref Speeches, "M", 0, Convert.ToInt32(Bot["user_id"].ToString()), Convert.ToBoolean(Bot["automatic_chat"]), Convert.ToInt32(Bot["speaking_interval"]), QuasarEnvironment.EnumToBool(Bot["mix_sentences"].ToString()), Convert.ToInt32(Bot["chat_bubble"])), null);
                }
            }
        }
        public void Init()
        {
            if (_games.Count > 0)
            {
                _games.Clear();
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable GetData = null;
                dbClient.SetQuery("SELECT `id`,`name`,`colour_one`,`colour_two`,`resource_path`,`string_three`,`game_swf`,`game_assets`,`game_server_host`,`game_server_port`,`socket_policy_port`,`game_enabled` FROM `games_config`");
                GetData = dbClient.getTable();

                if (GetData != null)
                {
                    foreach (DataRow Row in GetData.Rows)
                    {
                        this._games.Add(Convert.ToInt32(Row["id"]), new GameData(Convert.ToInt32(Row["id"]), Convert.ToString(Row["name"]), Convert.ToString(Row["colour_one"]), Convert.ToString(Row["colour_two"]), Convert.ToString(Row["resource_path"]), Convert.ToString(Row["string_three"]), Convert.ToString(Row["game_swf"]), Convert.ToString(Row["game_assets"]), Convert.ToString(Row["game_server_host"]), Convert.ToString(Row["game_server_port"]), Convert.ToString(Row["socket_policy_port"]), QuasarEnvironment.EnumToBool(Row["game_enabled"].ToString())));
                    }
                }
            }

            string CurrentTime = DateTime.Now.ToString("HH:mm:ss" + " | ");

            Console.WriteLine(CurrentTime + "» Hotel Datamanagement");
        }