/// <summary> /// Update the steam token of the program used to communicate with steam /// </summary> private static void UpdateSteamToken() { var msg = new StdData("", Program.HostId, 2000); var rec = new StdData(CustomSocket.StartClient(msg.Data)); if (rec.PacketType == 2000) { Program.SteamToken = rec.Text; } }
/// <summary> /// Asks the server for a new host id /// </summary> public static void UpdateHostId() { var msg = new StdData("", Program.HostId, 2001); var rec = new StdData(CustomSocket.StartClient(msg.Data)); if (rec.PacketType == 2001) { ushort.TryParse(rec.Text, out Program.HostId); } Console.WriteLine("New host id has been assigned: " + Program.HostId); }
/// <summary> /// Shows the general statistics for the server(The total stats for the tables) /// </summary> public static void ShowGenStats() { while (true) { if (Program.HostId == 0) { Console.Clear(); Updater.UpdateHostId(); Thread.Sleep(1000); } Console.Clear(); Console.WriteLine("Server IP: " + Program.IpAddress + " Port: " + Program.Port + " HostId: " + Program.HostId); Console.WriteLine(); Console.WriteLine("Getting the information from the server"); var information = new StdData(CustomSocket.StartClient(new StdData("", Program.HostId, 2050).Data)).Text; Console.WriteLine(information); Console.WriteLine("1. Refresh"); Console.WriteLine("2. Exit"); var o = Console.ReadLine(); if (o == "1") { continue; } break; } }
/// <summary> /// Shows a players /// </summary> /// <param name="user"></param> /// <returns></returns> public static List <User> ShowPlayerStats(StdData user) { var sid = user.Text; var dt = Program.Select( "SELECT tbl_gcollection.pk_gamehistory, tbl_user.pk_steamid, username, customurl, visibilitystate, membersince, location, realname, lastlogoff, lastsummaryupdate, lastfriendupdate, lastgameupdate, timestamp, fk_appid, tbl_games.NAME, minsonrecord, minslast2weeks FROM tbl_user LEFT JOIN (SELECT tbl_gcollectionlink.pk_steamid, timestamp FROM tbl_gcollectionlink RIGHT JOIN tbl_user ON tbl_gcollectionlink.pk_steamid = tbl_user.pk_steamid WHERE tbl_user.pk_steamid = '" + sid + "' OR username = '******' ORDER BY timestamp DESC LIMIT 1) t ON tbl_user.pk_steamid = t.pk_steamid LEFT JOIN tbl_gcollection ON t.pk_steamid = tbl_gcollection.fk_steamid AND t.timestamp = tbl_gcollection.FK_timestamp LEFT JOIN tbl_games ON tbl_gcollection.FK_AppID = tbl_games.pk_appid WHERE tbl_user.pk_steamid = '" + sid + "' OR tbl_user.username = '******';"); var count = 0; var list = new List <User> { new User() }; while (count != dt.Rows.Count) { if (list[list.Count - 1].SteamId != (ulong)dt.Rows[count][1]) { if (list[list.Count - 1].SteamId == 0) { list[list.Count - 1].SteamId = (ulong)dt.Rows[count][1]; } else { list.Add(new User()); list[list.Count - 1].SteamId = (ulong)dt.Rows[count][1]; } list[list.Count - 1].UserName = (string)dt.Rows[count][2]; list[list.Count - 1].CustomUrl = (string)dt.Rows[count][3]; list[list.Count - 1].VisibilityState = (bool)dt.Rows[count][4]; list[list.Count - 1].LastSummaryUpdate = (DateTime)dt.Rows[count][9]; list[list.Count - 1].LastLogOff = (DateTime)dt.Rows[count][8]; if (list[list.Count - 1].VisibilityState) { list[list.Count - 1].Location = (string)dt.Rows[count][6]; if (dt.Rows[count][7].GetType() != typeof(DBNull)) { list[list.Count - 1].RealName = (string)dt.Rows[count][7]; } list[list.Count - 1].MemberSince = (DateTime)dt.Rows[count][5]; list[list.Count - 1].LastGameUpdate = (DateTime)dt.Rows[count][11]; if (dt.Rows[count][10].GetType() != typeof(DBNull)) { list[list.Count - 1].LastFriendUpdate = (DateTime)dt.Rows[count][10]; } } } if (list[list.Count - 1].VisibilityState) { var result = new int(); if (!int.TryParse(dt.Rows[count][16].ToString(), out result)) { count++; continue; } var temp = new GameHistory { AppId = (int)dt.Rows[count][13], OnRecord = (int)dt.Rows[count][15] }; if (dt.Rows[count][14].GetType() != typeof(DBNull)) { temp.Name = (string)dt.Rows[count][14]; } list[list.Count - 1].ListOfGames.Add(temp); } count++; } if (list[0].SteamId == 0) { list.RemoveAt(0); } return(list); }