Пример #1
0
        public MoodlightData(int ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row = null;

            using (IQueryAdapter dbClient = NeonEnvironment.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 = NeonEnvironment.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       = NeonEnvironment.EnumToBool(Row["enabled"].ToString());
            CurrentPreset = Convert.ToInt32(Row["current_preset"]);
            Presets       = new List <MoodlightPreset>
            {
                GeneratePreset(Convert.ToString(Row["preset_one"])),
                GeneratePreset(Convert.ToString(Row["preset_two"])),
                GeneratePreset(Convert.ToString(Row["preset_three"]))
            };
        }
Пример #2
0
        public void OnNewFriendship(int friendID)
        {
            GameClient friend = NeonEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;

            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = NeonEnvironment.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"]),
                                               NeonEnvironment.EnumToBool(dRow["hide_online"].ToString()), NeonEnvironment.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));
        }
Пример #3
0
        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]), NeonEnvironment.EnumToBool(Bits[2])));
        }
Пример #4
0
 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"]), NeonEnvironment.EnumToBool(Row["block_newfriends"].ToString()), Convert.ToInt32(Row["last_online"]),
                      NeonEnvironment.EnumToBool(Row["hide_online"].ToString()), NeonEnvironment.EnumToBool(Row["hide_inroom"].ToString()),
                      Convert.ToDouble(Row["account_created"]), Convert.ToInt32(Row["vip_points"]), Convert.ToString(Row["machine_id"]), Convert.ToString(Row["volume"]),
                      NeonEnvironment.EnumToBool(Row["chat_preference"].ToString()), NeonEnvironment.EnumToBool(Row["focus_preference"].ToString()), NeonEnvironment.EnumToBool(Row["pets_muted"].ToString()), NeonEnvironment.EnumToBool(Row["bots_muted"].ToString()),
                      NeonEnvironment.EnumToBool(Row["advertising_report_blocked"].ToString()), Convert.ToDouble(Row["last_change"].ToString()), Convert.ToInt32(Row["gotw_points"]), Convert.ToInt32(Row["user_points"]),
                      NeonEnvironment.EnumToBool(Convert.ToString(Row["ignore_invites"])), Convert.ToDouble(Row["time_muted"]), Convert.ToDouble(UserInfo["trading_locked"]),
                      NeonEnvironment.EnumToBool(Row["allow_gifts"].ToString()), Convert.ToInt32(Row["friend_bar_state"]), NeonEnvironment.EnumToBool(Row["disable_forced_effects"].ToString()),
                      NeonEnvironment.EnumToBool(Row["allow_mimic"].ToString()), Convert.ToInt32(Row["rank_vip"]), Convert.ToByte(Row["guia"].ToString()), Convert.ToByte(Row["publi"].ToString()), Convert.ToByte(Row["builder"].ToString()), Convert.ToByte(Row["croupier"].ToString()), (Row["nux_user"].ToString() == "true"), Convert.ToByte(Row["targeted_buy"]), Convert.ToString(Row["namecolor"]), Convert.ToString(Row["tag"]), Convert.ToString(Row["tagcolor"]), Convert.ToByte(Row["changename"]), Convert.ToString(Row["pin_client"]), Convert.ToInt32(Row["cata_rank"])));
 }
Пример #5
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 = NeonEnvironment.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;
                }
            }

            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"]);
            RollerSpeed         = Convert.ToInt32(Row["roller_speed"]);

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

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

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

            PushEnabled    = NeonEnvironment.EnumToBool(Row["push_enabled"].ToString());
            PullEnabled    = NeonEnvironment.EnumToBool(Row["pull_enabled"].ToString());
            SPushEnabled   = NeonEnvironment.EnumToBool(Row["spush_enabled"].ToString());
            SPullEnabled   = NeonEnvironment.EnumToBool(Row["spull_enabled"].ToString());
            EnablesEnabled = NeonEnvironment.EnumToBool(Row["enables_enabled"].ToString());
            RespectNotificationsEnabled = NeonEnvironment.EnumToBool(Row["respect_notifications_enabled"].ToString());
            PetMorphsAllowed            = NeonEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString());
            Shoot     = Convert.ToInt32(Row["shoot"]);
            HideWired = NeonEnvironment.EnumToBool(Row["hide_wired"].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 = NeonEnvironment.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);

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

                dbClient.SetQuery("SELECT * FROM wired_scorebord WHERE roomid = @id ORDER BY `punten` DESC ");
                dbClient.AddParameter("id", 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") || WiredScoreBordDay.ContainsKey(userid) ? false : !SuperCheck[0]))
                    {
                        if (timestamp != getdaytoday)
                        {
                            SuperCheck[0] = false;
                        }
                        if (!SuperCheck[0])
                        {
                            WiredScoreBordDay.Add(userid, new KeyValuePair <int, string>(Punten, username));
                        }
                    }
                    if ((!(soort == "month") || WiredScoreBordMonth.ContainsKey(userid) ? false : !SuperCheck[1]))
                    {
                        if (timestamp != getmonthtoday)
                        {
                            SuperCheck[1] = false;
                        }
                        WiredScoreBordMonth.Add(userid, new KeyValuePair <int, string>(Punten, username));
                    }
                    if ((!(soort == "week") || WiredScoreBordWeek.ContainsKey(userid) ? false : !SuperCheck[2]))
                    {
                        if (timestamp != getweektoday)
                        {
                            SuperCheck[2] = false;
                        }
                        WiredScoreBordWeek.Add(userid, new KeyValuePair <int, string>(Punten, username));
                    }
                }
                if (SuperCheck[0])
                {
                    dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", Id, "' AND `soort`='day'"));
                    WiredScoreBordDay.Clear();
                }
                if (SuperCheck[1])
                {
                    dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", Id, "' AND `soort`='month'"));
                    WiredScoreBordMonth.Clear();
                }
                if (SuperCheck[2])
                {
                    dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", Id, "' AND `soort`='week'"));
                    WiredScoreBordDay.Clear();
                }
            }
        }
Пример #6
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

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

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

            string Name = Packet.PopString();

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

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

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

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

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

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

            int TradeSettings       = Packet.PopInt();//2 = All can trade, 1 = owner only, 0 = no trading.
            int AllowPets           = Convert.ToInt32(NeonEnvironment.BoolToEnum(Packet.PopBoolean()));
            int AllowPetsEat        = Convert.ToInt32(NeonEnvironment.BoolToEnum(Packet.PopBoolean()));
            int RoomBlockingEnabled = Convert.ToInt32(NeonEnvironment.BoolToEnum(Packet.PopBoolean()));
            int Hidewall            = Convert.ToInt32(NeonEnvironment.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 (!NeonEnvironment.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.RoomData.AllowPets           = AllowPets;
            Room.RoomData.AllowPetsEating     = AllowPetsEat;
            Room.RoomData.RoomBlockingEnabled = RoomBlockingEnabled;
            Room.RoomData.Hidewall            = Hidewall;

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

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

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

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

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

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

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

            Room.TradeSettings = TradeSettings;

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

            Room.RoomData.TradeSettings = TradeSettings;
            _ = Password.Length > 0 ? "password" : "open";
            string AccessStr;

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

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

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

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

            Room.GetGameMap().GenerateMaps();

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

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

            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModDoorModeSeen", 1);
            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModWalkthroughSeen", 1);
            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatScrollSpeedSeen", 1);
            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatFloodFilterSeen", 1);
            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatHearRangeSeen", 1);
        }
Пример #7
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            if (!NeonEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room 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("No puedes colocar al Bot aqui!");
                return;
            }

            if (!Session.GetHabbo().GetInventoryComponent().TryGetBot(BotId, out Bot 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("Lo siento, solo son un maximo de 5 bot por sala!");
                return;
            }

            //TODO: Hmm, maybe not????
            using (IQueryAdapter dbClient = NeonEnvironment.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 = NeonEnvironment.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, NeonEnvironment.EnumToBool(GetData["automatic_chat"].ToString()), Convert.ToInt32(GetData["speaking_interval"]), NeonEnvironment.EnumToBool(GetData["mix_sentences"].ToString()), Convert.ToInt32(GetData["chat_bubble"])), null);

            BotUser.ApplyEffect(187);
            BotUser.Chat("¡Hola " + Session.GetHabbo().Username + "!", false, 0);

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


            if (!Session.GetHabbo().GetInventoryComponent().TryRemoveBot(BotId, out Bot ToRemove))
            {
                Console.WriteLine("Error whilst removing Bot: " + ToRemove.Id);
                return;
            }
            Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots()));
        }
Пример #8
0
        public void Init(ItemDataManager ItemDataManager)
        {
            if (_pages.Count > 0)
            {
                _pages.Clear();
            }

            if (_bcpages.Count > 0)
            {
                _bcpages.Clear();
            }

            if (_botPresets.Count > 0)
            {
                _botPresets.Clear();
            }

            if (_items.Count > 0)
            {
                _items.Clear();
            }

            if (_bcitems.Count > 0)
            {
                _bcitems.Clear();
            }

            if (_deals.Count > 0)
            {
                _deals.Clear();
            }

            if (_predesignedItems.Count > 0)
            {
                _predesignedItems.Clear();
            }

            using (IQueryAdapter dbClient = NeonEnvironment.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` 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"]);
                        uint PredesignedId = Convert.ToUInt32(Row["predesigned_id"]);
                        if (BaseId == 0 && PredesignedId > 0)
                        {
                            PredesignedRooms.PredesignedRooms roomPack = _predesignedManager.predesignedRoom[PredesignedId];
                            if (roomPack == null)
                            {
                                continue;
                            }

                            if (roomPack.CatalogItems.Contains(";"))
                            {
                                Dictionary <int, int> cataItems = new Dictionary <int, int>();
                                string[] itemArray = roomPack.CatalogItems.Split(new char[] { ';' });
                                foreach (string item in itemArray)
                                {
                                    string[] items = item.Split(',');
                                    if (!ItemDataManager.GetItem(Convert.ToInt32(items[0]), out ItemData PredesignedData))
                                    {
                                        log.Error("Catalog Bundle " + ItemId + " has no furniture data.");
                                        continue;
                                    }

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

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

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

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

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

                        _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"]), NeonEnvironment.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"])));
                    }
                }


                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` FROM `catalog_bc_items`");
                DataTable BCCatalogueItems = dbClient.getTable();

                if (BCCatalogueItems != null)
                {
                    foreach (DataRow Row in BCCatalogueItems.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)
                        {
                            PredesignedRooms.PredesignedRooms roomPack = _predesignedManager.predesignedRoom[PredesignedId];
                            if (roomPack == null)
                            {
                                continue;
                            }

                            if (roomPack.CatalogItems.Contains(";"))
                            {
                                Dictionary <int, int> cataItems = new Dictionary <int, int>();
                                string[] itemArray = roomPack.CatalogItems.Split(new char[] { ';' });
                                foreach (string item in itemArray)
                                {
                                    string[] items = item.Split(',');
                                    if (!ItemDataManager.GetItem(Convert.ToInt32(items[0]), out ItemData PredesignedData))
                                    {
                                        log.Error("Couldn't load Catalog BC Item " + ItemId + ", no furniture record found. {2}");
                                        continue;
                                    }

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

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

                        ItemData Data = null;
                        if (PredesignedId <= 0)
                        {
                            if (!ItemDataManager.GetItem(BaseId, out Data))
                            {
                                log.Error("Couldn't load BC Item " + ItemId + ", no furniture record found. {1}");
                                continue;
                            }
                        }

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

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

                        _bcitems[PageId].Add(Convert.ToInt32(Row["id"]), new BCCatalogItem(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"]), NeonEnvironment.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"])));
                    }
                }


                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 (!_deals.ContainsKey(PageId))
                        {
                            _deals[PageId] = new Dictionary <int, CatalogDeal>();
                        }

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

                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_bc_pages` ORDER BY `order_num`");
                DataTable BCCatalogPages = dbClient.getTable();

                if (BCCatalogPages != null)
                {
                    foreach (DataRow Row in BCCatalogPages.Rows)
                    {
                        _bcpages.Add(Convert.ToInt32(Row["id"]), new BCCatalogPage(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"]),
                                                                                   _bcitems.ContainsKey(Convert.ToInt32(Row["id"])) ? _bcitems[Convert.ToInt32(Row["id"])] : new Dictionary <int, BCCatalogItem>(),
                                                                                   _deals.ContainsKey(Convert.ToInt32(Row["id"])) ? _deals[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogDeal>(),
                                                                                   _predesignedItems.ContainsKey(Convert.ToInt32(Row["id"])) ? _predesignedItems[Convert.ToInt32(Row["id"])] : null,
                                                                                   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])));
                    }
                }

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

            log.Info(">> Catalog Manager -> READY!");
        }
Пример #9
0
        public void LoadModels()
        {
            if (_roomModels.Count > 0)
            {
                _roomModels.Clear();
            }

            using (IQueryAdapter dbClient = NeonEnvironment.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"]);
                    _ = 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"]), NeonEnvironment.EnumToBool(Row["club_only"].ToString()), Convert.ToString(Row["poolmap"]), Convert.ToInt32(Row["wall_height"])));
                }
            }
        }
Пример #10
0
        /// <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 = NeonEnvironment.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 (_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"]), NeonEnvironment.EnumToBool(Row["is_activated"].ToString()), Convert.ToDouble(Row["activated_stamp"]), Convert.ToInt32(Row["quantity"]))))
                        {
                            //umm?
                        }
                    }
                }
            }

            _habbo         = Habbo;
            _currentEffect = 0;
            return(true);
        }
Пример #11
0
        public void Init()
        {
            if (_televisions.Count > 0)
            {
                _televisions.Clear();
            }

            DataTable getData = null;

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

                if (getData != null)
                {
                    foreach (DataRow Row in getData.Rows)
                    {
                        _televisions.Add(Convert.ToInt32(Row["id"]), new TelevisionItem(Convert.ToInt32(Row["id"]), Row["youtube_id"].ToString(), Row["title"].ToString(), Row["description"].ToString(), NeonEnvironment.EnumToBool(Row["enabled"].ToString())));
                    }
                }
            }
        }
Пример #12
0
        public bool RequestBuddy(string UserQuery)
        {
            int  userID;
            bool hasFQDisabled;

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

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = NeonEnvironment.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 = NeonEnvironment.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 = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("REPLACE INTO `messenger_requests` (`from_id`,`to_id`) VALUES ('" + _userId + "','" + ToId + "')");
            }

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

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

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

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

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

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

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

            _requests.Add(ToId, Request);
            return(true);
        }
Пример #13
0
        public static UserData GetUserData(string SessionTicket, out byte errorCode)
        {
            int       UserId;
            DataRow   dUserInfo       = null;
            DataTable dAchievements   = null;
            DataTable dFavouriteRooms = null;
            DataTable dTags           = null;
            DataTable dMystic         = 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 = NeonEnvironment.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 (NeonEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId) != null)
                {
                    errorCode = 2;
                    NeonEnvironment.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 `tag_name` FROM user_tags WHERE `user_id` = '" + UserId + "'");
                dTags = dbClient.getTable();

                dbClient.SetQuery("SELECT * FROM user_mystic_data WHERE `user_id` = '" + UserId + "'");
                dMystic = 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");
                dbClient.RunQuery("DELETE FROM `user_auth_ticket` WHERE `user_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 <string> tags = new List <string>();

            foreach (DataRow dRow in dTags.Rows)
            {
                tags.Add(Convert.ToString(dRow["tag_name"]));
            }

            List <string> mystic_keys = new List <string>();

            foreach (DataRow dRow in dMystic.Rows)
            {
                mystic_keys.Add(Convert.ToString(dRow["mystic_keys"]));
            }

            List <string> mystic_boxes = new List <string>();

            foreach (DataRow dRow in dMystic.Rows)
            {
                mystic_boxes.Add(Convert.ToString(dRow["mystic_boxes"]));
            }

            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 = NeonEnvironment.EnumToBool(dRow["hide_online"].ToString());
                bool   friendHideRoom   = NeonEnvironment.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(NeonEnvironment.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 <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;
            dTags           = null;
            dMystic         = null;

            errorCode = 0;
            return(new UserData(UserId, Achievements, favouritedRooms, tags, mystic_boxes, mystic_keys, ignores, badges, friends, requests, rooms, quests, user, Relationships, subscriptions));
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            if (Room.GetGameMap().Model == null)
            {
                return;
            }

            List <Point> Squares = new List <Point>();

            Room.GetRoomItemHandler().GetFloor.ToList().ForEach(Item =>
            {
                Item.GetCoords.ForEach(Point =>
                {
                    if (!Squares.Contains(Point))
                    {
                        Squares.Add(Point);
                    }
                });
            });

            Session.SendMessage(new FloorPlanFloorMapComposer(Squares));
            Session.SendMessage(new FloorPlanSendDoorComposer(Room.GetGameMap().Model.DoorX, Room.GetGameMap().Model.DoorY, Room.GetGameMap().Model.DoorOrientation));
            Session.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, NeonEnvironment.EnumToBool(Room.Hidewall.ToString())));

            Squares.Clear();
            Squares = null;
        }
Пример #15
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)
            {
                if (!NeonEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room OldRoom))
                {
                    return;
                }

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

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

            Room.SendObjects(Session);

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

            if (Session.GetHabbo().GetStats().QuestID > 0)
            {
                NeonEnvironment.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, NeonEnvironment.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));
            }

            if (!Session.GetHabbo().Effects().HasEffect(0) && Session.GetHabbo().Rank < 2)
            {
                Session.GetHabbo().Effects().ApplyEffect(0);
            }

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

            if (Session.GetHabbo().Rank > 7 && !Session.GetHabbo().StaffOk)
            {
                Session.SendMessage(new GnomeBoxComposer(0));
            }

            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("Esta Sala esta en venta, en " + Room.SalePrice + " Duckets. Escribe :buyroom si deseas comprarla!");
            }
            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("Esta Sala ya no se encuentra a la venta.");
                    }
                }
                Room.ForSale   = false;
                Room.SalePrice = 0;
            }

            if (NeonEnvironment.GetGame().GetPollManager().TryGetPollForRoom(Room.Id, out RoomPoll poll))
            {
                if (poll.Type == RoomPollType.Poll)
                {
                    Session.SendMessage(new PollOfferComposer(poll));
                }
            }

            if (NeonEnvironment.GetUnixTimestamp() < Session.GetHabbo().FloodTime&& Session.GetHabbo().FloodTime != 0)
            {
                Session.SendMessage(new FloodControlComposer((int)Session.GetHabbo().FloodTime - (int)NeonEnvironment.GetUnixTimestamp()));
            }
        }
Пример #16
0
        public void Init()
        {
            if (_games.Count > 0)
            {
                _games.Clear();
            }

            if (_leaderBoardData.Count > 0)
            {
                _leaderBoardData.Clear();
            }

            using (IQueryAdapter dbClient = NeonEnvironment.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)
                    {
                        using (IQueryAdapter dbClient2 = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            DataTable GetLeaderData = null;
                            dbClient2.SetQuery("SELECT * FROM `games_leaderboard` WHERE game_id = " + Convert.ToInt32(Row["id"]) + " ORDER BY points ASC");
                            GetLeaderData = dbClient2.getTable();

                            if (GetLeaderData != null)
                            {
                                foreach (DataRow Rows in GetLeaderData.Rows)
                                {
                                    LeaderBoardData value = new LeaderBoardData(Convert.ToInt32(Rows["game_id"]), Convert.ToInt32(Rows["user_id"]), Convert.ToInt32(Rows["points"]), Convert.ToInt32(Rows["record"]), Convert.ToInt32(Rows["week"]), Convert.ToInt32(Rows["year"]));
                                    _leaderBoardData.Add(Convert.ToInt32(Rows["id"]), value);
                                }
                            }
                            _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"]), NeonEnvironment.EnumToBool(Row["game_enabled"].ToString()), _leaderBoardData));
                        }
                    }
                }
            }

            log.Info(">> GameCenter Manager -> READY!");
        }
Пример #17
0
        public void Init()
        {
            if (_items.Count > 0)
            {
                _items.Clear();
            }

            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * 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          = NeonEnvironment.EnumToBool(Row["can_stack"].ToString());
                            bool            allowWalk           = NeonEnvironment.EnumToBool(Row["is_walkable"].ToString());
                            bool            allowSit            = NeonEnvironment.EnumToBool(Row["can_sit"].ToString());
                            bool            allowRecycle        = NeonEnvironment.EnumToBool(Row["allow_recycle"].ToString());
                            bool            allowTrade          = NeonEnvironment.EnumToBool(Row["allow_trade"].ToString());
                            bool            allowMarketplace    = Convert.ToInt32(Row["allow_marketplace_sell"]) == 1;
                            bool            allowGift           = Convert.ToInt32(Row["allow_gift"]) == 1;
                            bool            allowInventoryStack = NeonEnvironment.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              = NeonEnvironment.EnumToBool(Row["is_rare"].ToString());
                            int             ClothingId          = Convert.ToInt32(Row["clothing_id"]);
                            bool            ExtraRot            = NeonEnvironment.EnumToBool(Row["extra_rot"].ToString());
                            int             SongID              = Convert.ToInt32(Row["song_Id"]);

                            if (!_gifts.ContainsKey(spriteID))
                            {
                                _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, SongID));
                            }

                            if (!_items.ContainsKey(id))
                            {
                                _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, SongID));
                            }
                        }
                        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.");
                        }
                    }
                }
            }

            log.Info(">> Items Manager -> READY!");
        }
Пример #18
0
        public void LoadModel(string Id)
        {
            DataRow Row = null;

            using (IQueryAdapter dbClient = NeonEnvironment.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 (!_roomModels.ContainsKey(Id))
                {
                    _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"]), NeonEnvironment.EnumToBool(Row["club_only"].ToString()), Convert.ToString(Row["poolmap"]), Convert.ToInt32(Row["wall_height"])));
                }
            }
        }