updating the include and added forward that gives player time for a server

This commit is contained in:
jenz 2025-06-09 20:32:08 +02:00
parent b0feb898e3
commit 9e0dc43ec9
2 changed files with 22 additions and 1 deletions

View File

@ -12,3 +12,12 @@ native int GetAveragePlayerTimeOnServer();
* @returns the players rtv amount boost
*/
native int GetPlayerWorthRTV_boost_(int client);
/**
* returns a players hours for a specific server
*
* @int the actual client
* @int Game time hours that the client has on the server.
*/
forward void GetPlayerHoursServer(int client, int hours);

View File

@ -17,6 +17,8 @@ int g_iPlayerAFKTime;
int g_iPlayerCount_excludeSpec;
int g_iPlayerRTVCapacity;
static Handle g_hForwardPlayerHours;
public Plugin myinfo =
{
name = "UNLOZE_player_time",
@ -121,6 +123,10 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char [] error, int err_ma
{
CreateNative("GetAveragePlayerTimeOnServer", Native_GetAveragePlayerActiveTimeServer);
CreateNative("GetPlayerWorthRTV_boost_", Native_GetPlayerWorthRTV_boost);
//return g_iPlayerTimeServer[client];
g_hForwardPlayerHours = CreateGlobalForward("GetPlayerHoursServer", ET_Ignore, Param_Cell, Param_Cell);
return APLRes_Success;
}
@ -203,6 +209,7 @@ public void OnPluginEnd()
{
delete g_hTimer_avg_hour_count;
}
CloseHandle(g_hForwardPlayerHours);
}
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
@ -277,7 +284,7 @@ public void select_client_time_server(int client)
}
char sQuery[512];
Format(sQuery, sizeof(sQuery), "select sum(%s) as %s_total from unloze_playtimestats.player_time pt where pt.steam_id = '%s' GROUP BY steam_id order by %s_total desc", sServer, sServer, g_csSID[client], sServer);
g_hDatabase.Query(SQL_OnQueryCompletedTimeServer, sQuery, GetClientSerial(client));
g_hDatabase.Query(SQL_OnQueryCompletedTimeServer, sQuery, GetClientSerial(client), DBPrio_High);
}
public void SQL_OnQueryCompletedTimeServer(Database db, DBResultSet results, const char[] error, int iSerial)
@ -309,6 +316,11 @@ public void SQL_OnQueryCompletedTimeServer(Database db, DBResultSet results, con
iHours_Server = 5000;
}
g_iPlayerTimeServer[client] = iHours_Server;
Call_StartForward(g_hForwardPlayerHours);
Call_PushCell(client);
Call_PushCell(g_iPlayerTimeServer[client]);
Call_Finish();
}
public void OnClientDisconnect(int client)