SteamKit
SteamKit copied to clipboard
SteamFriends returns null
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.
Are you retrieving instances of SteamFriends with steamFriends = steamClient.GetHandler<SteamFriends>()?
Nope, that was missing. Such an obvious mistake. Thanks!