public bool HasMw2OrMw3(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetOwnedGamesBuilder gamesBuilder = SteamWebAPI.General().IPlayerService().GetOwnedGames(identity); try { GetOwnedGamesResponse response = gamesBuilder.GetResponse(); if (response != null && response.Data != null) { if (response.Data.Games != null) { var mw2AndMw3 = response.Data.Games.FirstOrDefault(x => x.AppID == 10180 || x.AppID == 42690); if (mw2AndMw3 != null) { return(true); } } } } catch (Exception) { } return(false); }
/// <summary> /// Get player level. /// </summary> /// <param name="identity">The identity of the player.</param> /// <returns></returns> public GetSteamLevelBuilder GetSteamLevel(SteamIdentity identity) { return(new GetSteamLevelBuilder(new GetSteamLevelRequest(this.Key) { SteamID = identity.SteamID })); }
static void populateGameOwnedTable(SqlConnection conn, SteamIdentity person) { //POPULATE GameOwned TABLE //define sql command string gameOwnedStatement = "INSERT INTO GameOwned(steamId, gameId, playTimeTwoWeek, playTimeForever) VALUES(@SteamId, @GameId, @PlayTimeTwoWeek, @PlayTimeForever)"; SqlCommand gameOwnedCommand = new SqlCommand(gameOwnedStatement, conn); gameOwnedCommand.Parameters.Add("@SteamId", SqlDbType.BigInt); gameOwnedCommand.Parameters.Add("@GameId", SqlDbType.Int); gameOwnedCommand.Parameters.Add("@PlayTimeTwoWeek", SqlDbType.Int); gameOwnedCommand.Parameters.Add("@PlayTimeForever", SqlDbType.Int); //get all the games owned var gameOwnedInfo = SteamWebAPI.General().IPlayerService().GetOwnedGames(person).GetResponse(); //cycle through the returned data and execute each command foreach (var gameOwned in gameOwnedInfo.Data.Games) { gameOwnedCommand.Parameters["@SteamId"].Value = person.SteamID; gameOwnedCommand.Parameters["@GameId"].Value = gameOwned.AppID; gameOwnedCommand.Parameters["@PlayTimeTwoWeek"].Value = gameOwned.PlayTime2Weeks.TotalMinutes; gameOwnedCommand.Parameters["@PlayTimeForever"].Value = gameOwned.PlayTimeTotal.TotalMinutes; gameOwnedCommand.ExecuteNonQuery(); } }
/// <summary> /// Get owned games for player. /// </summary> /// <param name="identity">The identity of the player.</param> /// <returns></returns> public GetOwnedGamesBuilder GetOwnedGames(SteamIdentity identity) { return(new GetOwnedGamesBuilder(new GetOwnedGamesRequest(this.Key) { SteamID = identity.SteamID })); }
/// <summary> /// User group data. /// </summary> /// <param name="identity">The identity of the user to retrieve a user group list for.</param> /// <returns></returns> public GetUserGroupListBuilder GetUserGroupList(SteamIdentity identity) { return(new GetUserGroupListBuilder(new GetUserGroupListRequest(this.Key) { SteamID = identity.SteamID })); }
}//end of getAllData static void populatePlayerTable(SqlConnection conn, SteamIdentity person) { //POPULATE PLAYER TABLE //define sql command string playerStatement = "INSERT INTO Player(steamId, personName, profileURL, lastLogOff) VALUES(@SteamId, @PersonName, @ProfileURL, @LastLogOff)"; SqlCommand playerCommand = new SqlCommand(playerStatement, conn); playerCommand.Parameters.Add("@SteamId", SqlDbType.BigInt); playerCommand.Parameters.Add("@PersonName", SqlDbType.VarChar, 30); playerCommand.Parameters.Add("@ProfileURL", SqlDbType.VarChar, 75); playerCommand.Parameters.Add("@LastLogOff", SqlDbType.DateTime); //get the game info on the currently defined player var playerInfo = SteamWebAPI.General().ISteamUser().GetPlayerSummaries(person).GetResponse(); //cycle through the returned data and execute each command foreach (var player in playerInfo.Data.Players) { playerCommand.Parameters["@SteamId"].Value = person.SteamID; playerCommand.Parameters["@PersonName"].Value = player.PersonaName; playerCommand.Parameters["@ProfileURL"].Value = player.ProfileUrl; playerCommand.Parameters["@LastLogOff"].Value = player.LastLogOff; playerCommand.ExecuteNonQuery(); } }
} //end main function static void getAllData(SqlConnection conn) { SteamWebAPI.SetGlobalKey("00E30769A6BA27CB7804374A82DBD737"); //create steam identity SteamIdentity[] steamID = new SteamIdentity[] { SteamIdentity.FromSteamID(76561198047886273), //colin SteamIdentity.FromSteamID(76561198065588383), //brenden SteamIdentity.FromSteamID(76561198018133285), //john SteamIdentity.FromSteamID(76561197983072534), SteamIdentity.FromSteamID(76561197996591065), SteamIdentity.FromSteamID(76561197999979429), SteamIdentity.FromSteamID(76561198009844144) }; populateGameTable(conn); foreach (var player in steamID) { populatePlayerTable(conn, player); populateGameOwnedTable(conn, player); populateAchievementTable(conn, player); populateAchievementOwnedTable(conn, player); populateFriendsHaveTable(conn, player); } //close sql connection and exit conn.Close(); Console.WriteLine("press enter to exit"); Console.ReadLine(); }//end of getAllData
public BanType GetBanType(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetPlayerBansBuilder summaryBuilder = SteamWebAPI.General().ISteamUser().GetPlayerBans(identity); try { GetPlayerBansResponse response = summaryBuilder.GetResponse(); if (response != null && response.Players != null) { GetPlayerBansResponsePlayer player = response.Players.FirstOrDefault(); if (player != null) { if (player.VACBanned) { // Ignore MW2/3 vac bans bool hasMw2OrMw3 = HasMw2OrMw3(steamId); return(hasMw2OrMw3 ? BanType.None : BanType.VAC); } else if (player.CommunityBanned) { return(BanType.Community); } } } } catch (Exception) { } return(BanType.None); }
public TimeSpan IsCsgoInstalled(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetOwnedGamesBuilder gamesBuilder = SteamWebAPI.General().IPlayerService().GetOwnedGames(identity); try { GetOwnedGamesResponse response = gamesBuilder.GetResponse(); if (response != null && response.Data != null) { if (response.Data.Games != null) { var csgo = response.Data.Games.FirstOrDefault(x => x.AppID == 730); if (csgo != null) { return(csgo.PlayTimeTotal); } } } } catch (Exception) { } return(TimeSpan.Zero); }
/// <summary> /// Returns the user stats for game. /// </summary> /// <param name="appID">AppID that we're getting achievements for.</param> /// <param name="identity">Identity of user.</param> /// <returns></returns> public GetUserStatsForGameBuilder GetUserStatsForGame(int appID, SteamIdentity identity) { return(new GetUserStatsForGameBuilder( new GetUserStatsForGameRequest(this.Key) { AppID = appID, SteamID = identity.SteamID })); }
/// <summary> /// Returns the current number of players for an app. /// </summary> /// <param name="appID">AppID that we're getting achievements for.</param> /// <param name="identity">Identity of user.</param> /// <returns></returns> public GetPlayerAchievementsBuilder GetPlayerAchievements(int appID, SteamIdentity identity) { return(new GetPlayerAchievementsBuilder( new GetPlayerAchievementsRequest(this.Key) { AppID = appID, SteamID = identity.SteamID })); }
/// <summary> /// Lists items in a player's backpack. /// <param name="identity">The identity of the user the backpack will be retrieved for.</param> /// </summary> public GetPlayerItemsBuilder GetPlayerItems(SteamIdentity identity) { return(new GetPlayerItemsBuilder( new GetPlayerItemsRequest(this.Key, this.AppID) { SteamID = identity.SteamID })); }
/// <summary> /// User friend list. /// </summary> /// <param name="identity">The identity of the user to retrieve a list for.</param> /// <param name="relationship">Filter by a given role.</param> /// <returns></returns> public GetFriendListBuilder GetFriendList(SteamIdentity identity, RelationshipType relationship) { return(new GetFriendListBuilder( new GetFriendListRequest(this.Key) { SteamID = identity.SteamID, Relationship = relationship })); }
/// <summary> /// Get badge progress for player. /// </summary> /// <param name="identity">The identity of the player.</param> /// <returns></returns> public GetCommunityBadgeProgressBuilder GetCommunityBadgeProgress(SteamIdentity identity) { return(new GetCommunityBadgeProgressBuilder( new GetCommunityBadgeProgressRequest(this.Key) { SteamID = identity.SteamID })); }
/// <summary> /// Stats about a particular player within a tournament. /// <param name="identity">SteamIdentity.</param> /// </summary> public GetTournamentPlayerStatsBuilder GetTournamentPlayerStats(SteamIdentity identity) { return(new GetTournamentPlayerStatsBuilder( new GetTournamentPlayerStatsRequest(this.Key, this.AppID) { AccountID = identity.AccountID })); }
public static void testFunction(string _parameter, Channel _channel, DiscordClient _client, User _user) { var steamIdentity = SteamIdentity.FromSteamID(Convert.ToInt64(_parameter)); string steamUserVanity = SteamWebAPI.General().ISteamUser().ResolveVanityURL(_parameter).GetResponseString(); string friendsList = SteamWebAPI.General().ISteamUser().GetFriendList(steamIdentity, RelationshipType.Friend).GetResponseString(RequestFormat.XML); _channel.SendMessage(steamUserVanity); _channel.SendMessage("Steam ID: " + friendsList); }
public async Task <TeamSelectedSteamIdentity[]> FindAllFrom(SteamIdentity steamIdentity) { return((await _liteDb.LiteDatabaseAsync .GetCollection <TeamSelectedSteamIdentity>("TeamSelectedSteamIdentity") .Include(x => x.SteamIdentity) .Include(x => x.SteamIdentity.LiteDbUser) .Include(x => x.Team) .FindAsync(x => x.SteamIdentity.Id == steamIdentity.Id)).ToArray()); }
private void CreateAndInitializeATeamWithAMember(out LiteDbUser user, out SteamIdentity steamIdentity, out Team team) { user = ServerSelectedModServiceTests.InsertUserAndSteamIdentity(_steamIdentityService, _userManager); steamIdentity = _steamIdentityService.FindAll().GetAwaiter().GetResult().First(); team = CreateTeam(_teamService); _teamSelectedSteamIdentityService.Insert(new TeamSelectedSteamIdentity { Team = team, SteamIdentity = steamIdentity, RoleOverwrite = "" }); }
private static SteamIdentity CrawlSteamIdentity(ExternalLoginInfo info) { var steamIdentity = new SteamIdentity(); if (info.Principal.HasClaim(c => c.Type == ClaimTypes.NameIdentifier)) { steamIdentity.Id = info.Principal.FindFirstValue(ClaimTypes.NameIdentifier).Split("/").Last(); } if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Name)) { steamIdentity.Name = info.Principal.FindFirstValue(ClaimTypes.Name); } return(steamIdentity); }
public static void Init(long steamID) { if (steamID == 0) { IsSteamProfile = false; return; } SteamWebAPI.SetGlobalKey("1E5E3956484C372C2D9AE6D58EFA4F69"); var appListResponse = SteamWebAPI.General().ISteamApps().GetAppList().GetResponse(); AppList = appListResponse.Data.Apps; SteamID = steamID; User = SteamIdentity.FromSteamID(steamID); }
public async Task <IActionResult> AddSteamIdentity(SteamIdentity steamIdentity) { var exist = await _steamIdentityService.FindOne(steamIdentity.Id); if (exist != null) { return(BadRequest("This steamId already exist and your only allow to add not to edit!")); } //security so that the LiteDbUser not can be set here steamIdentity.LiteDbUser = null; await _steamIdentityService.Insert(steamIdentity); //Handle more stuff can be seen in model return(await Index()); }
public List <string> getFriends(long steamID) { SteamWebAPI.SetGlobalKey("2E063F9BD27D3C9AED847FAB0D876E01"); var name = SteamIdentity.FromSteamID(steamID); var game = SteamWebAPI.General().ISteamUser().GetFriendList(name, RelationshipType.All).GetResponse(); var friends = SteamWebAPI.General().ISteamUser().GetFriendList(name, RelationshipType.All).GetResponse(); List <string> result = new List <String>(); List <String> friendNames = new List <string>(); foreach (var friend in friends.Data.Friends) { var level = SteamWebAPI.General().IPlayerService().GetSteamLevel(friend.Identity).GetResponse(); result.Add(friend.Identity.SteamID + " is level: " + level.Data.PlayerLevel.ToString()); } return(result); }
public async Task <IActionResult> EditOwnSteamIdentity() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var bla = await _steamIdentityService.FindOne(new ObjectId(userId)); if (bla == null) { bla = new SteamIdentity { LiteDbUserId = userId, LiteDbUser = (await _userService.FindAll()).FirstOrDefault(x => x.Id == new ObjectId(userId)) } } ; //Handle more stuff can be seen in model ViewBag.IsOwnSteamIdentity = true; return(View("SteamIdentity", bla)); }
static void populateAchievementOwnedTable(SqlConnection conn, SteamIdentity person) { //POPULATE ACHIEVEMENT OWNED TABLE //define sql command string achievementStatement = "INSERT INTO AchievementOwned(playerId, gameId, name) VALUES(@PlayerId, @GameId, @Name)"; SqlCommand achievementCommand = new SqlCommand(achievementStatement, conn); achievementCommand.Parameters.Add("@PlayerId", SqlDbType.BigInt); achievementCommand.Parameters.Add("@GameId", SqlDbType.Int); achievementCommand.Parameters.Add("@Name", SqlDbType.VarChar, 50); //get all the games owned var gameOwnedInfo = SteamWebAPI.General().IPlayerService().GetOwnedGames(person).GetResponse(); //cycle through the returned data and execute each command foreach (var gameOwned in gameOwnedInfo.Data.Games) { //get the achievement info on the currently defined player var achievementInfo = SteamWebAPI.General().ISteamUserStats().GetPlayerAchievements(gameOwned.AppID, person).GetResponse(); //the try for see if there Achievements try { //cycle through the returned data and execute each command foreach (var achievement in achievementInfo.Data.Achievements) { achievementCommand.Parameters["@PlayerId"].Value = person.SteamID; achievementCommand.Parameters["@GameId"].Value = gameOwned.AppID; achievementCommand.Parameters["@Name"].Value = achievement.APIName; achievementCommand.ExecuteNonQuery(); } } catch { //Console.WriteLine("can't"); } } }
protected override GetTeamInfoByTeamIDResponseTeam Create(Type objectType, JObject jsonObject) { var team = new GetTeamInfoByTeamIDResponseTeam(); team.TeamID = long.Parse(jsonObject["team_id"].ToNullableString()); team.Name = jsonObject["name"].ToNullableString(); team.Tag = jsonObject["tag"].ToNullableString(); team.TimeCreated = long.Parse(jsonObject["time_created"].ToNullableString()).ToDateTime(); team.Rating = jsonObject["rating"].ToNullableString(); team.Logo = long.Parse(jsonObject["logo"].ToNullableString()); team.LogoSponsor = long.Parse(jsonObject["logo_sponsor"].ToNullableString()); team.CountryCode = jsonObject["country_code"].ToNullableString(); team.Url = jsonObject["url"].ToNullableString(); team.GamesPlayedWithCurrentRoster = int.Parse(jsonObject["games_played_with_current_roster"].ToNullableString()); team.AdminIdentity = SteamIdentity.FromAccountID(long.Parse(jsonObject["admin_account_id"].ToNullableString())); team.PlayerIdentities = new List <SteamIdentity>(); team.Leagues = new List <GetTeamInfoByTeamIDResponseLeague>(); var playerAccountIDs = jsonObject.Properties().Where(x => x.Name.Contains("player_")); foreach (var playerAccountID in playerAccountIDs) { team.PlayerIdentities.Add( SteamIdentity.FromAccountID(long.Parse(playerAccountID.Value.ToNullableString()))); } var leagueIDs = jsonObject.Properties().Where(x => x.Name.Contains("league_id")); foreach (var leagueID in leagueIDs) { team.Leagues.Add(new GetTeamInfoByTeamIDResponseLeague { LeagueID = long.Parse(leagueID.Value.ToNullableString()) }); } return(team); }
public static bool DoIHaveDayZ(long steamId) { SteamWebAPI.SetGlobalKey("26DF222A39656E4F4B38BA61B7E57744"); var me = SteamIdentity.FromSteamID(steamId); var myGames = SteamWebAPI .General() .IPlayerService() .GetOwnedGames(me) .GetResponse().Data .Games; if (myGames != null && myGames.Any(g => g.AppID == DayZAppId)) { return(true); } return(false); }
static void populateFriendsHaveTable(SqlConnection conn, SteamIdentity person) { string friendStatement = "INSERT INTO FriendHave(friendOne, friendTwo, friendSince) VALUES(@FriendOne, @FriendTwo, @FriendSince)"; SqlCommand friendCommand = new SqlCommand(friendStatement, conn); friendCommand.Parameters.Add("@FriendOne", SqlDbType.BigInt); friendCommand.Parameters.Add("@FriendTwo", SqlDbType.BigInt); friendCommand.Parameters.Add("@FriendSince", SqlDbType.DateTime); //get all the games owned var friendInfo = SteamWebAPI.General().ISteamUser().GetFriendList(person, RelationshipType.Friend).GetResponse(); //cycle through the returned data and execute each command foreach (var friend in friendInfo.Data.Friends) { friendCommand.Parameters["@FriendOne"].Value = person.SteamID; friendCommand.Parameters["@FriendTwo"].Value = friend.Identity.SteamID; friendCommand.Parameters["@FriendSince"].Value = friend.FriendSince; friendCommand.ExecuteNonQuery(); } }
public string GetName(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetPlayerSummariesBuilder summaryBuilder = SteamWebAPI.General().ISteamUser().GetPlayerSummaries(identity); try { GetPlayerSummariesResponse response = summaryBuilder.GetResponse(); if (response != null && response.Data != null) { GetPlayerSummariesResponsePlayer player = response.Data.Players.FirstOrDefault(); if (player != null) { return(player.PersonaName); } } } catch (Exception) { } return(""); }
public void FindFriends(long steamId) { SteamIdentity identity = SteamIdentity.FromSteamID(steamId); GetFriendListBuilder friendBuilder = SteamWebAPI.General().ISteamUser().GetFriendList(identity, RelationshipType.Friend); try { var response = friendBuilder.GetResponse(); if (response != null && response.Data != null) { List <Friend> friends = response.Data.Friends.ToList(); foreach (Friend friend in friends) { _queue.Push(friend.Identity.SteamID); } Console.WriteLine("Found friends for {0} (found {1}), queue: {2}", steamId, friends.Count, _queue.Count); } } catch (Exception) { } }
public async Task <string> Insert(SteamIdentity steamIdentity) { return(await _liteDb.LiteDatabaseAsync.GetCollection <SteamIdentity>("SteamIdentity") .InsertAsync(steamIdentity)); }