internal async Task <uint?> GetLevel() { if (!Client.IsConnected) { return(null); } CPlayer_GetGameBadgeLevels_Request request = new CPlayer_GetGameBadgeLevels_Request(); SteamUnifiedMessages.ServiceMethodResponse response; try { response = await UnifiedPlayerService.SendMessage(x => x.GetGameBadgeLevels(request)); } catch (Exception e) { ArchiLogger.LogGenericWarningException(e); return(null); } if (response == null) { ArchiLogger.LogNullError(nameof(response)); return(null); } if (response.Result != EResult.OK) { return(null); } CPlayer_GetGameBadgeLevels_Response body = response.GetDeserializedResponse <CPlayer_GetGameBadgeLevels_Response>(); return(body.player_level); }
static void OnLoggedOn(SteamUser.LoggedOnCallback callback) { if (callback.Result != EResult.OK) { if (callback.Result == EResult.AccountLogonDenied) { // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc) // then the account we're logging into is SteamGuard protected // see sample 5 for how SteamGuard can be handled Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected."); isRunning = false; return; } Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult); isRunning = false; return; } Console.WriteLine("Successfully logged on!"); // now that we're logged onto Steam, lets query the IPlayer service for our badge levels // first, build our request object, these are autogenerated and can normally be found in the SteamKit2.Unified.Internal namespace CPlayer_GetGameBadgeLevels_Request req = new CPlayer_GetGameBadgeLevels_Request { // we want to know our 440 (TF2) badge level appid = 440, }; // now lets send the request, this is done by building an expression tree with the IPlayer interface badgeRequest = playerService.SendMessage(x => x.GetGameBadgeLevels(req)); // alternatively, the request can be made using SteamUnifiedMessages directly, but then you must build the service request name manually // the name format is in the form of <Service>.<Method>#<Version> steamUnifiedMessages.SendMessage("Player.GetGameBadgeLevels#1", req); }