05.06.2017, 12:45
What is the best aproach to get the number of players at each hour so I can display them on a graphic?
Are you trying to do this every hour(3:23, 4:23) or when the hour changes (8:00, 7:00)?
|
new server_hour;
// ongamemodeinit
new minute, second;
gettime(server_hour, minute, second);
HourTimer = SetTimer("HourlyUpdate", (60 - minute) * 1000, true);
//
forward HourlyUpdate();
public HourlyUpdate()
{
new gPlayers, local_query[128];
for(new i; i <= GetPlayerPoolSize(); i++)
{
if(IsPlayerConnected(i)) gPlayers++;
}
mysql_format(gSQLConnection, local_query, sizeof local_query, "INSERT..."
mysql_pquery(gSQLConnection, local_query);
return true;
}
SetTimerEx("HourlyUpdate", (60 - minute) * 1000*60, false, "i", true);
public HourlyUpdate(bool: firstcall)
{
if(firstcall == true)
{
KillTimer(HourTimer);
HourTimer = SetTimerEx("HourlyUpdate", 3600000, true, "i", false);
firstcall = false;
}
// after insert
if(server_hour == 23) server_hour = 0;
else server_hour ++;
}