Answer the question
In order to leave comments, you need to log in
How to properly initialize an object?
It throws an error when I try to subscribe to an event.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Instance.manager.Subscribe<SteamClient.ConnectedCallback>(BinVerify.OnConnected);
public static void OnConnected(SteamClient.ConnectedCallback callback)
{
Console.WriteLine($"Connected to Steam! Logging in '{Instance.botConfig.login}'...");
byte[] sentryHash = null;
if (File.Exists("sentry.bin"))
{
// if we have a saved sentry file, read and sha-1 hash it
byte[] sentryFile = File.ReadAllBytes("sentry.bin");
sentryHash = CryptoHelper.SHAHash(sentryFile);
}
Instance.steamUser.LogOn(new SteamUser.LogOnDetails
{
Username = Instance.botConfig.login,
Password = Instance.botConfig.password,
// in this sample, we pass in an additional authcode
// this value will be null (which is the default) for our first logon attempt
AuthCode = Instance.authCode,
TwoFactorCode = Instance.twoFactorAuth,
// our subsequent logons use the hash of the sentry file as proof of ownership of the file
// this will also be null for our first (no authcode) and second (authcode only) logon attempts
SentryFileHash = sentryHash,
ClientLanguage = "Russian"
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question