Exemple #1
0
        public static Habbo GetHabboById(int UserId)
        {
            try
            {
                if (GetGame() == null)
                {
                    return(null);
                }

                if (GetGame().GetClientManager() == null)
                {
                    return(null);
                }

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

                if (Client != null)
                {
                    Habbo User = Client.GetHabbo();
                    if (User != null && User.Id > 0)
                    {
                        if (_usersCached.ContainsKey(UserId))
                        {
                            _usersCached.TryRemove(UserId, out User);
                        }
                        return(User);
                    }
                }
                else
                {
                    try
                    {
                        if (_usersCached.ContainsKey(UserId))
                        {
                            return(_usersCached[UserId]);
                        }
                        else
                        {
                            UserData data = UserDataFactory.GetUserData(UserId);
                            if (data != null)
                            {
                                Habbo Generated = data.user;
                                if (Generated != null)
                                {
                                    Generated.InitInformation(data);
                                    _usersCached.TryAdd(UserId, Generated);
                                    return(Generated);
                                }
                            }
                        }
                    }
                    catch { return(null); }
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }
Exemple #2
0
        internal static Habbo getHabboForId(uint UserId)
        {
            Habbo result;

            try
            {
                GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (clientByUserID != null)
                {
                    Habbo habbo = clientByUserID.GetHabbo();
                    if (habbo != null && habbo.Id > 0u)
                    {
                        if (CyberEnvironment.usersCached.Contains(UserId))
                        {
                            CyberEnvironment.usersCached.Remove(UserId);
                        }
                        result = habbo;
                        return(result);
                    }
                }
                else
                {
                    if (CyberEnvironment.usersCached.Contains(UserId))
                    {
                        result = (Habbo)CyberEnvironment.usersCached[UserId];
                        return(result);
                    }
                    UserData userData = UserDataFactory.GetUserData(checked ((int)UserId));
                    Habbo    user     = userData.user;
                    if (user != null)
                    {
                        user.InitInformation(userData);
                        CyberEnvironment.usersCached.Add(UserId, user);
                        result = user;
                        return(result);
                    }
                }
                result = null;
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Exemple #3
0
 internal static Habbo getHabboForId(uint UserId)
 {
     try
     {
         HabboHotel.GameClients.GameClient game = GetGame().GetClientManager().GetClientByUserID(UserId);
         if (game != null)
         {
             Habbo noUser = game.GetHabbo();
             if (noUser != null && noUser.Id > 0)
             {
                 if (usersCached.ContainsKey(UserId))
                 {
                     usersCached.Remove(UserId);
                 }
                 return(noUser);
             }
         }
         else
         {
             if (usersCached.ContainsKey(UserId))
             {
                 return(usersCached[UserId]);
             }
             else
             {
                 UserData data      = UserDataFactory.GetUserData((int)UserId);
                 Habbo    Generated = data.user;
                 if (Generated != null)
                 {
                     Generated.InitInformation(data);
                     usersCached.Add(UserId, Generated);
                     return(Generated);
                 }
             }
         }
         return(null);
     }
     catch { return(null); }
 }