Exemple #1
0
        public static string GetUsernameById(int UserId)
        {
            string Name = "Unknown User";

            GameClient Client = GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client != null && Client.GetHabbo() != null)
            {
                return(Client.GetHabbo().Username);
            }

            UserCache User = HabboEnvironment.GetGame().GetCacheManager().GenerateUser(UserId);

            if (User != null)
            {
                return(User.Username);
            }

            using (IQueryAdapter dbClient = HabboEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `username` FROM `users` WHERE id = @id LIMIT 1");
                dbClient.AddParameter("id", UserId);
                Name = dbClient.getString();
            }

            if (string.IsNullOrEmpty(Name))
            {
                Name = "Unknown User";
            }

            return(Name);
        }