Exemplo n.º 1
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

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

            if (User == null)
            {
                return;
            }

            string NewName = Packet.PopString();
            string OldName = Session.GetHabbo().Username;

            if (NewName == OldName)
            {
                Session.GetHabbo().ChangeName(OldName);
                Session.SendMessage(new UpdateUsernameComposer(NewName));
                return;
            }

            if (!CanChangeName(Session.GetHabbo()))
            {
                Session.SendNotification("Oops, it appears you currently cannot change your username!");
                return;
            }

            bool InUse = false;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1");
                dbClient.AddParameter("name", NewName);
                InUse = dbClient.getInteger() == 1;
            }

            char[] Letters           = NewName.ToLower().ToCharArray();
            string AllowedCharacters = "abcdefghijklmnopqrstuvwxyz.,_-;:?!1234567890";

            foreach (char Chr in Letters)
            {
                if (!AllowedCharacters.Contains(Chr))
                {
                    return;
                }
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool") && NewName.ToLower().Contains("mod") || NewName.ToLower().Contains("adm") || NewName.ToLower().Contains("admin") ||
                NewName.ToLower().Contains("m0d") || NewName.ToLower().Contains("mob") || NewName.ToLower().Contains("m0b"))
            {
                return;
            }
            else if (!NewName.ToLower().Contains("mod") && (Session.GetHabbo().Rank == 2 || Session.GetHabbo().Rank == 3))
            {
                return;
            }
            else if (NewName.Length > 15)
            {
                return;
            }
            else if (NewName.Length < 3)
            {
                return;
            }
            else if (InUse)
            {
                return;
            }
            else
            {
                if (!PlusEnvironment.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName))
                {
                    Session.SendNotification("Oops! An issue occoured whilst updating your username.");
                    return;
                }

                Session.GetHabbo().ChangingName = false;

                Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false);

                Session.GetHabbo().ChangeName(NewName);
                Session.GetHabbo().GetMessenger().OnStatusChanged(true);

                Session.SendMessage(new UpdateUsernameComposer(NewName));
                Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName));

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @name, '" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "')");
                    dbClient.AddParameter("name", NewName);
                    dbClient.RunQuery();
                }

                ICollection <RoomData> Rooms = Session.GetHabbo().UsersRooms;
                foreach (RoomData Data in Rooms)
                {
                    if (Data == null)
                    {
                        continue;
                    }

                    Data.OwnerName = NewName;
                }

                foreach (Room UserRoom in PlusEnvironment.GetGame().GetRoomManager().GetRooms().ToList())
                {
                    if (UserRoom == null || UserRoom.RoomData.OwnerName != NewName)
                    {
                        continue;
                    }

                    UserRoom.OwnerName          = NewName;
                    UserRoom.RoomData.OwnerName = NewName;

                    UserRoom.SendMessage(new RoomInfoUpdatedComposer(UserRoom.RoomId));
                }

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

                Session.SendMessage(new RoomForwardComposer(Room.Id));
            }
        }
Exemplo n.º 2
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Digite o nome de usuário da pessoa!", 1);
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (TargetClient == null)
            {
                Session.SendWhisper("Ocorreu um erro ao encontrar esse usuário, talvez ele não esteja online.", 1);
                return;
            }

            if (Params.Length == 2)
            {
                Session.SendWhisper("Você alterou com sucesso o nome deste usuário!", 1);
                TargetClient.GetHabbo().LastNameChange    = 0;
                TargetClient.GetHabbo().ChangingName      = true;
                TargetClient.GetRoleplay().FreeNameChange = true;
                TargetClient.SendNotification("Tenha em atenção que, se o seu nome de usuário for considerado inapropriado, você será banido.\r\rObserve a Equipe NÃO permitirá que você altere seu nome de usuário novamente se você tiver um problema com o que você escolheu.\r\rFeche esta janela e clique em si mesmo para começar a escolher um novo nome de usuário!");
                TargetClient.SendMessage(new UserObjectComposer(TargetClient.GetHabbo()));
            }
            else if (Params.Length > 2)
            {
                var User = TargetClient.GetRoomUser();

                if (User == null)
                {
                    Session.SendWhisper("Desculpe, mas essa pessoa não está em uma sala!", 1);
                    return;
                }

                if (User.RoomId != Room.Id)
                {
                    Session.SendWhisper("Certifique-se de que o alvo esteja na mesma sala que você para fazer a alteração!", 1);
                    return;
                }

                string NewName = Params[2];
                string OldName = TargetClient.GetHabbo().Username;

                bool InUse = false;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1");
                    dbClient.AddParameter("name", NewName);
                    InUse = dbClient.getInteger() == 1;
                }

                if (InUse)
                {
                    Session.SendWhisper("Este usuário já possui este nome!", 1);
                    return;
                }

                if (!PlusEnvironment.GetGame().GetClientManager().UpdateClientUsername(TargetClient, OldName, NewName))
                {
                    Session.SendWhisper("Opa! Ocorreu um problema ao atualizar seu nome de usuário. Por favor, tente novamente.", 1);
                    return;
                }

                Room TargetRoom = User.GetRoom();

                TargetClient.GetHabbo().ChangingName = false;
                if (TargetRoom != null)
                {
                    TargetRoom.GetRoomUserManager().RemoveUserFromRoom(TargetClient, true, false);
                }

                TargetClient.GetHabbo().ChangeName(NewName);
                TargetClient.GetHabbo().GetMessenger().OnStatusChanged(true);

                TargetClient.SendMessage(new UpdateUsernameComposer(NewName));
                if (TargetRoom != null)
                {
                    TargetRoom.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName));
                }

                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + TargetClient.GetHabbo().Id + "', @name, '" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "')");
                    dbClient.AddParameter("name", NewName);
                    dbClient.RunQuery();
                }

                ICollection <RoomData> Rooms = TargetClient.GetHabbo().UsersRooms;
                foreach (RoomData Data in Rooms)
                {
                    if (Data == null)
                    {
                        continue;
                    }

                    Data.OwnerName = NewName;
                }

                foreach (Room UserRoom in PlusEnvironment.GetGame().GetRoomManager().GetRooms().ToList())
                {
                    if (UserRoom == null || UserRoom.RoomData.OwnerName != NewName)
                    {
                        continue;
                    }

                    UserRoom.OwnerName          = NewName;
                    UserRoom.RoomData.OwnerName = NewName;

                    UserRoom.SendMessage(new RoomInfoUpdatedComposer(UserRoom.RoomId));
                }
                RoleplayManager.SendUser(TargetClient, Room.Id, "");
                Session.Shout("*Altera imediatamente o nome de " + OldName + " para " + NewName + "*", 23);
                return;
            }
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

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

            if (User == null)
            {
                return;
            }

            string NewName = Packet.PopString();
            string OldName = Session.GetHabbo().Username;

            if (NewName == OldName)
            {
                Session.GetHabbo().ChangeName(OldName);
                Session.SendMessage(new UpdateUsernameComposer(NewName));
                return;
            }

            if (!CanChangeName(Session.GetHabbo()))
            {
                Session.SendNotification("Bem, parece que atualmente você não pode mudar seu nome de usuário!");
                return;
            }

            if (Session.GetHabbo().Rank > 0)
            {
                DataRow presothiago = null;
                using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT Presidio FROM users WHERE id = '" + Session.GetHabbo().Id + "'");
                    presothiago = dbClient.getRow();
                }

                if (Convert.ToBoolean(presothiago["Presidio"]) == true)
                {
                    if (Session.GetHabbo().Rank > 0)
                    {
                        string thiago = Session.GetHabbo().Look;
                        Session.SendMessage(new RoomNotificationComposer("police_announcement", "message", "Você esta preso e não pode troca seu nome."));
                        return;
                    }
                }
            }

            bool InUse = false;

            using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1");
                dbClient.AddParameter("name", NewName);
                InUse = dbClient.getInteger() == 1;
            }

            char[] Letters           = NewName.ToLower().ToCharArray();
            string AllowedCharacters = "abcdefghijklmnopqrstuvwxyz.,_-;:?!1234567890";

            foreach (char Chr in Letters)
            {
                if (!AllowedCharacters.Contains(Chr))
                {
                    return;
                }
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool") && NewName.ToLower().Contains("mod") || NewName.ToLower().Contains("adm") || NewName.ToLower().Contains("admin") ||
                NewName.ToLower().Contains("m0d") || NewName.ToLower().Contains("mob") || NewName.ToLower().Contains("m0b"))
            {
                return;
            }
            else if (!NewName.ToLower().Contains("mod") && (Session.GetHabbo().Rank == 2 || Session.GetHabbo().Rank == 3))
            {
                return;
            }
            else if (NewName.Length > 15)
            {
                return;
            }
            else if (NewName.Length < 3)
            {
                return;
            }
            else if (InUse)
            {
                return;
            }
            else
            {
                if (!BiosEmuThiago.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName))
                {
                    Session.SendNotification("Ops! Houve um problema ao atualizar seu nome de usuário.");
                    return;
                }

                Session.GetHabbo().ChangingName = false;

                Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false);

                Session.GetHabbo().ChangeName(NewName);
                Session.GetHabbo().GetMessenger().OnStatusChanged(true);

                Session.SendMessage(new UpdateUsernameComposer(NewName));
                Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName));

                using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @name, '" + OldName + "', '" + BiosEmuThiago.GetUnixTimestamp() + "')");
                    dbClient.AddParameter("name", NewName);
                    dbClient.RunQuery();
                }

                ICollection <RoomData> Rooms = Session.GetHabbo().UsersRooms;
                foreach (RoomData Data in Rooms)
                {
                    if (Data == null)
                    {
                        continue;
                    }

                    Data.OwnerName = NewName;
                }

                foreach (Room UserRoom in BiosEmuThiago.GetGame().GetRoomManager().GetRooms().ToList())
                {
                    if (UserRoom == null || UserRoom.RoomData.OwnerName != NewName)
                    {
                        continue;
                    }

                    UserRoom.OwnerName          = NewName;
                    UserRoom.RoomData.OwnerName = NewName;

                    UserRoom.SendMessage(new RoomInfoUpdatedComposer(UserRoom.RoomId));
                }

                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_Name", 1);

                Session.SendMessage(new RoomForwardComposer(Room.Id));
            }
        }
Exemplo n.º 4
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            string NewName = Packet.PopString();
            string OldName = Session.GetHabbo().Username;

            if (NewName == OldName)
            {
                Session.GetHabbo().ChangeName(OldName);
                Session.SendMessage(new UpdateUsernameComposer(NewName));
                return;
            }

            if (!CanChangeName(Session.GetHabbo()))
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Ops, parece que você atualmente não pode alterar seu nome de usuário!");
                return;
            }

            if (!Session.GetRoleplay().FreeNameChange)
            {
                if (Session.GetHabbo().Diamonds < 1)
                {
                    Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                    Session.SendNotification("Você não tem diamantes suficientes para uma mudança de nome!");
                    return;
                }
            }

            bool InUse = false;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1");
                dbClient.AddParameter("name", NewName);
                InUse = dbClient.getInteger() == 1;
            }

            char[] Letters           = NewName.ToLower().ToCharArray();
            string AllowedCharacters = "abcdefghijklmnopqrstuvwxyz-";

            foreach (char Chr in Letters)
            {
                if (!AllowedCharacters.Contains(Chr))
                {
                    return;
                }
            }

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

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `cms_blacklisted_words`");
                DataTable Table = dbClient.getTable();

                if (Table != null)
                {
                    foreach (DataRow Row in Table.Rows)
                    {
                        string Word = Row["word"].ToString();

                        if (Word.Length > 0 && Word.ToLower() != "")
                        {
                            if (!BlacklistedWords.Contains(Word.ToLower()))
                            {
                                BlacklistedWords.Add(Word.ToLower());
                            }
                        }
                    }
                }
            }

            if (NewName.ToLower().Contains("mod") || NewName.ToLower().Contains("adm") || NewName.ToLower().Contains("admin") || NewName.ToLower().Contains("m0d"))
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Você não pode fazer deste seu nome! Por favor digite ':mudarnick' novamente!");
                return;
            }
            else if (!NewName.Contains('-'))
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Você não pode fazer deste seu nome! Por favor digite ':mudarnick' novamente!");
                return;
            }
            else if (NewName.Split('-')[0].Length < 3 || NewName.Split('-')[1].Length < 1)
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Você não pode fazer deste seu nome! Por favor digite ':mudarnick' novamente!");
                return;
            }
            else if (NewName.Length > 15)
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Você não pode fazer deste seu nome! Por favor digite ':mudarnick' novamente!");
                return;
            }
            else if (NewName.Length < 3)
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Você não pode fazer deste seu nome! Por favor digite ':mudarnick' novamente!");
                return;
            }
            else if (InUse)
            {
                Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                Session.SendNotification("Você não pode fazer deste seu nome! Por favor digite ':mudarnick' novamente!");
                return;
            }
            else
            {
                string FirstName  = NewName.Split('-')[0].ToLower();
                string SecondName = NewName.Split('-')[1].ToLower();

                if (BlacklistedWords.Contains(FirstName) || BlacklistedWords.Contains(SecondName))
                {
                    if (BlacklistedWords.Contains(FirstName))
                    {
                        Session.SendNotification("Desculpe, mas esse primeiro nome não é permitido");
                    }
                    else
                    {
                        Session.SendNotification("Desculpe, mas esse segundo nome não é permitido!");
                    }
                    Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                    return;
                }

                if (!PlusEnvironment.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName))
                {
                    Session.SendMessage(new UserObjectComposer(Session.GetHabbo()));
                    Session.SendNotification("Opa! Ocorreu um problema ao atualizar seu nome de usuário. Por favor digite ':mudarnick' novamente!");
                    return;
                }

                Session.GetHabbo().ChangingName = false;
                Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false);

                Session.GetHabbo().ChangeName(NewName);
                Session.GetHabbo().GetMessenger().OnStatusChanged(true);

                if (!Session.GetRoleplay().FreeNameChange)
                {
                    Session.GetHabbo().Diamonds--;
                    Session.SendMessage(new ActivityPointsComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Diamonds, Session.GetHabbo().EventPoints));
                }

                Session.SendMessage(new UpdateUsernameComposer(NewName));
                Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName));

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @name, '" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "')");
                    dbClient.AddParameter("name", NewName);
                    dbClient.RunQuery();
                }

                ICollection <RoomData> Rooms = Session.GetHabbo().UsersRooms;
                foreach (RoomData Data in Rooms)
                {
                    if (Data == null)
                    {
                        continue;
                    }

                    Data.OwnerName = NewName;
                }

                foreach (Room UserRoom in PlusEnvironment.GetGame().GetRoomManager().GetRooms().ToList())
                {
                    if (UserRoom == null || UserRoom.RoomData.OwnerName != NewName)
                    {
                        continue;
                    }

                    UserRoom.OwnerName          = NewName;
                    UserRoom.RoomData.OwnerName = NewName;

                    UserRoom.SendMessage(new RoomInfoUpdatedComposer(UserRoom.RoomId));
                }

                HabboRoleplay.Misc.RoleplayManager.SendUser(Session, Room.Id, "");
            }
        }