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);
        }
        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);
        }
Beispiel #3
0
        }         //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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
        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)
            {
            }
        }
Beispiel #11
0
 public static void SetSteamUser(long steamID)
 {
     SteamID = steamID;
     User    = SteamIdentity.FromSteamID(steamID);
 }
Beispiel #12
0
        static void Main(string[] args)
        {
//OPEN CONNECTION AND DEFINE TARGET PLAYER
            //open the sql connection by finding the server on the currently used computer
            SqlConnection conn = new SqlConnection("Server=COLINREILLY\\SQLEXPRESS;" +
                                                   "Database=steamDb;" +
                                                   "Integrated Security=true");

            conn.Open();

            //define target player cridentials
            //long[] steamID = new long[] { 76561198065588383, 76561198047886273 };
            SteamWebAPI.SetGlobalKey("00E30769A6BA27CB7804374A82DBD737");

            //create steam identity
            var colin   = SteamIdentity.FromSteamID(76561198047886273);
            var brenden = SteamIdentity.FromSteamID(76561198065588383);

//POPULATE GAME TABLE
            //define sql command
            string gameStatement = "INSERT INTO Game(gameId, name) VALUES(@GameID, @Name)";

            SqlCommand gameCommand = new SqlCommand(gameStatement, conn);

            gameCommand.Parameters.Add("@GameID", SqlDbType.Int);
            gameCommand.Parameters.Add("@Name", SqlDbType.VarChar, 50);

            //get the game info on the currently defined player
            var gameInfo = SteamWebAPI.General().ISteamApps().GetAppList().GetResponse();

            //cycle through the returned data and execute each command
            foreach (var game in gameInfo.Data.Apps)
            {
                Console.WriteLine(game.Name);
                Console.WriteLine(game.AppID);
                gameCommand.Parameters["@GameID"].Value = game.AppID;
                gameCommand.Parameters["@Name"].Value   = game.Name;

                gameCommand.ExecuteNonQuery();
                if (game.AppID > 300)
                {
                    break;
                }
            }

//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(colin).GetResponse();

            //cycle through the returned data and execute each command
            foreach (var player in playerInfo.Data.Players)
            {
                Console.WriteLine(colin.SteamID);
                Console.WriteLine(player.PersonaName);
                Console.WriteLine(player.ProfileUrl);
                Console.WriteLine(player.LastLogOff);
                playerCommand.Parameters["@SteamId"].Value    = colin.SteamID;
                playerCommand.Parameters["@PersonName"].Value = player.PersonaName;
                playerCommand.Parameters["@ProfileURL"].Value = player.ProfileUrl;
                playerCommand.Parameters["@LastLogOff"].Value = player.LastLogOff;

                playerCommand.ExecuteNonQuery();
            }

//POPULATE ACHIEVEMENT TABLE
            //define sql command
            string achievementStatement = "INSERT INTO Achievement(Name, gameId) VALUES(@Name, @GameId)";

            SqlCommand achievementCommand = new SqlCommand(achievementStatement, conn);

            achievementCommand.Parameters.Add("@Name", SqlDbType.VarChar, 50);
            achievementCommand.Parameters.Add("@GameId", SqlDbType.Int);

            //get the game info on the currently defined player
            var achievementInfo = SteamWebAPI.General().ISteamUserStats().GetPlayerAchievements(440, colin).GetResponse();

            //cycle through the returned data and execute each command
            foreach (var achievement in achievementInfo.Data.Achievements)
            {
                Console.WriteLine(achievement.APIName);
                Console.WriteLine(440);
                achievementCommand.Parameters["@Name"].Value   = achievement.APIName;
                achievementCommand.Parameters["@GameId"].Value = 440;

                achievementCommand.ExecuteNonQuery();
            }

            //close sql connection and exit
            conn.Close();
            Console.WriteLine("press enter to exit");
            Console.ReadLine();
        }
Beispiel #13
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                 JsonSerializer serializer)
 {
     return(SteamIdentity.FromSteamID(long.Parse(reader.Value.ToNullableString())));
 }
Beispiel #14
0
        // GET: GameLists/Create
        public ActionResult Create()
        {
            string          currentUserID = User.Identity.GetUserId();
            ApplicationUser currentUser   = Database.Users.Find(currentUserID);
            string          providerKey   = currentUser.Logins.First().ProviderKey;

            providerKey = providerKey.Substring(providerKey.Length - 17);

            SteamWebAPI.SetGlobalKey(Security.apiKey);

            var identity = SteamIdentity.FromSteamID(Int64.Parse(providerKey));

            //JSON response from Steam
            var response = SteamWebAPI.General().IPlayerService().GetOwnedGames(identity).IncludeAppInfo().GetResponse();

            //Iterate through each item and add it to database
            foreach (var res in response.Data.Games)
            {
                TimeSpan timeSpan = res.PlayTimeTotal;

                int totalHours = (int)timeSpan.TotalHours;

                TagList tagList = new TagList()
                {
                    appID  = res.AppID,
                    userID = currentUserID
                };

                GameDescrip gameDesc = new GameDescrip()
                {
                    appID            = res.AppID,
                    playtime_forever = totalHours,
                    userId           = currentUserID,
                    visible          = true, //True by default for now.
                    Tags             = tagList
                };

                Game game = new Game();

                if (res.Name != null)
                {
                    game.name = res.Name;
                }
                else
                {
                    game.name = res.AppID.ToString();
                }
                game.appID          = res.AppID;
                game.img_header_url = "http://cdn.akamai.steamstatic.com/steam/apps/" + res.AppID + "/header.jpg";
                game.img_icon_url   = "http://media.steampowered.com/steamcommunity/public/images/apps/" + res.AppID + "/" + res.IconUrl + ".jpg";
                game.img_logo_url   = "http://media.steampowered.com/steamcommunity/public/images/apps/" + res.AppID + "/" + res.LogoUrl + ".jpg";

                //Ensure User entry for game doesn't exist in table
                bool doesLibraryExist = (Database.GDescriptions.Any(u => u.userId.Equals(gameDesc.userId)) &&
                                         Database.GDescriptions.Any(a => a.appID.Equals(game.appID))); //AppID
                //Ensure Game doesn't already exist in game table
                bool doesGameExist = Database.Games.Any(a => a.appID.Equals(game.appID));

                if (doesLibraryExist)
                {
                    // Do nothing
                }
                else
                {
                    if (doesGameExist)
                    {
                        //Add existing game object
                        gameDesc.Game = Database.Games.Where(a => a.appID == game.appID).SingleOrDefault();
                    }
                    else
                    {
                        //add newly created game object
                        gameDesc.Game = game;
                        Database.Games.Add(game);
                    }
                    //Add User Record for game
                    Database.GDescriptions.Add(gameDesc);
                }
            }
            currentUser.GameCount = response.Data.GameCount;
            Database.SaveChanges();

            return(RedirectToAction("Index"));
        }