From 9e0dc43ec9133c00f0d481a08860a0a689c87def Mon Sep 17 00:00:00 2001 From: jenz Date: Mon, 9 Jun 2025 20:32:08 +0200 Subject: [PATCH] updating the include and added forward that gives player time for a server --- .../scripting/include/unloze_playtime.inc | 9 +++++++++ .../scripting/unloze_player_time.sp | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/discord_verificiation/scripting/include/unloze_playtime.inc b/discord_verificiation/scripting/include/unloze_playtime.inc index 875140a..fa9b1ed 100755 --- a/discord_verificiation/scripting/include/unloze_playtime.inc +++ b/discord_verificiation/scripting/include/unloze_playtime.inc @@ -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); diff --git a/discord_verificiation/scripting/unloze_player_time.sp b/discord_verificiation/scripting/unloze_player_time.sp index 87cafea..ebcc1d2 100644 --- a/discord_verificiation/scripting/unloze_player_time.sp +++ b/discord_verificiation/scripting/unloze_player_time.sp @@ -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)