added myactivity command cause machu asked
This commit is contained in:
parent
111cc27521
commit
71d8773767
@ -24,6 +24,7 @@ public void OnPluginStart()
|
||||
Database.Connect(SQL_OnDatabaseConnect, "unloze_playtimestats");
|
||||
}
|
||||
RegConsoleCmd("sm_activity", Command_topactivity, "retrieve top activity on ze for the week");
|
||||
RegConsoleCmd("sm_myactivity", Command_myactivity, "retrieve your own activity on ze for the week");
|
||||
CreateTimer(1800.0, update_top_activity, _, TIMER_REPEAT);
|
||||
update_top_activity_ze();
|
||||
}
|
||||
@ -101,6 +102,62 @@ public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
||||
g_hDatabase.Query(SQL_top_activity, sQuery, DBPrio_Low);
|
||||
}
|
||||
|
||||
public Action Command_myactivity(int client, int args)
|
||||
{
|
||||
if (!g_hDatabase)
|
||||
{
|
||||
Database.Connect(SQL_OnDatabaseConnect, "unloze_playtimestats");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sSID[64];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
|
||||
char sQuery[1024];
|
||||
Format(sQuery, sizeof(sQuery), "select pt.steam_id, pt.player_name, SUM(pt.ze_time) - pa.ze_time_start_week AS time_this_week from unloze_playtimestats.player_activity_ze pa inner join unloze_playtimestats.player_time pt on pa.steamid = pt.steam_id where pa.steamid = '%s' GROUP BY pt.steam_id ORDER BY time_this_week DESC limit 15", sSID);
|
||||
g_hDatabase.Query(SQL_my_activity, sQuery, GetClientSerial(client), DBPrio_Low);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void SQL_my_activity(Database db, DBResultSet results, const char[] error, int iSerial)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
delete results;
|
||||
LogError("Query error: %s", error);
|
||||
return;
|
||||
}
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(iSerial)) == 0)
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
|
||||
char sTitle[64];
|
||||
Format(sTitle, sizeof(sTitle), "[UNLOZE your weekly activity ZE]");
|
||||
Menu menu = new Menu(MenuHandler1);
|
||||
menu.SetTitle(sTitle);
|
||||
|
||||
if (results.RowCount && results.FetchRow())
|
||||
{
|
||||
char sBuffer[528];
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
results.FetchString(1, sName, sizeof(sName));
|
||||
float time_this_week = results.FetchFloat(2);
|
||||
|
||||
int hours_server = RoundToFloor((time_this_week / 60) / 60);
|
||||
int minutes_server = RoundToFloor((time_this_week / 60) % 60);
|
||||
|
||||
Format(sBuffer, sizeof(sBuffer), "%s %d Hours %d Minutes", sName, hours_server, minutes_server);
|
||||
menu.AddItem("-1", sBuffer, ITEMDRAW_DISABLED);
|
||||
}
|
||||
delete results;
|
||||
|
||||
menu.ExitButton = true;
|
||||
menu.Display(client, 0);
|
||||
}
|
||||
|
||||
public Action Command_topactivity(int client, int args)
|
||||
{
|
||||
if (!g_hDatabase)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user