private void DoTimeRequest()
{
int Kit = 0;
int Vehicle = 0;
int Weapon = 0;
int Map = 0;
string colName;
// Get params
if (Request.QueryString.ContainsKey("kit"))
Int32.TryParse(Request.QueryString["kit"], out Kit);
if (Request.QueryString.ContainsKey("vehicle"))
Int32.TryParse(Request.QueryString["vehicle"], out Vehicle);
if (Request.QueryString.ContainsKey("weapon"))
Int32.TryParse(Request.QueryString["weapon"], out Weapon);
if (Request.QueryString.ContainsKey("map"))
Int32.TryParse(Request.QueryString["map"], out Map);
// Check if the player exists
Rows = Database.Query("SELECT name FROM player WHERE id=@P0", Pid);
if (Rows.Count == 0)
{
Response.WriteResponseStart(false);
Response.WriteHeaderLine("asof", "err");
Response.WriteDataLine(DateTime.UtcNow.ToUnixTimestamp(), "Player Doesnt Exist");
Response.Send();
return;
}
else
{
Response.WriteResponseStart();
Response.WriteHeaderLine("asof");
Response.WriteDataLine(DateTime.UtcNow.ToUnixTimestamp());
}
// Prepare output
Response.WriteHeaderLine("pid", "nick", "ktm-" + Kit.ToString(), "vtm-" + Vehicle.ToString(), "wtm-" + Weapon.ToString(), "mtm-" + Map.ToString());
string Name = Rows[0]["name"].ToString().Trim();
// Format weapon column name
if(Weapon > 8)
{
switch(Weapon)
{
default:
colName = "knifetime";
break;
case 10:
colName = "shockpadtime";
break;
case 11:
colName = "(c4time + claymoretime + atminetime)";
break;
case 12:
colName = "handgrenadetime";
break;
}
}
else
colName = "time" + Weapon;
// Kit Time
Rows = Database.Query(String.Format("SELECT time{0} AS time FROM kits WHERE id={1}", Kit, Pid));
Kit = (Rows.Count == 0) ? 0 : Int32.Parse(Rows[0]["time"].ToString());
// Vehicle Time
Rows = Database.Query(String.Format("SELECT time{0} AS time FROM vehicles WHERE id={1}", Vehicle, Pid));
Vehicle = (Rows.Count == 0) ? 0 : Int32.Parse(Rows[0]["time"].ToString());
// Weapon Time
Rows = Database.Query(String.Format("SELECT {0} AS time FROM weapons WHERE id={1}", colName, Pid));
Weapon = (Rows.Count == 0) ? 0 : Int32.Parse(Rows[0]["time"].ToString());
// Map Time
Rows = Database.Query("SELECT time FROM maps WHERE id = @P0 AND mapid = @P1", Pid, Map);
Map = (Rows.Count == 0) ? 0 : Int32.Parse(Rows[0]["time"].ToString());
// Send Response
Response.WriteDataLine(Pid, Name, Kit, Vehicle, Weapon, Map);
Response.Send();
}