Пример #1
0
        public HabboUserBadgesComposer(Habbo Habbo, RoleplayBot Bot = null)
            : base(ServerPacketHeader.HabboUserBadgesMessageComposer)
        {
            if (Bot != null)
            {
                base.WriteInteger(Bot.Id + 1000000);
                base.WriteInteger(1);
                base.WriteInteger(1);
                base.WriteString("BOT");
            }
            else
            {
                base.WriteInteger(Habbo.Id);
                base.WriteInteger(Habbo.GetBadgeComponent().EquippedCount);

                foreach (Badge Badge in Habbo.GetBadgeComponent().GetBadges().ToList())
                {
                    if (Badge.Slot <= 0)
                    {
                        continue;
                    }

                    base.WriteInteger(Badge.Slot);
                    base.WriteString(Badge.Code);
                }
            }
        }
Пример #2
0
        public HabboUserBadgesComposer(Habbo habbo)
            : base(ServerPacketHeader.HabboUserBadgesMessageComposer)
        {
            WriteInteger(habbo.Id);
            WriteInteger(habbo.GetBadgeComponent().EquippedCount);

            foreach (Badge badge in habbo.GetBadgeComponent().GetBadges().Where(b => b.Slot > 0).ToList())
            {
                WriteInteger(badge.Slot);
                WriteString(badge.Code);
            }
        }
Пример #3
0
        public HabboUserBadgesComposer(Habbo habbo)
            : base(ServerPacketHeader.HabboUserBadgesMessageComposer)
        {
            WriteInteger(habbo.Id);
            WriteInteger(habbo.GetBadgeComponent().EquippedCount);

            foreach (var badge in habbo.GetBadgeComponent().GetBadges().ToList())
            {
                if (badge.Slot <= 0)
                {
                    continue;
                }

                WriteInteger(badge.Slot);
                WriteString(badge.Code);
            }
        }
Пример #4
0
        public HabboUserBadgesComposer(Habbo Habbo)
            : base(ServerPacketHeader.HabboUserBadgesMessageComposer)
        {
            base.WriteInteger(Habbo.Id);
            base.WriteInteger(Habbo.GetBadgeComponent().EquippedCount);

            foreach (Badge Badge in Habbo.GetBadgeComponent().GetBadges().ToList())
            {
                if (Badge.Slot <= 0)
                {
                    continue;
                }

                base.WriteInteger(Badge.Slot);
                base.WriteString(Badge.Code);
            }
        }
Пример #5
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = RavenEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            if (Player.GetBadgeComponent().HasBadge(StringData))
            {
                Player.GetClient().SendNotification("Parece que ya has obtenido esta placa, revisa tu inventario.");
            }
            else
            {
                Player.GetBadgeComponent().GiveBadge(StringData, true, Player.GetClient());
                Player.GetClient().SendNotification("¡Acabas de recibir una placa!");
            }

            return(true);
        }
Пример #6
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = BiosEmuThiago.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            if (Player.GetBadgeComponent().HasBadge(StringData))
            {
                Player.GetClient().SendNotification("Parece que você já tem esse emblema no inventário .");
            }
            else
            {
                Player.GetBadgeComponent().GiveBadge(StringData, true, Player.GetClient());
                Player.GetClient().SendMessage(RoomNotificationComposer.SendBubble("badge/" + Params[2], "Acaba de receber um emblema!", "/inventory/open/badge"));
            }

            return(true);
        }
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = QuasarEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            if (Player.GetBadgeComponent().HasBadge(StringData))
            {
                Player.GetClient().SendNotification("Oeps! Je hebt een Badge ontvangen die je al in je inventaris hebt staan.");
            }
            else
            {
                Player.GetBadgeComponent().GiveBadge(StringData, true, Player.GetClient());
                Player.GetClient().SendNotification("Je hebt een Badge ontvangen!");
            }

            return(true);
        }
Пример #8
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = PlusEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Id);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            if (Player.GetBadgeComponent().HasBadge(StringData))
            {
                Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Parece que você já recebeu este emblema!", 0, User.LastBubble));
            }
            else
            {
                Player.GetBadgeComponent().GiveBadge(StringData, true, Player.GetClient());
                Player.GetClient().SendNotification("Você recebeu um Emblema!");
            }

            return(true);
        }
Пример #9
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = PlusEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            if (Player.GetBadgeComponent().HasBadge(StringData))
            {
                Player.GetClient().SendPacket(new WhisperComposer(User.VirtualId, "Oops, it appears you have already recieved this badge!", 0, User.LastBubble));
            }
            else
            {
                Player.GetBadgeComponent().GiveBadge(StringData, true, Player.GetClient());
                Player.GetClient().SendNotification("You have recieved a badge!");
            }

            return(true);
        }
Пример #10
0
        public bool Execute(params object[] Params)
        {
            if (Params.Length == 0)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(this.StringData))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

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

            if (!Player.GetBadgeComponent().GetBadges().Contains(Player.GetBadgeComponent().GetBadge(this.StringData)))
            {
                return(true);
            }

            foreach (Badge Badge in Player.GetBadgeComponent().GetBadges().ToList())
            {
                if (Badge.Slot <= 0)
                {
                    continue;
                }

                if (Badge.Code == this.StringData)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #11
0
        /// <summary>
        /// Actualiza el progreso una recompensa.
        /// </summary>
        /// <param name="Session"></param>
        /// <param name="UserId"></param>
        /// <param name="AchievementGroup"></param>
        /// <param name="ProgressAmount"></param>
        /// <returns></returns>
        public bool ProgressUserAchievement(uint UserId, string AchievementGroup, int ProgressAmount)
        {
            Habbo Habbo = UsersCache.getHabboCache(UserId);

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

            GameClient Session = Habbo.GetClient();

            Achievement AchievementData = GetAchievementByName(AchievementGroup);

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

            UserAchievement UserData = Habbo.GetAchievementData(AchievementGroup);

            if (UserData == null)
            {
                UserData = new UserAchievement(AchievementGroup, 0, 0);
                Habbo.Achievements.Add(AchievementGroup, UserData);
            }

            uint TotalLevels = (uint)AchievementData.Levels.Length;

            if (UserData.Level == TotalLevels)
            {
                return(false); // ya está todo completado
            }

            uint TargetLevel = UserData.Level + 1;

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

            uint TargetRequeriment = AchievementData.Levels[TargetLevel - 1];

            UserData.Progress += ProgressAmount;

            if (UserData.Progress >= TargetRequeriment)
            {
                UserData.Level++;

                if (TargetLevel == 1)
                {
                    Habbo.GetBadgeComponent().GiveBadge(AchievementGroup + TargetLevel);
                }
                else
                {
                    Habbo.GetBadgeComponent().UpdateBadge(AchievementGroup + TargetLevel);
                }

                Habbo.AchievementPoints += AchievementData.Reward;

                if (Session != null)
                {
                    Session.SendMessage(AchievementUnlockedComposer.Compose(AchievementData, TargetLevel, AchievementData.Reward));
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Habbo.AchievementPoints));
                }
            }

            if (Session != null)
            {
                Session.SendMessage(AchievementProgressComposer.Compose(AchievementData, UserData));
            }

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("REPLACE INTO user_achievements VALUES (" + Habbo.Id + ", @group, " + UserData.Level + ", " + UserData.Progress + ")");
                dbClient.addParameter("group", AchievementGroup);
                dbClient.runQuery();
            }

            if (Session == null)
            {
                Habbo.SaveBadges();
            }

            return(true);
        }
Пример #12
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (CloudServer.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (CloudServer.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    //Now let us check for a username ban record..
                    BanRecord = null;
                    if (CloudServer.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                    {
                        if (CloudServer.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                CloudServer.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo           = userData.user;
                _habbo.ssoTicket = AuthTicket;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts));
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer(CloudServer.GetGame().GetModerationManager().UserActionPresets));
                    SendMessage(new BadgeDefinitionsComposer(CloudServer.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));

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

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    if (CloudServer.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup))
                    {
                        if (!String.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    if (!CloudServer.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        CloudServer.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendMessage(new ModeratorInitComposer(
                                        CloudServer.GetGame().GetModerationManager().UserMessagePresets,
                                        CloudServer.GetGame().GetModerationManager().RoomMessagePresets,
                                        CloudServer.GetGame().GetModerationManager().GetTickets));
                    }

                    if (CloudServer.GetGame().GetSettingsManager().TryGetValue("user.login.message.enabled") == "1")
                    {
                        SendMessage(new MOTDNotificationComposer(CloudServer.GetGame().GetLanguageManager().TryGetValue("user.login.message")));
                    }

                    if (ExtraSettings.WELCOME_MESSAGE_ENABLED)
                    {
                        SendMessage(new MOTDNotificationComposer(ExtraSettings.WelcomeMessage.Replace("%username%", GetHabbo().Username)));
                    }



                    if (ExtraSettings.TARGETED_OFFERS_ENABLED)
                    {
                        if (CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                        {
                            CloudServer.GetGame().GetTargetedOffersManager().Initialize(CloudServer.GetDatabaseManager().GetQueryReactor());
                            TargetedOffers TargetedOffer = CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer;

                            if (TargetedOffer.Expire > CloudServer.GetIUnixTimestamp())
                            {
                                if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                                {
                                    SendMessage(CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                                }
                            }
                            else
                            {
                                using (var dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                                    dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'");
                                using (var dbClient2 = CloudServer.GetDatabaseManager().GetQueryReactor())
                                    dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0");
                            }
                        }
                    }

                    //SendMessage(new HCGiftsAlertComposer());



                    /*var nuxStatuss = new ServerPacket(ServerPacketHeader.NuxSuggestFreeGiftsMessageComposer);
                     * SendMessage(nuxStatuss);*/

                    CloudServer.GetGame().GetRewardManager().CheckRewards(this);
                    CloudServer.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this);
                    CloudServer.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this);
                    CloudServer.GetGame().GetAchievementManager().TryProgressLoginAchievements(this);
                    ICollection <MessengerBuddy> Friends = new List <MessengerBuddy>();
                    foreach (MessengerBuddy Buddy in GetHabbo().GetMessenger().GetFriends().ToList())
                    {
                        if (Buddy == null)
                        {
                            continue;
                        }

                        GameClient Friend = CloudServer.GetGame().GetClientManager().GetClientByUserID(Buddy.Id);
                        if (Friend == null)
                        {
                            continue;
                        }
                        string figure = GetHabbo().Look;
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (BiosEmuThiago.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (BiosEmuThiago.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    //Now let us check for a username ban record..
                    BanRecord = null;
                    if (BiosEmuThiago.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                    {
                        if (BiosEmuThiago.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                BiosEmuThiago.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo           = userData.user;
                _habbo.ssoTicket = AuthTicket;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts));
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer(BiosEmuThiago.GetGame().GetModerationManager().UserActionPresets));
                    SendMessage(new BadgeDefinitionsComposer(BiosEmuThiago.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));

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

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    if (BiosEmuThiago.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup))
                    {
                        if (!String.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    if (!BiosEmuThiago.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        BiosEmuThiago.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendMessage(new ModeratorInitComposer(
                                        BiosEmuThiago.GetGame().GetModerationManager().UserMessagePresets,
                                        BiosEmuThiago.GetGame().GetModerationManager().RoomMessagePresets,
                                        BiosEmuThiago.GetGame().GetModerationManager().GetTickets));
                    }

                    if (BiosEmuThiago.GetGame().GetSettingsManager().TryGetValue("user.login.message.enabled") == "1")
                    {
                        SendMessage(new MOTDNotificationComposer(BiosEmuThiago.GetGame().GetLanguageManager().TryGetValue("user.login.message")));
                    }

                    if (ExtraSettings.WELCOME_MESSAGE_ENABLED)
                    {
                        SendMessage(new MOTDNotificationComposer(ExtraSettings.WelcomeMessage.Replace("%username%", GetHabbo().Username)));
                    }

                    if (GetHabbo().Rank >= 3)
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `ranks` WHERE id = '" + GetHabbo().Rank + "'");
                            DataRow Table = dbClient.getRow();

                            if (GetHabbo().GetBadgeComponent().HasBadge(Convert.ToString(Table["badgeid"])))
                            {
                            }
                            else
                            {
                                GetHabbo().GetBadgeComponent().GiveBadge(Convert.ToString(Table["badgeid"]), true, GetHabbo().GetClient());
                                SendMessage(RoomNotificationComposer.SendBubble("badge/" + Table["badgeid"], "Você recebeu o emblema staff do seu rank!", "/inventory/open/badge"));
                            }
                        }
                    }

                    if (ExtraSettings.TARGETED_OFFERS_ENABLED)
                    {
                        if (BiosEmuThiago.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                        {
                            BiosEmuThiago.GetGame().GetTargetedOffersManager().Initialize(BiosEmuThiago.GetDatabaseManager().GetQueryReactor());
                            TargetedOffers TargetedOffer = BiosEmuThiago.GetGame().GetTargetedOffersManager().TargetedOffer;

                            if (TargetedOffer.Expire > BiosEmuThiago.GetIUnixTimestamp())
                            {
                                if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                                {
                                    SendMessage(BiosEmuThiago.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                                }
                            }
                            else
                            {
                                using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                                    dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'");
                                using (var dbClient2 = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                                    dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0");
                            }
                        }
                    }

                    // Fixe do Presentes do HC By Thiago Araujo
                    //DateTime dateGregorians = new DateTime();
                    //dateGregorians = DateTime.Today;
                    //int days = (dateGregorians.Day);
                    //if (30 == days)
                    //{
                    //    SendMessage(new HCGiftsAlertComposer());
                    //    SendMessage(new RoomNotificationComposer("sumando", "message", "Hoje é dia de presentes HC, pegue o seu antes que acabe!"));
                    //}

                    // Da a conquista de login por dia feito por Thiago Araujo
                    string dFrank = null;
                    using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("SELECT Datahoje FROM users WHERE id = '" + userData.user.GetClient().GetHabbo().Id + "' LIMIT 1");
                        dFrank = dbClient.getString();
                    }
                    int      dFrankInt     = Int32.Parse(dFrank);
                    DateTime dateGregorian = new DateTime();
                    dateGregorian = DateTime.Today;
                    int day = (dateGregorian.Day);
                    if (dFrankInt != day)
                    {
                        using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE users SET Datahoje = '" + day + "' WHERE id = " + GetHabbo().Id + ";");
                        }
                        BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_Login", 1);
                    }

                    if (ExtraSettings.STAFF_MENSG_ENTERTHIAGO)
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `ranks` WHERE id = '" + GetHabbo().Rank + "'");
                            DataRow Table = dbClient.getRow();

                            if (GetHabbo().Rank == 1)
                            {
                                // Thiago é muito lindo ser é doido
                            }
                            else
                            {
                                string figure = this.GetHabbo().Look;

                                BiosEmuThiago.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("fig/" + figure, 3, "O " + Convert.ToString(Table["name"]) + " " + userData.user.GetClient().GetHabbo().Username + " entrou no hotel!", ""));
                            }
                        }

                        if (GetHabbo().isMedal)
                        {
                            var nuxStatus = new ServerPacket(ServerPacketHeader.NuxUserStatus);
                            nuxStatus.WriteInteger(2);
                            SendMessage(nuxStatus);

                            string thiagolindogostoso = this.GetHabbo().Look;

                            BiosEmuThiago.GetGame().GetClientManager().StaffAlert(new RoomNotificationComposer("fig/" + thiagolindogostoso, 3, "Hey o usuário: " + GetHabbo().Username + " acaba de se registra no hotel.", ""));

                            if (GetHabbo().isMedal)
                            {
                                string thiago = this.GetHabbo().Look;

                                SendMessage(new RoomNotificationComposer("fig/" + thiago, 3, "Hey " + userData.user.GetClient().GetHabbo().Username + " Bem-vindo ao nosso hotel!", ""));
                            }


                            if (GetHabbo().isMedal == false)
                            {
                                string thiagolindo = this.GetHabbo().Look;

                                SendMessage(new RoomNotificationComposer("fig/" + thiagolindo, 3, "Hey " + userData.user.GetClient().GetHabbo().Username + " Bem-vindo de volta ao nosso hotel!", ""));
                            }
                        }
                    }

                    if (GetHabbo().Rank > Convert.ToInt32(BiosEmuThiago.GetConfig().data["MineRankStaff"]))
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE users SET prefix_name = '' WHERE id = '" + GetHabbo().Id + "'");
                            dbClient.RunQuery("UPDATE users SET prefix_name_color = '' WHERE id = '" + GetHabbo().Id + "'");
                        }
                        GetHabbo()._NamePrefixColor = "";
                        GetHabbo()._NamePrefix      = "";
                    }

                    if (GetHabbo().Rank > 0)
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `users` WHERE id = '" + GetHabbo().Id + "'");
                            DataRow Table = dbClient.getRow();

                            if (Convert.ToString(Table["LalaConf"]) == "0")
                            {
                                // Thiago é muito lindo ser é doido
                            }
                            else
                            {
                                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_TraderPass", 1);
                                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_AvatarTags", 1);
                                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_EmailVerification", 1);
                            }
                        }
                    }

                    if (GetHabbo().isMedal)
                    {
                        if (ExtraSettings.WELCOME_NEW_MESSAGE_ENABLED)
                        {
                            ServerPacket notif = new ServerPacket(ServerPacketHeader.NuxAlertMessageComposer);
                            notif.WriteString(ExtraSettings.WELCOME_MESSAGE_URL);
                            SendMessage(notif);
                        }
                        using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE users SET isMedal = '0' WHERE id = " + GetHabbo().Id + ";");
                        }
                        GetHabbo().isMedal = false;
                    }

                    BiosEmuThiago.GetGame().GetRewardManager().CheckRewards(this);
                    BiosEmuThiago.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this);
                    BiosEmuThiago.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this);
                    BiosEmuThiago.GetGame().GetAchievementManager().TryProgressLoginAchievements(this);
                    ICollection <MessengerBuddy> Friends = new List <MessengerBuddy>();
                    foreach (MessengerBuddy Buddy in GetHabbo().GetMessenger().GetFriends().ToList())
                    {
                        if (Buddy == null)
                        {
                            continue;
                        }

                        GameClient Friend = BiosEmuThiago.GetGame().GetClientManager().GetClientByUserID(Buddy.Id);
                        if (Friend == null)
                        {
                            continue;
                        }
                        string figure = GetHabbo().Look;

                        Friend.SendMessage(new RoomNotificationComposer("fig/" + figure, 3, this.GetHabbo().Username + ", seu amigo acabou de entrar no hotel!", ""));
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
Пример #14
0
        /// <summary>
        ///     Progresses the user achievement.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="achievementGroup">The achievement group.</param>
        /// <param name="progressAmount">The progress amount.</param>
        /// <param name="fromZero">if set to <c>true</c> [from zero].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool ProgressUserAchievement(GameClient session, string achievementGroup, uint progressAmount,
                                              bool fromZero = false)
        {
            if (Achievements.ContainsKey(achievementGroup) && session?.GetHabbo() != null)
            {
                Achievement achievement = Achievements[achievementGroup];

                Habbo user = session.GetHabbo();

                // Get UserAchievementData, if the user doesn't has the Achievement, create a new.
                UserAchievement userAchievement = user.Achievements.ContainsKey(achievementGroup)
                    ? user.GetAchievementData(achievementGroup)
                    : new UserAchievement(achievementGroup, 0, 0);

                // If is a New Achievement is fromZero
                if (!user.Achievements.ContainsKey(achievementGroup))
                {
                    fromZero = true;
                }

                // If user hasn't the Achievement, after created the new, Must add in Collections.
                if (!user.Achievements.ContainsKey(achievementGroup))
                {
                    user.Achievements.Add(achievementGroup, userAchievement);
                }

                // Get Achievement
                userAchievement = user.Achievements[achievementGroup];

                // Total Levels from this Achievement
                uint achievementLevelsCount = (uint)achievement.Levels.Count;

                // Get User Achievement Level
                uint achievementCurrentLevel = userAchievement.Level;

                // Get User Achievement Progress
                uint achievementCurrentProgress = userAchievement.Progress;

                // If the next Level is the last level must set to Levels.Count (Ex: 38 Levels => .Count = 37 (Max Level in the Array, but .Count 37 == 38, Soo need put Level - 1)
                uint achievementNextLevel = achievementCurrentLevel + 1 > achievementLevelsCount
                    ? achievementLevelsCount
                    : achievementCurrentLevel + 1;

                // Set Achievement Progress
                uint achievementProgress = achievementCurrentProgress + progressAmount;

                // If he has already the Max, something is wrong.
                if (achievementCurrentLevel == achievementLevelsCount)
                {
                    return(false);
                }

                // Get Next Level Data
                AchievementLevel achievementNextLevelData = achievement.Levels[achievementNextLevel];

                // if progress isn't sufficient or, isn't new Achievement
                if (achievementProgress < achievementNextLevelData.Requirement || achievementCurrentLevel >= 1)
                {
                    fromZero = false;
                }

                // If progress is sufficient to next level, or is new Achievement
                if (achievementProgress >= achievementNextLevelData.Requirement || (achievementCurrentLevel < 1))
                {
                    fromZero = true;
                }

                // if is a new level (but level isn't 0)
                if (achievementProgress >= achievementNextLevelData.Requirement)
                {
                    achievementProgress = 0;
                }

                // If is new Level
                if (fromZero)
                {
                    // Set Level
                    userAchievement.SetLevel(achievementNextLevel);

                    // Set Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Give Reward Points
                    user.AchievementPoints += achievementNextLevelData.RewardPoints;
                    user.NotifyNewPixels(achievementNextLevelData.RewardPixels);
                    user.Duckets += achievementNextLevelData.RewardPixels;

                    // Update Points Balance
                    user.UpdateActivityPointsBalance();

                    // Remove old Badge - (Is not problem if is First Level Badge, because if the user hasn't the badg, simply, will not remove.
                    user.GetBadgeComponent()
                    .RemoveBadge(Convert.ToString($"{achievementGroup}{achievementNextLevel - 1}"), session);

                    // Give new Badge
                    user.GetBadgeComponent().GiveBadge($"{achievementGroup}{achievementNextLevel}", true, session);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementNextLevel}', '{achievementProgress}')");

                    // Send Unlocked Composer
                    session.SendMessage(AchievementUnlockedComposer.Compose(achievement, achievementNextLevel,
                                                                            achievementNextLevelData.RewardPoints, achievementNextLevelData.RewardPixels));

                    // Send Score Composer
                    session.SendMessage(AchievementScoreUpdateComposer.Compose(user.AchievementPoints));

                    // Send Progress Composer
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementNextLevel,
                                                                            achievementNextLevelData, achievementLevelsCount, userAchievement));

                    // Set Talent
                    if (
                        Yupi.GetGame()
                        .GetTalentManager()
                        .Talents.Values.Any(talent => talent.AchievementGroup == achievementGroup))
                    {
                        Yupi.GetGame()
                        .GetTalentManager()
                        .CompleteUserTalent(session,
                                            Yupi.GetGame().GetTalentManager().GetTalentData(achievementGroup));
                    }
                }
                else
                {
                    // Get Current Level Data
                    AchievementLevel achievementCurrentLevelData = achievement.Levels[achievementCurrentLevel];

                    // It's the Same Level
                    userAchievement.SetLevel(achievementCurrentLevel);

                    // But increase Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementCurrentLevel}', '{achievementProgress}')");

                    // Compose Current Data
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementCurrentLevel,
                                                                            achievementCurrentLevelData, achievementLevelsCount, userAchievement));
                }

                // Send User New Data
                GameClientMessageHandler messageHandler = session.GetMessageHandler();

                messageHandler.GetResponse().Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
                messageHandler.GetResponse().AppendInteger(-1);
                messageHandler.GetResponse().AppendString(user.Look);
                messageHandler.GetResponse().AppendString(user.Gender.ToLower());
                messageHandler.GetResponse().AppendString(user.Motto);
                messageHandler.GetResponse().AppendInteger(user.AchievementPoints);

                messageHandler.SendResponse();

                return(true);
            }

            return(false);
        }
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = QuasarEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            int  amountLeft = int.Parse(this.StringData.Split('-')[2]);
            int  often      = int.Parse(this.StringData.Split('-')[1]);
            bool unique     = this.BoolData;

            bool premied = false;

            if (amountLeft == 1)
            {
                Player.GetClient().SendNotification("Ya no hay mas premios, vuelve mas tarde.");
                return(true);
            }

            foreach (var dataStr in (this.StringData.Split('-')[0]).Split(';'))
            {
                var dataArray = dataStr.Split(',');

                var isbadge    = dataArray[0] == "0";
                var code       = dataArray[1];
                var percentage = int.Parse(dataArray[2]);

                var random = QuasarEnvironment.GetRandomNumber(0, 100);

                if (!unique && percentage < random)
                {
                    continue;
                }
                premied = true;

                if (isbadge)
                {
                    if (Player.GetBadgeComponent().HasBadge(code))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Je hebt een Badge ontvangen die je al eerder in je inventaris had staan!", 0, User.LastBubble));
                    }
                    else
                    {
                        Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                        Player.GetClient().SendNotification("Je hebt een Badge ontvangen!");
                    }
                }
                else
                {
                    ItemData ItemData = null;

                    if (!QuasarEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Kon item niet laden: " + code, 0, User.LastBubble));
                        return(false);
                    }

                    Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                    if (Item != null)
                    {
                        Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                        Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                        Player.GetClient().SendMessage(new PurchaseOKComposer());
                        Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                        Player.GetClient().SendMessage(new FurniListUpdateComposer());
                        Player.GetClient().SendNotification("¡Has recibido un regalo! Revisa tu inventario.");
                    }
                }
            }

            if (!premied)
            {
                Player.GetClient().SendNotification("Mweh, volgende keer weer een kans.");
            }
            else if (amountLeft > 1)
            {
                amountLeft--;
                this.StringData.Split('-')[2] = amountLeft.ToString();
            }

            return(true);
        }
Пример #16
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking

                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (NeonEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (NeonEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (NeonEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                {
                    if (NeonEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                    {
                        Disconnect();
                        return(false);
                    }
                }

                #endregion

                NeonEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo = userData.user;


                if (_habbo != null)
                {
                    ssoTicket = AuthTicket;
                    userData.user.Init(this, userData);


                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts));
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));


                    //var habboClubSubscription = new ServerPacket(ServerPacketHeader.HabboClubSubscriptionComposer);
                    //habboClubSubscription.WriteString("club_habbo");
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(2);
                    //habboClubSubscription.WriteBoolean(false);
                    //habboClubSubscription.WriteBoolean(false);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //SendMessage(habboClubSubscription);

                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer());

                    SendMessage(new BadgeDefinitionsComposer(NeonEnvironment.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));

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

                    if (_habbo.Rank < 2 && !NeonStaticGameSettings.HotelOpenForUsers)
                    {
                        SendMessage(new SendHotelAlertLinkEventComposer("Actualmente solo el Equipo Adminsitrativo puede entrar al hotel para comprobar que todo está bien antes de que los usuarios puedan entrar. Vuelve a intentarlo en unos minutos, podrás encontrar más información en nuestro Facebook.", NeonEnvironment.GetDBConfig().DBData["facebook_url"]));
                        Thread.Sleep(10000);
                        Disconnect();
                        return(false);
                    }

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }
                    if (NeonEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup))
                    {
                        if (!string.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    if (NeonEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData SubData))
                    {
                        if (!string.IsNullOrEmpty(SubData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this);
                            }
                        }
                    }

                    if (!NeonEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        NeonEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    GetHabbo()._lastitems = new Dictionary <int, CatalogItem>();
                    //ICollection<MessengerBuddy> Friends = new List<MessengerBuddy>();
                    //foreach (MessengerBuddy Buddy in this.GetHabbo().GetMessenger().GetFriends().ToList())
                    //{
                    //    if (Buddy == null)
                    //        continue;

                    //    GameClient Friend = NeonEnvironment.GetGame().GetClientManager().GetClientByUserID(Buddy.Id);
                    //    if (Friend == null)
                    //        continue;
                    //    string figure = this.GetHabbo().Look;


                    //    Friend.SendMessage(RoomNotificationComposer.SendBubble("usr/look/" + this.GetHabbo().Username + "", this.GetHabbo().Username + " se ha conectado a " + NeonEnvironment.GetDBConfig().DBData["hotel.name"] + ".", ""));

                    //}

                    if (GetHabbo()._NUX)
                    {
                        SendMessage(new MassEventComposer("habbopages/bienvenida.txt"));
                    }
                    else
                    {
                        SendMessage(new MassEventComposer("habbopages/welk.txt?249"));
                    }


                    if (NeonEnvironment.GetDBConfig().DBData["pin.system.enable"] == "0")
                    {
                        GetHabbo().StaffOk = true;
                    }

                    if (GetHabbo().StaffOk)
                    {
                        if (GetHabbo().GetPermissions().HasRight("mod_tickets"))
                        {
                            SendMessage(new ModeratorInitComposer(
                                            NeonEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                            NeonEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                            NeonEnvironment.GetGame().GetModerationManager().GetTickets));
                        }
                    }

                    if (GetHabbo().Rank > 5 || GetHabbo()._guidelevel > 0)
                    {
                        HelperToolsManager.AddHelper(_habbo.GetClient(), false, true, true);
                        SendMessage(new HandleHelperToolComposer(true));
                    }

                    //SendMessage(new CampaignCalendarDataComposer(_habbo.calendarGift));
                    //if (int.Parse(NeonEnvironment.GetDBConfig().DBData["advent.calendar.enable"]) == 1) // Tk Custom By Whats
                    //    SendMessage(new MassEventComposer("openView/calendar"));

                    if (NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                    {
                        NeonEnvironment.GetGame().GetTargetedOffersManager().Initialize(NeonEnvironment.GetDatabaseManager().GetQueryReactor());
                        TargetedOffers TargetedOffer = NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer;

                        if (TargetedOffer.Expire > NeonEnvironment.GetIUnixTimestamp())
                        {
                            if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                            {
                                SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                            }
                        }
                        else if (TargetedOffer.Expire == -1)
                        {
                            if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                            {
                                SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                            }
                        }
                        else
                        {
                            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'");
                            }

                            using (IQueryAdapter dbClient2 = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0");
                            }
                        }
                    }

                    if (_habbo.MysticBoxes.Count == 0 && _habbo.MysticKeys.Count == 0)
                    {
                        int    box      = RandomNumber.GenerateRandom(1, 8);
                        string boxcolor = "";
                        switch (box)
                        {
                        case 1:
                            boxcolor = "purple";
                            break;

                        case 2:
                            boxcolor = "blue";
                            break;

                        case 3:
                            boxcolor = "green";
                            break;

                        case 4:
                            boxcolor = "yellow";
                            break;

                        case 5:
                            boxcolor = "lilac";
                            break;

                        case 6:
                            boxcolor = "orange";
                            break;

                        case 7:
                            boxcolor = "turquoise";
                            break;

                        case 8:
                            boxcolor = "red";
                            break;
                        }

                        int    key      = RandomNumber.GenerateRandom(1, 8);
                        string keycolor = "";
                        switch (key)
                        {
                        case 1:
                            keycolor = "purple";
                            break;

                        case 2:
                            keycolor = "blue";
                            break;

                        case 3:
                            keycolor = "green";
                            break;

                        case 4:
                            keycolor = "yellow";
                            break;

                        case 5:
                            keycolor = "lilac";
                            break;

                        case 6:
                            keycolor = "orange";
                            break;

                        case 7:
                            keycolor = "turquoise";
                            break;

                        case 8:
                            keycolor = "red";
                            break;
                        }

                        _habbo.MysticKeys.Add(keycolor);
                        _habbo.MysticBoxes.Add(boxcolor);

                        using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.runFastQuery("INSERT INTO user_mystic_data(user_id, mystic_keys, mystic_boxes) VALUES(" + GetHabbo().Id + ", '" + keycolor + "', '" + boxcolor + "');");
                        }
                    }

                    SendMessage(new MysteryBoxDataComposer(_habbo.GetClient()));

                    SendMessage(new HCGiftsAlertComposer());

                    //if(!GetHabbo()._NUX)
                    //{
                    //    DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    //    dtDateTime = dtDateTime.AddSeconds(GetHabbo().LastOnline);

                    //    if ((DateTime.Now - dtDateTime).TotalDays > 2)
                    //    {
                    //        //NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_Login", 1, true);
                    //        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_RegistrationDuration", 1);
                    //    }

                    //    else if ((DateTime.Now - dtDateTime).TotalDays > 1 && (DateTime.Now - dtDateTime).TotalDays < 2)
                    //    {
                    //        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_Login", 1);
                    //        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_RegistrationDuration", 1);

                    //        if(GetHabbo().Rank > 2 || GetHabbo()._guidelevel > 0)
                    //        {
                    //            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_GuideEnrollmentLifetime", 1);
                    //        }
                    //    }
                    //}


                    NeonEnvironment.GetGame().GetRewardManager().CheckRewards(this);

                    if (GetHabbo()._NUX)
                    {
                        NeonEnvironment.GetGame().GetClientManager().StaffAlert(new RoomInviteComposer(int.MinValue, GetHabbo().Username + " acaba de registrarse en Keko."));

                        GetHabbo()._NUX = false;
                        using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.runFastQuery("UPDATE users SET nux_user = '******' WHERE id = " + GetHabbo().Id + ";");
                        }
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }
Пример #17
0
        public bool TryAuthenticate(string authTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(authTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out _))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out _))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                if (userData.user == null) //Possible NPE
                {
                    return(false);
                }

                PlusEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.user.Username);
                _habbo = userData.user;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendPacket(new AuthenticationOKComposer());
                    SendPacket(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendPacket(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendPacket(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendPacket(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts));
                    SendPacket(new UserRightsComposer(_habbo.Rank));
                    SendPacket(new AvailabilityStatusComposer());
                    SendPacket(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendPacket(new BuildersClubMembershipComposer());
                    SendPacket(new CfhTopicsInitComposer(PlusEnvironment.GetGame().GetModerationManager().UserActionPresets));

                    SendPacket(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager().Achievements));
                    SendPacket(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

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

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    if (PlusEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup group))
                    {
                        if (!String.IsNullOrEmpty(group.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(group.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(group.Badge, true, this);
                            }
                        }
                    }

                    if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData subData))
                    {
                        if (!String.IsNullOrEmpty(subData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(subData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(subData.Badge, true, this);
                            }
                        }
                    }

                    if (!PlusEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.Look = PlusEnvironment.GetFigureManager().ProcessFigure(_habbo.Look, _habbo.Gender, _habbo.GetClothing().GetClothingParts, true);
                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendPacket(new ModeratorInitComposer(
                                       PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                       PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                       PlusEnvironment.GetGame().GetModerationManager().GetTickets));
                    }

                    if (PlusEnvironment.GetSettingsManager().TryGetValue("user.login.message.enabled") == "1")
                    {
                        SendPacket(new MotdNotificationComposer(PlusEnvironment.GetLanguageManager().TryGetValue("user.login.message")));
                    }

                    PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this);
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
Пример #18
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, out errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect(true);
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect(true);
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    //Now let us check for a username ban record..
                    BanRecord = null;
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect(true);
                            return(false);
                        }
                    }
                }
                #endregion

                #region Roleplay Data
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT * FROM `rp_stats` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                    DataRow UserRPRow = dbClient.getRow();

                    dbClient.SetQuery("SELECT * FROM `rp_stats_cooldowns` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                    DataRow UserRPCooldowns = dbClient.getRow();

                    if (UserRPCooldowns == null)
                    {
                        dbClient.RunQuery("INSERT INTO `rp_stats_cooldowns` (`id`) VALUES ('" + userData.userID + "')");
                        dbClient.SetQuery("SELECT * FROM `rp_stats_cooldowns` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                        UserRPCooldowns = dbClient.getRow();
                    }

                    dbClient.SetQuery("SELECT * FROM `rp_stats_farming` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                    DataRow UserRPFarming = dbClient.getRow();

                    if (UserRPFarming == null)
                    {
                        dbClient.RunQuery("INSERT INTO `rp_stats_farming` (`id`) VALUES ('" + userData.userID + "')");
                        dbClient.SetQuery("SELECT * FROM `rp_stats_farming` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                        UserRPFarming = dbClient.getRow();
                    }

                    _roleplay = new RoleplayUser(this, UserRPRow, UserRPCooldowns, UserRPFarming);
                }
                #endregion

                PlusEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo = userData.user;

                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts));
                    SendMessage(new UserRightsComposer(this, _habbo.Rank));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer());
                    SendMessage(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (this._habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    PermissionGroup PermissionGroup = null;
                    if (PlusEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup))
                    {
                        if (!String.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    SubscriptionData SubData = null;
                    if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out SubData))
                    {
                        if (!String.IsNullOrEmpty(SubData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this);
                            }
                        }
                    }

                    if (!PlusEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendMessage(new ModeratorInitComposer(
                                        PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                        PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                        PlusEnvironment.GetGame().GetModerationManager().UserActionPresets,
                                        PlusEnvironment.GetGame().GetModerationTool().GetTickets));
                    }

                    if (!string.IsNullOrWhiteSpace(PlusEnvironment.GetDBConfig().DBData["welcome_message"]))
                    {
                        SendMessage(new MOTDNotificationComposer(PlusEnvironment.GetDBConfig().DBData["welcome_message"].Replace("\\r\\n", "\n")));
                    }

                    PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this);
                    this.AuthTicket = AuthTicket;
                    EventManager.TriggerEvent("OnLogin", this);
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Erro durante o login do usuário: " + e);
            }
            return(false);
        }
Пример #19
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, out errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking

                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (RocketEmulador.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (RocketEmulador.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    BanRecord = null;
                    if (RocketEmulador.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                    {
                        if (RocketEmulador.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                RocketEmulador.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                this._habbo = userData.user;
                bool flag8 = this._habbo != null;
                if (flag8)
                {
                    userData.user.Init(this, userData);
                    this.SendMessage(new AuthenticationOKComposer());
                    this.SendMessage(new AvatarEffectsComposer(this._habbo.Effects().GetAllEffects));
                    this.SendMessage(new NavigatorSettingsComposer(this._habbo.HomeRoom));
                    this.SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    this.SendMessage(new FigureSetIdsComposer(this._habbo.GetClothing().GetClothingAllParts));
                    this.SendMessage(new UserRightsComposer(this._habbo.Rank));
                    this.SendMessage(new AvailabilityStatusComposer());

                    this.SendMessage(new TalentTrackLevelComposer());
                    this.SendMessage(new TargetOfferMessageComposer());
                    this.SendMessage(new AchievementScoreComposer(this._habbo.GetStats().AchievementPoints));

                    ServerPacket serverPacket = new ServerPacket(879);
                    serverPacket.WriteString("club_habbo");
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(2);
                    serverPacket.WriteBoolean(false);
                    serverPacket.WriteBoolean(false);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    this.SendMessage(serverPacket);
                    this.SendMessage(new BuildersClubMembershipComposer());
                    this.SendMessage(new CfhTopicsInitComposer());
                    this.SendMessage(new BadgeDefinitionsComposer(RocketEmulador.GetGame().GetAchievementManager()._achievements));
                    this.SendMessage(new SoundSettingsComposer(this._habbo.ClientVolume, this._habbo.ChatPreference, this._habbo.AllowMessengerInvites, this._habbo.FocusPreference, FriendBarStateUtility.GetInt(this._habbo.FriendbarState)));
                    bool flag9 = this.GetHabbo().GetMessenger() != null;
                    if (flag9)
                    {
                        this.GetHabbo().GetMessenger().OnStatusChanged(true);
                    }
                    bool flag10 = !string.IsNullOrEmpty(this.MachineId);
                    if (flag10)
                    {
                        bool flag11 = this._habbo.MachineId != this.MachineId;
                        if (flag11)
                        {
                            using (IQueryAdapter queryReactor = RocketEmulador.GetDatabaseManager().GetQueryReactor())
                            {
                                queryReactor.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                queryReactor.AddParameter("MachineId", this.MachineId);
                                queryReactor.AddParameter("id", this._habbo.Id);
                                queryReactor.RunQuery();
                            }
                        }
                        this._habbo.MachineId = this.MachineId;
                    }

                    PermissionGroup PermissionGroup = null;
                    if (RocketEmulador.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup))
                    {
                        if (!String.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    SubscriptionData SubData = null;
                    if (RocketEmulador.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out SubData))
                    {
                        if (!String.IsNullOrEmpty(SubData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this);
                            }
                        }
                    }

                    if (!RocketEmulador.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        RocketEmulador.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendMessage(new ModeratorInitComposer(
                                        RocketEmulador.GetGame().GetModerationManager().UserMessagePresets,
                                        RocketEmulador.GetGame().GetModerationManager().RoomMessagePresets,
                                        RocketEmulador.GetGame().GetModerationManager().UserActionPresets,
                                        RocketEmulador.GetGame().GetModerationTool().GetTickets));
                    }

                    {
                        string hotelName = RocketEmulador.RocketData().data["hotelname"];
                        if (!string.IsNullOrWhiteSpace(RocketEmulador.GetDBConfig().DBData["welcome_message"]))
                        {
                            SendMessage(new MOTDNotificationComposer(RocketEmulador.GetDBConfig().DBData["welcome_message"]));
                        }


                        SendMessage(new RoomNotificationComposer("entrar", "message", "Bem-vindo" +
                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                 "ao " + hotelName + "!"));


                        if (GetHabbo().Rank == 10)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O PROGRAMADOR" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }
                        if (GetHabbo().Rank == 9)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O CEO" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 8)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O GERENTE" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 7)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O ADM" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 6)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O MOD" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 5)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O PROMOTOR" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 4)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O EMB" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 3)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O VIP" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }



                        if (GetHabbo().Rank == 2)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O LOCUTOR" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        Console.WriteLine("Um novo usuário se conectou seu nick é: " + userData.user.GetClient().GetHabbo().Username + " e seu ip: " + userData.user.GetClient().GetConnection().getIp(), "Rocket.Users",
                                          ConsoleColor.DarkGreen);
                    }
                }
            }


            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }
Пример #20
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = NeonEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            Room Room = Player.CurrentRoom;

            if (string.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            int    SplitNumber  = -1;
            int    oftenforuser = int.Parse(StringData.Split('-')[3]);
            int    amountLeft   = int.Parse(StringData.Split('-')[2]);
            int    often        = int.Parse(StringData.Split('-')[1]);
            string Reward       = StringData.Split('-')[0];
            bool   unique       = BoolData;
            int    totalrewards = (StringData.Split('-')[0]).Split(';').Count();
            bool   premied      = false;

            /*
             * Often numbers
             * 3- 1/min
             * 2- 1/Hour
             * 1- 1/Day
             * 0- Once
             *
             */

            if (amountLeft == 1)
            {
                Player.GetClient().SendMessage(new WiredRewardAlertComposer(0));
                return(true);
            }

            if (!unique)
            {
                int percentage1     = 0;
                int percentage2     = 0;
                int percentage3     = 0;
                int percentage4     = 0;
                int percentage5     = 0;
                int totalpercentage = 0;

                if (totalrewards > 0)
                {
                    percentage1 = int.Parse(((StringData.Split('-')[0]).Split(';')[0]).Split(',')[2]);
                }
                else if (totalrewards > 1)
                {
                    percentage2 = int.Parse(((StringData.Split('-')[0]).Split(';')[1]).Split(',')[2]) + percentage1;
                }
                else if (totalrewards > 2)
                {
                    percentage3 = int.Parse(((StringData.Split('-')[0]).Split(';')[2]).Split(',')[2]) + percentage2;
                }
                else if (totalrewards > 3)
                {
                    percentage4 = int.Parse(((StringData.Split('-')[0]).Split(';')[3]).Split(',')[2]) + percentage3;
                }
                else if (totalrewards > 4)
                {
                    percentage5 = int.Parse(((StringData.Split('-')[0]).Split(';')[4]).Split(',')[2]) + percentage4;
                }

                totalpercentage = percentage5 + percentage4 + percentage3 + percentage2 + percentage1;

                int random = NeonEnvironment.GetRandomNumber(0, 100);

                if (random > totalpercentage)
                {
                    Player.GetClient().SendMessage(new WiredRewardAlertComposer(4));
                    return(true);
                }


                if (percentage1 >= random)
                {
                    SplitNumber = 0;
                }
                else if (percentage1 <= random && random <= percentage2)
                {
                    SplitNumber = 1;
                }
                else if (percentage2 <= random && random <= percentage3)
                {
                    SplitNumber = 2;
                }
                else if (percentage3 <= random && random <= percentage4)
                {
                    SplitNumber = 3;
                }
                else if (percentage4 <= random && random <= percentage5 || random >= percentage5)
                {
                    SplitNumber = 4;
                }

                Player.GetClient().SendWhisper(random + " | " + SplitNumber + " | " + totalpercentage);

                string[] dataArray = ((StringData.Split('-')[0]).Split(';')[SplitNumber]).Split(',');

                bool   isbadge    = dataArray[0] == "0";
                string code       = dataArray[1];
                int    percentage = int.Parse(dataArray[2]);

                premied = true;

                if (isbadge)
                {
                    if (code.StartsWith("diamonds:"))
                    {
                        foreach (string reward in code.Split('-'))
                        {
                            string[] dataArray2 = code.Split(':');
                            int      diamonds   = int.Parse(dataArray2[1]);
                            if (diamonds > 100)
                            {
                                Player.GetClient().SendMessage(new RoomCustomizedAlertComposer("¡Ha ocurrido un error! Avisa a un miembro del equipo Staff."));
                                NeonEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("advice", "" + Player.GetClient().GetHabbo().Username + " ha usado un wired que no sigue las normas del hotel.\n             Click aquí.", "event:navigator/goto/" + Player.GetClient().GetHabbo().CurrentRoomId));
                            }
                            else
                            {
                                Player.GetClient().GetHabbo().Diamonds += diamonds;
                                Player.GetClient().SendMessage(new HabboActivityPointNotificationComposer(Player.GetClient().GetHabbo().Diamonds, diamonds, 5));
                            }
                        }
                    }
                    else if (Player.GetBadgeComponent().HasBadge(code))
                    {
                        Player.GetClient().SendMessage(new WiredRewardAlertComposer(5));
                    }
                    else
                    {
                        Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                        Player.GetClient().SendMessage(new WiredRewardAlertComposer(7));
                    }
                }
                else
                {
                    if (!NeonEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData ItemData))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "No se pudo obtener Item ID: " + code, 0, User.LastBubble));
                        return(false);
                    }

                    Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                    if (Item != null)
                    {
                        Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                        Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                        Player.GetClient().SendMessage(new PurchaseOKComposer());
                        Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                        Player.GetClient().SendMessage(new FurniListUpdateComposer());
                        Player.GetClient().SendMessage(new WiredRewardAlertComposer(6));
                    }
                }
            }
            else
            {
                foreach (string dataStr in (StringData.Split('-')[0]).Split(';'))
                {
                    string[] dataArray = dataStr.Split(',');

                    bool   isbadge    = dataArray[0] == "0";
                    string code       = dataArray[1];
                    int    percentage = int.Parse(dataArray[2]);

                    int random = NeonEnvironment.GetRandomNumber(0, 100);

                    premied = true;

                    if (isbadge)
                    {
                        if (code.StartsWith("diamonds:"))
                        {
                            foreach (string reward in code.Split('-'))
                            {
                                string[] dataArray2 = code.Split(':');
                                int      diamonds   = int.Parse(dataArray2[1]);
                                if (diamonds > 100)
                                {
                                    Player.GetClient().SendMessage(new RoomCustomizedAlertComposer("¡Ha ocurrido un error! Avisa a un miembro del equipo Staff."));
                                    NeonEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("advice", "" + Player.GetClient().GetHabbo().Username + " ha usado un wired que no sigue las normas del hotel.\n             Click aquí.", "event:navigator/goto/" + Player.GetClient().GetHabbo().CurrentRoomId));
                                }
                                else
                                {
                                    Player.GetClient().GetHabbo().Diamonds += diamonds;
                                    Player.GetClient().SendMessage(new HabboActivityPointNotificationComposer(Player.GetClient().GetHabbo().Diamonds, diamonds, 5));
                                }
                            }
                        }
                        if (Player.GetBadgeComponent().HasBadge(code))
                        {
                            Player.GetClient().SendMessage(new WiredRewardAlertComposer(5));
                        }
                        else
                        {
                            Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                            Player.GetClient().SendMessage(new WiredRewardAlertComposer(7));
                        }
                    }
                    else
                    {
                        if (!NeonEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData ItemData))
                        {
                            Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "No se pudo obtener Item ID: " + code, 0, User.LastBubble));
                            return(false);
                        }

                        Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                        if (Item != null)
                        {
                            Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                            Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                            Player.GetClient().SendMessage(new PurchaseOKComposer());
                            Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                            Player.GetClient().SendMessage(new FurniListUpdateComposer());
                            Player.GetClient().SendMessage(new WiredRewardAlertComposer(6));
                        }
                    }
                }
            }

            if (premied)
            {
            }
            else if (!premied)
            {
                Player.GetClient().SendMessage(new WiredRewardAlertComposer(4));
            }
            else if (amountLeft > 1)
            {
                amountLeft--;
                StringData = Reward + "-" + often + "-" + amountLeft + "-" + oftenforuser;
            }

            return(true);
        }
Пример #21
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, out errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (QuasarEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (QuasarEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    //Now let us check for a username ban record..
                    BanRecord = null;
                    if (QuasarEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                    {
                        if (QuasarEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                QuasarEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo = userData.user;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    //FurniListNotification -> why?
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts));
                    //1984
                    //2102
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    //1044
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    //3674
                    //3437
                    SendMessage(new CampaignCalendarDataComposer(_habbo.calendarGift));

                    var habboClubSubscription = new ServerPacket(ServerPacketHeader.HabboClubSubscriptionComposer);
                    habboClubSubscription.WriteString("club_habbo");
                    habboClubSubscription.WriteInteger(0);
                    habboClubSubscription.WriteInteger(0);
                    habboClubSubscription.WriteInteger(0);
                    habboClubSubscription.WriteInteger(2);
                    habboClubSubscription.WriteBoolean(false);
                    habboClubSubscription.WriteBoolean(false);
                    habboClubSubscription.WriteInteger(0);
                    habboClubSubscription.WriteInteger(0);
                    habboClubSubscription.WriteInteger(0);
                    SendMessage(habboClubSubscription);

                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer());

                    SendMessage(new BadgeDefinitionsComposer(QuasarEnvironment.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (this._habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    PermissionGroup PermissionGroup = null;
                    if (QuasarEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup))
                    {
                        if (!String.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    SubscriptionData SubData = null;
                    if (QuasarEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out SubData))
                    {
                        if (!String.IsNullOrEmpty(SubData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this);
                            }
                        }
                    }

                    if (!QuasarEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        QuasarEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }


                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendMessage(new ModeratorInitComposer(
                                        QuasarEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                        QuasarEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                        QuasarEnvironment.GetGame().GetModerationManager().UserActionPresets,
                                        QuasarEnvironment.GetGame().GetModerationTool().GetTickets));
                    }

                    if (!string.IsNullOrWhiteSpace(QuasarEnvironment.GetDBConfig().DBData["welcome_message"]))
                    {
                        SendMessage(new MOTDNotificationComposer(QuasarEnvironment.GetDBConfig().DBData["welcome_message"]));
                    }

                    QuasarEnvironment.GetGame().GetRewardManager().CheckRewards(this);


                    if (GetHabbo()._NUX)
                    {
                        var nuxStatus = new ServerPacket(ServerPacketHeader.NuxUserStatus);
                        nuxStatus.WriteInteger(2);
                        SendMessage(nuxStatus);
                        QuasarEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("bubble_filter", "Er is een nieuwe gebruiker geregistreerd in Habbis!\n\nGebruiker: " + GetHabbo().Username + "", ""));
                    }

                    if (QuasarEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                    {
                        SendMessage(QuasarEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }
Пример #22
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = CloudServer.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

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

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            int  amountLeft = int.Parse(StringData.Split('-')[2]);
            int  often      = int.Parse(StringData.Split('-')[1]);
            bool unique     = BoolData;

            bool premied = false;

            if (amountLeft == 1)
            {
                Player.GetClient().SendNotification("Ya no hay mas premios, vuelve mas tarde.");
                return(true);
            }

            foreach (var dataStr in (StringData.Split('-')[0]).Split(';'))
            {
                var dataArray = dataStr.Split(',');

                var isbadge    = dataArray[0] == "0";
                var code       = dataArray[1];
                var percentage = int.Parse(dataArray[2]);

                var random = CloudServer.GetRandomNumber(0, 100);

                if (!unique && percentage < random)
                {
                    continue;
                }
                premied = true;

                if (isbadge)
                {
                    if (Player.GetBadgeComponent().HasBadge(code))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Oops,Parece que já recebeu este emblema !", 0, User.LastBubble));
                    }
                    else
                    {
                        Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                        Player.GetClient().SendMessage(RoomNotificationComposer.SendBubble("badge/" + Params[2], "Acaba de receber um emblema!", "/inventory/open/badge"));
                    }
                }
                else
                {
                    ItemData ItemData = null;

                    if (!CloudServer.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "No se pudo obtener Item ID: " + code, 0, User.LastBubble));
                        return(false);
                    }

                    Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                    if (Item != null)
                    {
                        Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                        Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                        Player.GetClient().SendMessage(new PurchaseOKComposer());
                        Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                        Player.GetClient().SendMessage(new FurniListUpdateComposer());
                        Player.GetClient().SendNotification("¡Has recibido un regalo! Revisa tu inventario.");
                    }
                }
            }

            if (!premied)
            {
                Player.GetClient().SendNotification("Suerte la proxima vez :(");
            }
            else if (amountLeft > 1)
            {
                amountLeft--;
                this.StringData.Split('-')[2] = amountLeft.ToString();
            }

            return(true);
        }