/// <summary> /// Handles a player stat request /// </summary> static public void Handle_CS_PlayerStatsRequest(CS_PlayerStatsRequest <Zone> pkt, Zone zone) { //Attempt to find the player in question Zone.Player player = zone.getPlayer(pkt.player.id); if (player == null) { //Make a note Log.write(TLog.Warning, "Ignoring player stats request for #{0}, not present in zone mirror.", pkt.player.id); return; } using (InfantryDataContext db = zone._server.getContext()) { //What sort of request are we dealing with? switch (pkt.type) { case CS_PlayerStatsRequest <Zone> .ChartType.ScoreLifetime: { //Get the top100 stats sorted by points var stats = (from st in db.stats where st.zone1 == zone._zone orderby st.assistPoints + st.bonusPoints + st.killPoints descending select st).Take(100); MemoryStream stream = new MemoryStream(); foreach (Data.DB.stats lifetime in stats) { if (lifetime != null && writeElementToBuffer(lifetime, stream) == false) { continue; } } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreLifetime; response.columns = "Top100 Lifetime Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreDaily: { DateTime now = DateTime.Today; //Get the top100 stats sorted by points //For today's date var daily = (from dt in db.statsDailies where dt.zone1 == zone._zone && dt.date >= now orderby dt.assistPoints + dt.bonusPoints + dt.killPoints descending select dt).Take(100); //Are they requesting a specific date? if (pkt.options != "") { //Player wants to see yesterday's date if (pkt.options.Equals("-1")) { DateTime today = now; now = now.AddDays(-1); daily = (from dt in db.statsDailies where dt.zone1 == zone._zone && dt.date >= now && dt.date < today orderby dt.assistPoints + dt.bonusPoints + dt.killPoints descending select dt).Take(100); } else //Specific date { string[] args = pkt.options.Split('-'); string final = string.Join("/", args); try { now = DateTime.Parse(final, System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); } catch (FormatException) { //Wrong format, use yesterday as default now = (now.AddDays(-1)); } DateTime add = now.AddDays(1); daily = (from dt in db.statsDailies where dt.zone1 == zone._zone && dt.date >= now && dt.date < add orderby dt.assistPoints + dt.bonusPoints + dt.killPoints descending select dt).Take(100); } } MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsDaily day in daily) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(day.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = day.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(day.vehicleDeaths); bw.Write(day.vehicleKills); bw.Write(day.killPoints); bw.Write(day.deathPoints); bw.Write(day.assistPoints); bw.Write(day.bonusPoints); bw.Write(day.kills); bw.Write(day.deaths); bw.Write((int)0); bw.Write(day.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementDaily " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreDaily; response.columns = "Top100 Daily Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreWeekly: { DateTime now = DateTime.Today; if (((int)now.DayOfWeek) > 0) { now = now.AddDays(-((int)now.DayOfWeek)); } //Get the top100 stats sorted by points //For this week var weekly = (from wt in db.statsWeeklies where wt.zone1 == zone._zone && wt.date >= now orderby wt.assistPoints + wt.bonusPoints + wt.killPoints descending select wt).Take(100); //Are they requesting a specific date? if (pkt.options != "") { //Player wants to see last week's date if (pkt.options.Equals("-1")) { DateTime today = now; now = now.AddDays(-7); weekly = (from wt in db.statsWeeklies where wt.zone1 == zone._zone && wt.date >= now && wt.date < today orderby wt.assistPoints + wt.bonusPoints + wt.killPoints descending select wt).Take(100); } else //Specific date { string[] args = pkt.options.Split('-'); string final = string.Join("/", args); try { now = DateTime.Parse(final, System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); } catch (FormatException) { //Wrong format, use last week as default now = (now.AddDays(-7)); } DateTime add = now.AddDays(7); weekly = (from wt in db.statsWeeklies where wt.zone1 == zone._zone && wt.date >= now && wt.date < add orderby wt.assistPoints + wt.bonusPoints + wt.killPoints descending select wt).Take(100); } } MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsWeekly week in weekly) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(week.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = week.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(week.vehicleDeaths); bw.Write(week.vehicleKills); bw.Write(week.killPoints); bw.Write(week.deathPoints); bw.Write(week.assistPoints); bw.Write(week.bonusPoints); bw.Write(week.kills); bw.Write(week.deaths); bw.Write((int)0); bw.Write(week.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementWeekly " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreWeekly; response.columns = "Top100 Weekly Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreMonthly: { DateTime now = DateTime.Today; if (((int)now.Day - 1) > 1) { now = now.AddDays(-(((int)now.Day) - 1)); } //Get the top100 stats sorted by points //For this month var monthly = (from mt in db.statsMonthlies where mt.zone1 == zone._zone && mt.date >= now orderby mt.assistPoints + mt.bonusPoints + mt.killPoints descending select mt).Take(100); //Are they requesting a specific date? if (pkt.options != "") { //Player wants to see last month's date if (pkt.options.Equals("-1")) { DateTime today = now; now = now.AddMonths(-1); monthly = (from mt in db.statsMonthlies where mt.zone1 == zone._zone && mt.date >= now && mt.date < today orderby mt.assistPoints + mt.bonusPoints + mt.killPoints descending select mt).Take(100); } else //Specific date { string[] args = pkt.options.Split('-'); string final = string.Join("/", args); //Since the client only gives month/year, lets start from day 1 final = String.Format("{0}/01", final); try { now = DateTime.Parse(final, System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); } catch (FormatException) { //Wrong format, use last month as default now = (now.AddMonths(-1)); } DateTime add = now.AddMonths(1); monthly = (from mt in db.statsMonthlies where mt.zone1 == zone._zone && mt.date >= now && mt.date < add orderby mt.assistPoints + mt.bonusPoints + mt.killPoints descending select mt).Take(100); } } MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsMonthly month in monthly) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(month.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = month.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(month.vehicleDeaths); bw.Write(month.vehicleKills); bw.Write(month.killPoints); bw.Write(month.deathPoints); bw.Write(month.assistPoints); bw.Write(month.bonusPoints); bw.Write(month.kills); bw.Write(month.deaths); bw.Write((int)0); bw.Write(month.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementMonthly " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreMonthly; response.columns = "Top100 Monthly Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreYearly: { DateTime now = DateTime.Today; if (((int)now.Month) > 1) { now = now.AddMonths(-((int)DateTime.Now.Month)); } //Get the top100 stats sorted by points var yearly = (from yt in db.statsYearlies where yt.zone1 == zone._zone && yt.date >= now orderby yt.assistPoints + yt.bonusPoints + yt.killPoints descending select yt).Take(100); //Are they requesting a specific date? if (pkt.options != "") { //Player wants to see last years date if (pkt.options.Equals("-1")) { now = now.AddYears(-1); yearly = (from yt in db.statsYearlies where yt.zone1 == zone._zone && yt.date >= now orderby yt.assistPoints + yt.bonusPoints + yt.killPoints descending select yt).Take(100); } else //Specific date { //Since the client only gives the year, lets start from jan 1st string final = String.Format("{0}/01/01", pkt.options); try { now = DateTime.Parse(final, System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); } catch (FormatException) { //Wrong format, use last year as default now = (now.AddYears(-1)); } DateTime add = now.AddYears(1); yearly = (from yt in db.statsYearlies where yt.zone1 == zone._zone && yt.date >= now && yt.date <= add orderby yt.assistPoints + yt.bonusPoints + yt.killPoints descending select yt).Take(100); } } MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsYearly year in yearly) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(year.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = year.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(year.vehicleDeaths); bw.Write(year.vehicleKills); bw.Write(year.killPoints); bw.Write(year.deathPoints); bw.Write(year.assistPoints); bw.Write(year.bonusPoints); bw.Write(year.kills); bw.Write(year.deaths); bw.Write((int)0); bw.Write(year.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementYear " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreYearly; response.columns = "Top100 Yearly Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryDaily: { Data.DB.alias getAlias = db.alias.FirstOrDefault(a => a.name.Equals(pkt.options)); Data.DB.player getPlayer = db.players.FirstOrDefault(p => p.alias1 == getAlias && p.zone == zone._zone.id); if (getPlayer == null) { return; } //Lets give them a year's worth DateTime now = DateTime.Today; if (((int)now.DayOfYear - 1) > 1) { now = now.AddDays(-(((int)now.DayOfYear) - 1)); } DateTime today = DateTime.Today; var daily = (from dt in db.statsDailies where dt.zone1 == zone._zone && dt.date >= now && dt.date < today orderby dt.date descending select dt); MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsDaily day in daily) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(day.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = day.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(day.vehicleDeaths); bw.Write(day.vehicleKills); bw.Write(day.killPoints); bw.Write(day.deathPoints); bw.Write(day.assistPoints); bw.Write(day.bonusPoints); bw.Write(day.kills); bw.Write(day.deaths); bw.Write((int)0); bw.Write(day.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementHistoryDailly " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryDaily; response.columns = "ScoreHistory Daily Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryWeekly: { Data.DB.alias getAlias = db.alias.FirstOrDefault(a => a.name.Equals(pkt.options)); Data.DB.player getPlayer = db.players.FirstOrDefault(p => p.alias1 == getAlias && p.zone == zone._zone.id); if (getPlayer == null) { return; } //Lets give them a year's worth DateTime now = DateTime.Today; if (((int)now.DayOfWeek) > 0) { now = now.AddDays(-(((int)now.DayOfWeek) - 1)); } DateTime today = now; now = now.AddMonths(-((int)now.Month - 1)); var weekly = (from wt in db.statsWeeklies where wt.zone1 == zone._zone && wt.date >= now && wt.date < today orderby wt.date descending select wt); MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsWeekly week in weekly) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(week.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = week.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(week.vehicleDeaths); bw.Write(week.vehicleKills); bw.Write(week.killPoints); bw.Write(week.deathPoints); bw.Write(week.assistPoints); bw.Write(week.bonusPoints); bw.Write(week.kills); bw.Write(week.deaths); bw.Write((int)0); bw.Write(week.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementHistoryWeekly " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryWeekly; response.columns = "ScoreHistory Weekly Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryMonthly: { Data.DB.alias getAlias = db.alias.FirstOrDefault(a => a.name.Equals(pkt.options)); Data.DB.player getPlayer = db.players.FirstOrDefault(p => p.alias1 == getAlias && p.zone == zone._zone.id); if (getPlayer == null) { return; } //Lets give them a year's worth DateTime now = DateTime.Today; if (((int)now.Day - 1) > 1) { now = now.AddDays(-(((int)now.Day) - 1)); } DateTime today = now; now = now.AddMonths(-((int)now.Month - 1)); var monthly = (from mt in db.statsMonthlies where mt.zone1 == zone._zone && mt.date >= now && mt.date < today orderby mt.date descending select mt); MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsMonthly month in monthly) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(month.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = month.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(month.vehicleDeaths); bw.Write(month.vehicleKills); bw.Write(month.killPoints); bw.Write(month.deathPoints); bw.Write(month.assistPoints); bw.Write(month.bonusPoints); bw.Write(month.kills); bw.Write(month.deaths); bw.Write((int)0); bw.Write(month.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementHistoryMonthly " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryMonthly; response.columns = "ScoreHistory Monthly Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; case CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryYearly: { Data.DB.alias getAlias = db.alias.FirstOrDefault(a => a.name.Equals(pkt.options)); Data.DB.player getPlayer = db.players.FirstOrDefault(p => p.alias1 == getAlias && p.zone == zone._zone.id); if (getPlayer == null) { return; } //Lets give them a year's worth DateTime now = DateTime.Today; if (((int)now.Day - 1) > 1) { now = now.AddDays(-(((int)now.Day) - 1)); } DateTime today = now; now = now.AddMonths(-((int)now.Month - 1)); var yearly = (from yt in db.statsYearlies where yt.zone1 == zone._zone && yt.date >= now && yt.date < today orderby yt.date descending select yt); MemoryStream stream = new MemoryStream(); try { foreach (Data.DB.statsYearly year in yearly) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(year.players[0].alias1.name.ToCharArray()); bw.Write((byte)0); Data.DB.squad squad = year.players[0].squad1; string squadname = ""; if (squad != null) { squadname = squad.name; } bw.Write(squadname.ToCharArray()); bw.Write((byte)0); bw.Write((short)2); bw.Write(year.vehicleDeaths); bw.Write(year.vehicleKills); bw.Write(year.killPoints); bw.Write(year.deathPoints); bw.Write(year.assistPoints); bw.Write(year.bonusPoints); bw.Write(year.kills); bw.Write(year.deaths); bw.Write((int)0); bw.Write(year.playSeconds); } } catch (Exception e) { Log.write(TLog.Warning, "WriteElementHistoryYearly " + e); } SC_PlayerStatsResponse <Zone> response = new SC_PlayerStatsResponse <Zone>(); response.player = pkt.player; response.type = CS_PlayerStatsRequest <Zone> .ChartType.ScoreHistoryYearly; response.columns = "ScoreHistory Yearly Score,Name,Squad"; response.data = stream.ToArray(); zone._client.sendReliable(response, 1); } break; } } }
/// <summary> /// Creates a new packet based on the typeID and the received content /// inside the buffer. The user has to create an own implementation /// of this interface. /// </summary> public PacketBase createPacket(NetworkClient client, ushort typeID, byte[] buffer, int offset, int size) { //Ready our packet base PacketBase packet = null; size--; //Was it a system packet? if (buffer[offset++] == 0) { //Yes, find the appropriate type return(createSystemPacket(typeID, buffer, offset, size)); } //So what was the typeid? switch (typeID) { case CS_Auth <T> .TypeID: packet = new CS_Auth <T>(typeID, buffer, offset, size); break; case CS_PlayerLogin <T> .TypeID: packet = new CS_PlayerLogin <T>(typeID, buffer, offset, size); break; case CS_PlayerUpdate <T> .TypeID: packet = new CS_PlayerUpdate <T>(typeID, buffer, offset, size); break; case CS_PlayerLeave <T> .TypeID: packet = new CS_PlayerLeave <T>(typeID, buffer, offset, size); break; case CS_PlayerBanner <T> .TypeID: packet = new CS_PlayerBanner <T>(typeID, buffer, offset, size); break; case CS_PlayerStatsRequest <T> .TypeID: packet = new CS_PlayerStatsRequest <T>(typeID, buffer, offset, size); break; case CS_Whisper <T> .TypeID: packet = new CS_Whisper <T>(typeID, buffer, offset, size); break; case CS_JoinChat <T> .TypeID: packet = new CS_JoinChat <T>(typeID, buffer, offset, size); break; case CS_LeaveChat <T> .TypeID: packet = new CS_LeaveChat <T>(typeID, buffer, offset, size); break; case CS_PrivateChat <T> .TypeID: packet = new CS_PrivateChat <T>(typeID, buffer, offset, size); break; case CS_ModCommand <T> .TypeID: packet = new CS_ModCommand <T>(typeID, buffer, offset, size); break; case CS_Squads <T> .TypeID: packet = new CS_Squads <T>(typeID, buffer, offset, size); break; case CS_ChatQuery <T> .TypeID: packet = new CS_ChatQuery <T>(typeID, buffer, offset, size); break; case Disconnect <T> .TypeID: packet = new Disconnect <T>(typeID, buffer, offset, size); break; case CS_Ban <T> .TypeID: packet = new CS_Ban <T>(typeID, buffer, offset, size); break; case CS_SquadMatch <T> .TypeID: packet = new CS_SquadMatch <T>(typeID, buffer, offset, size); break; case CS_ModQuery <T> .TypeID: packet = new CS_ModQuery <T>(typeID, buffer, offset, size); break; case CS_ChatCommand <T> .TypeID: packet = new CS_ChatCommand <T>(typeID, buffer, offset, size); break; case CS_StatsUpdate <T> .TypeID: packet = new CS_StatsUpdate <T>(typeID, buffer, offset, size); break; case CS_ArenaUpdate <T> .TypeID: packet = new CS_ArenaUpdate <T>(typeID, buffer, offset, size); break; default: //An undefined packet. packet = new PacketDummy(typeID, buffer, offset, size); break; } return(packet); }
{ /// <summary> /// Handles all player update packets received from clients /// </summary> static public void Handle_CS_ChartRequest(CS_ChartRequest pkt, Player player) { //Make sure he has an arena if (player._arena == null) { Log.write(TLog.Error, "Player {0} requested chart with no arena.", player); return; } //What sort of chart request? SC_ScoreChart chart = new SC_ScoreChart(); switch (pkt.type) { case Helpers.ChartType.ScoreOnlinePlayers: { List <Player> players = player._arena.Players.OrderByDescending(p => p.Points).ToList(); chart.type = Helpers.ChartType.ScoreOnlinePlayers; chart.columns = "Online Player Scores,Name,Squad"; chart.playerFunc = delegate(int idx) { return(players[idx]); }; chart.dataFunc = delegate(int idx) { if (idx >= players.Count) { return(null); } if (players[idx].StatsTotal != null) { return(players[idx].StatsTotal); } return(null); }; player._client.sendReliable(chart, 1); } break; case Helpers.ChartType.ScoreCurrentGame: { List <Player> players = player._arena.Players.OrderByDescending(p => p.Points).ToList(); chart.type = Helpers.ChartType.ScoreCurrentGame; chart.columns = "Current Game Scores,Name,Squad"; chart.playerFunc = delegate(int idx) { return(players[idx]); }; chart.dataFunc = delegate(int idx) { if (idx >= players.Count) { return(null); } if (players[idx].StatsCurrentGame != null) { return(players[idx].StatsCurrentGame); } return(null); }; player._client.sendReliable(chart, 1); } break; case Helpers.ChartType.ScorePreviousGame: { List <Player> players = player._arena.Players.OrderByDescending(p => p.Points).ToList(); chart.type = Helpers.ChartType.ScorePreviousGame; chart.columns = "Current Session Scores,Name,Squad"; chart.playerFunc = delegate(int idx) { return(players[idx]); }; chart.dataFunc = delegate(int idx) { if (idx >= players.Count) { return(null); } if (players[idx].StatsLastGame != null) { return(players[idx].StatsLastGame); } return(null); }; player._client.sendReliable(chart, 1); } break; case Helpers.ChartType.ScoreCurrentSession: { List <Player> players = player._arena.Players.OrderByDescending(p => p.Points).ToList(); chart.type = Helpers.ChartType.ScoreCurrentSession; chart.columns = "Current Session Scores,Name,Squad"; chart.playerFunc = delegate(int idx) { return(players[idx]); }; chart.dataFunc = delegate(int idx) { if (idx >= players.Count) { return(null); } if (players[idx].StatsCurrentSession != null) { return(players[idx].StatsCurrentSession); } return(null); }; player._client.sendReliable(chart, 1); } break; case Helpers.ChartType.ScoreLifetime: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreLifetime; req.options = pkt.options; player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreDaily: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreDaily; req.options = pkt.options; player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreWeekly: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreWeekly; req.options = pkt.options; player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreMonthly: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreMonthly; req.options = pkt.options; player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreYearly: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreYearly; req.options = pkt.options; player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreHistoryDaily: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreHistoryDaily; if (pkt.options == "") { req.options = player._alias.ToString(); } else { req.options = pkt.options; } player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreHistoryWeekly: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreHistoryWeekly; if (pkt.options == "") { req.options = player._alias.ToString(); } else { req.options = pkt.options; } player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreHistoryMonthly: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreHistoryMonthly; if (pkt.options == "") { req.options = player._alias.ToString(); } else { req.options = pkt.options; } player._arena._server._db.send(req); } break; case Helpers.ChartType.ScoreHistoryYearly: { //Send the request to the database! CS_PlayerStatsRequest <Data.Database> req = new CS_PlayerStatsRequest <Data.Database>(); req.player = player.toInstance(); req.type = CS_PlayerStatsRequest <Data.Database> .ChartType.ScoreHistoryYearly; if (pkt.options == "") { req.options = player._alias.ToString(); } else { req.options = pkt.options; } player._arena._server._db.send(req); } break; default: { chart.type = Helpers.ChartType.ScoreCurrentGame; chart.columns = "Invalid Chart Request"; chart.dataFunc = delegate(int idx) { return(null); }; player._client.sendReliable(chart, 1); } break; } }