SteamKit icon indicating copy to clipboard operation
SteamKit copied to clipboard

SteamFriends returns null

Open DevPhreak opened this issue 9 years ago • 2 comments

Can log in all fine, however when I use the SteamFriends object it always throws

An unhandled exception of type 'System.NullReferenceException' occurred

Code: SteamClient steamClient; CallbackManager manager; SteamUser steamUser; SteamFriends steamFriends;

void OnAccountInfo(SteamUser.AccountInfoCallback callback)
        {
            steamFriends.SetPersonaState(EPersonaState.Online);    //crashes here
        }

        void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            int friendCount = steamFriends.GetFriendCount();    //and here
            loginfo("We have " + friendCount + " friends.");
            for (int x = 0; x < friendCount; x++)
            {
                SteamID steamIdFriend = steamFriends.GetFriendByIndex(x);
                Console.WriteLine("Friend: {0}", steamIdFriend.Render());
                friends.Add(steamIdFriend.Render(), x);
            }        
        }

The objects arent static because im using a form.

DevPhreak avatar Feb 03 '17 16:02 DevPhreak

Are you retrieving instances of SteamFriends with steamFriends = steamClient.GetHandler<SteamFriends>()?

voided avatar Feb 03 '17 16:02 voided

Nope, that was missing. Such an obvious mistake. Thanks!

DevPhreak avatar Feb 03 '17 16:02 DevPhreak