updated by request of machu to display top100
This commit is contained in:
parent
8d15f3b278
commit
1c0688bf80
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
Database g_hDatabase;
|
Database g_hDatabase;
|
||||||
Handle g_h_time_activity = null;
|
Handle g_h_time_activity = null;
|
||||||
|
char g_cTimeRecords[100][128];
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
@ -90,6 +91,7 @@ public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
|||||||
g_hDatabase = db;
|
g_hDatabase = db;
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
OnClientPostAdminCheck(i);
|
OnClientPostAdminCheck(i);
|
||||||
|
OnMapStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientPostAdminCheck(int client)
|
public void OnClientPostAdminCheck(int client)
|
||||||
@ -136,12 +138,12 @@ stock bool IsValidClient(int client)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_TopTime(int client, int args)
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
if (!g_hDatabase)
|
if (!g_hDatabase)
|
||||||
{
|
{
|
||||||
Database.Connect(SQL_OnDatabaseConnect, "unloze_playtimestats");
|
Database.Connect(SQL_OnDatabaseConnect, "unloze_playtimestats");
|
||||||
return Plugin_Handled;
|
return;
|
||||||
}
|
}
|
||||||
char sQuery[512];
|
char sQuery[512];
|
||||||
char sServer[32];
|
char sServer[32];
|
||||||
@ -165,11 +167,42 @@ public Action Command_TopTime(int client, int args)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Plugin_Handled;
|
return;
|
||||||
}
|
}
|
||||||
Format(sQuery, sizeof(sQuery), "select steam_id, player_name, sum(%s) as %s_total from unloze_playtimestats.player_time GROUP BY steam_id order by %s_total desc limit 10", sServer, sServer, sServer);
|
Format(sQuery, sizeof(sQuery), "select player_name, sum(%s) as %s_total from unloze_playtimestats.player_time GROUP BY steam_id order by %s_total desc limit 100", sServer, sServer, sServer);
|
||||||
g_hDatabase.Query(SQL_OnQueryCompletedTopTime, sQuery, GetClientSerial(client));
|
g_hDatabase.Query(SQL_OnQueryCompletedTopTime, sQuery);
|
||||||
return Plugin_Handled;
|
}
|
||||||
|
|
||||||
|
public Action Command_TopTime(int client, int args)
|
||||||
|
{
|
||||||
|
char sTitle[64];
|
||||||
|
char sServer[32];
|
||||||
|
int i_port = GetConVarInt(FindConVar("hostport"));
|
||||||
|
if (i_port == 27015 || i_port == 27019)
|
||||||
|
{
|
||||||
|
Format(sServer, sizeof(sServer), "ZE");
|
||||||
|
}
|
||||||
|
else if (i_port == 27016)
|
||||||
|
{
|
||||||
|
Format(sServer, sizeof(sServer), "ZR");
|
||||||
|
}
|
||||||
|
else if (i_port == 27017)
|
||||||
|
{
|
||||||
|
Format(sServer, sizeof(sServer), "MG");
|
||||||
|
}
|
||||||
|
else if (i_port == 27023)
|
||||||
|
{
|
||||||
|
Format(sServer, sizeof(sServer), "JB");
|
||||||
|
}
|
||||||
|
Format(sTitle, sizeof(sTitle), "[UNLOZE Playtime] Top 100 Record Holders for %s:", sServer);
|
||||||
|
Menu menu = new Menu(MenuHandler1);
|
||||||
|
menu.SetTitle(sTitle);
|
||||||
|
for (int i = 0; i < sizeof(g_cTimeRecords); i++)
|
||||||
|
{
|
||||||
|
menu.AddItem("-1", g_cTimeRecords[i], ITEMDRAW_DISABLED);
|
||||||
|
}
|
||||||
|
menu.ExitButton = true;
|
||||||
|
menu.Display(client, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_Time(int client, int args)
|
public Action Command_Time(int client, int args)
|
||||||
@ -193,58 +226,35 @@ public void SQL_OnQueryCompletedTopTime(Database db, DBResultSet results, const
|
|||||||
{
|
{
|
||||||
LogError("Query error 3: %s", error);
|
LogError("Query error 3: %s", error);
|
||||||
}
|
}
|
||||||
int client;
|
|
||||||
if ((client = GetClientFromSerial(iSerial)) == 0)
|
|
||||||
return;
|
|
||||||
char sServer[32];
|
|
||||||
|
|
||||||
int i_port = GetConVarInt(FindConVar("hostport"));
|
|
||||||
if (i_port == 27015 || i_port == 27019)
|
|
||||||
{
|
|
||||||
Format(sServer, sizeof(sServer), "ze_time");
|
|
||||||
}
|
|
||||||
else if (i_port == 27016)
|
|
||||||
{
|
|
||||||
Format(sServer, sizeof(sServer), "zr_time");
|
|
||||||
}
|
|
||||||
else if (i_port == 27017)
|
|
||||||
{
|
|
||||||
Format(sServer, sizeof(sServer), "mg_time");
|
|
||||||
}
|
|
||||||
else if (i_port == 27023)
|
|
||||||
{
|
|
||||||
Format(sServer, sizeof(sServer), "jb_time");
|
|
||||||
}
|
|
||||||
|
|
||||||
int iTime;
|
int iTime;
|
||||||
char sName[MAX_NAME_LENGTH];
|
char sName[MAX_NAME_LENGTH];
|
||||||
char sAuthID[32];
|
int counter = 0;
|
||||||
Panel mSayPanel = new Panel(GetMenuStyleHandle(MenuStyle_Radio));
|
|
||||||
char sTitle[64];
|
|
||||||
Format(sTitle, sizeof(sTitle), "[UNLOZE Playtime] Record Holders for %s:", sServer);
|
|
||||||
mSayPanel.SetTitle(sTitle);
|
|
||||||
int counter = 1;
|
|
||||||
while (results.RowCount && results.FetchRow())
|
while (results.RowCount && results.FetchRow())
|
||||||
{
|
{
|
||||||
char sBuffer[256];
|
char sBuffer[256];
|
||||||
results.FetchString(0, sAuthID, sizeof(sAuthID));
|
results.FetchString(0, sName, sizeof(sName));
|
||||||
results.FetchString(1, sName, sizeof(sName));
|
iTime = results.FetchInt(1);
|
||||||
iTime = results.FetchInt(2);
|
|
||||||
|
|
||||||
int iHours = (iTime / 60) / 60;
|
int iHours = (iTime / 60) / 60;
|
||||||
Format(sBuffer, sizeof(sBuffer), "%i %s %d Hours", counter, sName, iHours);
|
Format(sBuffer, sizeof(sBuffer), "%i %s %d Hours", counter + 1, sName, iHours);
|
||||||
|
Format(g_cTimeRecords[counter], sizeof(g_cTimeRecords[]), sBuffer);
|
||||||
counter++;
|
counter++;
|
||||||
mSayPanel.DrawText(sBuffer);
|
|
||||||
}
|
}
|
||||||
mSayPanel.DrawItem("", ITEMDRAW_SPACER);
|
|
||||||
mSayPanel.DrawItem("1. Got it!", ITEMDRAW_RAWLINE);
|
|
||||||
|
|
||||||
mSayPanel.SetKeys(1023);
|
|
||||||
mSayPanel.Send(client, Handler_Menu, 0);
|
|
||||||
delete mSayPanel;
|
|
||||||
delete results;
|
delete results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2)
|
||||||
|
{
|
||||||
|
switch(action)
|
||||||
|
{
|
||||||
|
case MenuAction_End:
|
||||||
|
{
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void SQL_OnQueryCompletedTime(Database db, DBResultSet results, const char[] error, int iSerial)
|
public void SQL_OnQueryCompletedTime(Database db, DBResultSet results, const char[] error, int iSerial)
|
||||||
{
|
{
|
||||||
if (!db || strlen(error))
|
if (!db || strlen(error))
|
||||||
|
Loading…
Reference in New Issue
Block a user