From ab481d6d65face6c7e3d9d7f790ceca6ca2e5878 Mon Sep 17 00:00:00 2001 From: jenz Date: Tue, 25 Aug 2026 16:44:31 +0200 Subject: [PATCH] fixing where the previous session gets updated, now only update it in case of it being inserted inside the last 10 minutes --- .../scripting/unloze_playtime_display.sp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/discord_verificiation/scripting/unloze_playtime_display.sp b/discord_verificiation/scripting/unloze_playtime_display.sp index 7be9526..250b476 100644 --- a/discord_verificiation/scripting/unloze_playtime_display.sp +++ b/discord_verificiation/scripting/unloze_playtime_display.sp @@ -1,6 +1,6 @@ #pragma semicolon 1 #define PLUGIN_AUTHOR "jenz" -#define PLUGIN_VERSION "1.0" +#define PLUGIN_VERSION "1.1" #include #include #include @@ -128,7 +128,7 @@ public void SQL_FinishedQuerySelectUserSession(Database db, DBResultSet results, { //new session that we insert //chaining the calls - upsert_player(client); + insert_player(client); } delete results; } @@ -138,12 +138,14 @@ public void update_play_session(int client, int client_hours, int client_minutes char sSID[64]; GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); + //we only update the latest session row if it actually was updated inside the last 10 minutes. otherwise its an old session that should not be updated. char sQuery[512]; - Format(sQuery, sizeof(sQuery), "UPDATE `playtime_display_sessions` SET session_end_playtime_minutes='%i', session_end_dt=NOW() WHERE steamid = '%s' order by session_id desc limit 1", (client_hours * 60) + client_minutes, sSID); + Format(sQuery, sizeof(sQuery), "UPDATE `playtime_display_sessions` SET session_end_playtime_minutes='%i', session_end_dt=NOW() WHERE steamid = '%s' and session_end_dt > NOW() - INTERVAL 10 MINUTE order by session_id desc limit 1", (client_hours * 60) + client_minutes, sSID); + g_hDatabase.Query(SQL_FinishedQuery, sQuery, _, DBPrio_Normal); } -public void upsert_player(int client) +public void insert_player(int client) { char sName[MAX_NAME_LENGTH]; GetClientName(client, sName, sizeof(sName));