Exemplo n.º 1
0
        public Habbo(int Id, string Username, int Rank, string Motto, string Look, string Gender, int Credits, int ActivityPoints, int HomeRoom,
                     bool HasFriendRequestsDisabled, int LastOnline, bool AppearOffline, bool HideInRoom, double CreateDate, int Diamonds,
                     string machineID, string clientVolume, bool ChatPreference, bool FocusPreference, bool PetsMuted, bool BotsMuted, bool AdvertisingReportBlocked, double LastNameChange,
                     int GOTWPoints, bool IgnoreInvites, double TimeMuted, double TradingLock, bool AllowGifts, int FriendBarState, bool DisableForcedEffects, bool AllowMimic, int VIPRank)
        {
            this.Id         = Id;
            this.Username   = Username;
            this.Rank       = Rank;
            this.Motto      = Motto;
            this.Look       = Look;
            this.Gender     = Gender.ToLower();
            FootballLook    = HabboUtilities.FilterFigure(Look.ToLower());
            FootballGender  = Gender.ToLower();
            this.Credits    = Credits;
            Duckets         = ActivityPoints;
            this.Diamonds   = Diamonds;
            this.GOTWPoints = GOTWPoints;
            this.HomeRoom   = HomeRoom;
            this.LastOnline = LastOnline;
            AccountCreated  = CreateDate;
            ClientVolume    = new List <int>();
            foreach (var Str in clientVolume.Split(','))
            {
                var Val = 0;
                if (int.TryParse(Str, out Val))
                {
                    ClientVolume.Add(int.Parse(Str));
                }
                else
                {
                    ClientVolume.Add(100);
                }
            }

            this.LastNameChange  = LastNameChange;
            MachineId            = machineID;
            this.ChatPreference  = ChatPreference;
            this.FocusPreference = FocusPreference;
            IsExpert             = IsExpert;

            this.AppearOffline    = AppearOffline;
            AllowTradingRequests  = true;                      //TODO
            AllowUserFollowing    = true;                      //TODO
            AllowFriendRequests   = HasFriendRequestsDisabled; //TODO
            AllowMessengerInvites = IgnoreInvites;
            AllowPetSpeech        = PetsMuted;
            AllowBotSpeech        = BotsMuted;
            AllowPublicRoomStatus = HideInRoom;
            AllowConsoleMessages  = true;
            this.AllowGifts       = AllowGifts;
            this.AllowMimic       = AllowMimic;
            ReceiveWhispers       = true;
            IgnorePublicWhispers  = false;
            PlayingFastFood       = false;
            FriendbarState        = FriendBarStateUtility.GetEnum(FriendBarState);
            ChristmasDay          = ChristmasDay;
            WantsToRideHorse      = 0;
            TimeAFK = 0;
            this.DisableForcedEffects = DisableForcedEffects;
            this.VIPRank = VIPRank;

            _disconnected = false;
            _habboSaved   = false;
            ChangingName  = false;

            FloodTime      = 0;
            FriendCount    = 0;
            this.TimeMuted = TimeMuted;
            _timeCached    = DateTime.Now;

            TradingLockExpiry = TradingLock;
            if (TradingLockExpiry > 0 && UnixUtilities.GetNow() > TradingLockExpiry)
            {
                TradingLockExpiry = 0;
                using (var dbClient = Program.DatabaseManager.GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '0' WHERE `user_id` = '" + Id + "' LIMIT 1");
                }
            }

            BannedPhraseCount  = 0;
            SessionStart       = UnixUtilities.GetNow();
            MessengerSpamCount = 0;
            MessengerSpamTime  = 0;
            CreditsUpdateTick  = Convert.ToInt32(Program.SettingsManager.TryGetValue("user.currency_scheduler.tick"));

            TentId            = 0;
            HopperId          = 0;
            IsHopping         = false;
            TeleporterId      = 0;
            IsTeleporting     = false;
            TeleportingRoomID = 0;
            RoomAuthOk        = false;
            CurrentRoomId     = 0;

            HasSpoken                  = false;
            LastAdvertiseReport        = 0;
            AdvertisingReported        = false;
            AdvertisingReportedBlocked = AdvertisingReportBlocked;

            WiredInteraction   = false;
            QuestLastCompleted = 0;
            InventoryAlert     = false;
            IgnoreBobbaFilter  = false;
            WiredTeleporting   = false;
            CustomBubbleId     = 0;
            OnHelperDuty       = false;
            FastfoodScore      = 0;
            PetId   = 0;
            TempInt = 0;

            LastGiftPurchaseTime       = DateTime.Now;
            LastMottoUpdateTime        = DateTime.Now;
            LastClothingUpdateTime     = DateTime.Now;
            LastForumMessageUpdateTime = DateTime.Now;

            GiftPurchasingWarnings = 0;
            MottoUpdateWarnings    = 0;
            ClothingUpdateWarnings = 0;

            SessionGiftBlocked     = false;
            SessionMottoBlocked    = false;
            SessionClothingBlocked = false;

            FavoriteRooms = new ArrayList();
            Achievements  = new ConcurrentDictionary <string, UserAchievement>();
            Relationships = new Dictionary <int, Relationship>();
            RatedRooms    = new List <int>();

            //TODO: Nope.
            InitPermissions();

            #region Stats
            DataRow StatRow = null;
            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                dbClient.AddParameter("user_id", Id);
                StatRow = dbClient.GetRow();

                if (StatRow == null)//No row, add it yo
                {
                    dbClient.RunQuery("INSERT INTO `user_stats` (`id`) VALUES ('" + Id + "')");
                    dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                    dbClient.AddParameter("user_id", Id);
                    StatRow = dbClient.GetRow();
                }

                try
                {
                    _habboStats = new HabboStats(Convert.ToInt32(StatRow["roomvisits"]), Convert.ToDouble(StatRow["onlineTime"]), Convert.ToInt32(StatRow["respect"]), Convert.ToInt32(StatRow["respectGiven"]), Convert.ToInt32(StatRow["giftsGiven"]),
                                                 Convert.ToInt32(StatRow["giftsReceived"]), Convert.ToInt32(StatRow["dailyRespectPoints"]), Convert.ToInt32(StatRow["dailyPetRespectPoints"]), Convert.ToInt32(StatRow["AchievementScore"]),
                                                 Convert.ToInt32(StatRow["quest_id"]), Convert.ToInt32(StatRow["quest_progress"]), Convert.ToInt32(StatRow["groupid"]), Convert.ToString(StatRow["respectsTimestamp"]), Convert.ToInt32(StatRow["forum_posts"]));

                    if (Convert.ToString(StatRow["respectsTimestamp"]) != DateTime.Today.ToString("MM/dd"))
                    {
                        _habboStats.RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                        SubscriptionData SubData = null;

                        var DailyRespects = 10;

                        if (_permissions.HasRight("mod_tool"))
                        {
                            DailyRespects = 20;
                        }
                        else if (Program.GameContext.GetSubscriptionManager().TryGetSubscriptionData(VIPRank, out SubData))
                        {
                            DailyRespects = SubData.Respects;
                        }

                        _habboStats.DailyRespectPoints    = DailyRespects;
                        _habboStats.DailyPetRespectPoints = DailyRespects;

                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + DailyRespects + "', `dailyPetRespectPoints` = '" + DailyRespects + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "' WHERE `id` = '" + Id + "' LIMIT 1");
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }

            Group G = null;
            if (!Program.GameContext.GetGroupManager().TryGetGroup(_habboStats.FavouriteGroupId, out G))
            {
                _habboStats.FavouriteGroupId = 0;
            }
            #endregion
        }
Exemplo n.º 2
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            var gender = packet.PopString().ToUpper();
            var look   = Program.FigureManager.ProcessFigure(packet.PopString(), gender, session.GetHabbo().GetClothing().GetClothingParts, true);

            if (look == session.GetHabbo().Look)
            {
                return;
            }

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

                return;
            }

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

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

            string[] allowedGenders = { "M", "F" };
            if (!allowedGenders.Contains(gender))
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Sorry, you chose an invalid gender."));
                return;
            }

            Program.GameContext.GetQuestManager().ProgressUserQuest(session, QuestType.ProfileChangeLook);

            session.GetHabbo().Look   = HabboUtilities.FilterFigure(look);
            session.GetHabbo().Gender = gender.ToLower();

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `users` SET `look` = @look, `gender` = @gender WHERE `id` = '" + session.GetHabbo().Id + "' LIMIT 1");
                dbClient.AddParameter("look", look);
                dbClient.AddParameter("gender", gender);
                dbClient.RunQuery();
            }

            Program.GameContext.GetAchievementManager().ProgressAchievement(session, "ACH_AvatarLooks", 1);
            session.SendPacket(new AvatarAspectUpdateComposer(look, gender));
            if (session.GetHabbo().Look.Contains("ha-1006"))
            {
                Program.GameContext.GetQuestManager().ProgressUserQuest(session, QuestType.WearHat);
            }

            if (session.GetHabbo().InRoom)
            {
                var roomUser = session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);
                if (roomUser != null)
                {
                    session.SendPacket(new UserChangeComposer(roomUser, true));
                    session.GetHabbo().CurrentRoom.SendPacket(new UserChangeComposer(roomUser, false));
                }
            }
        }