From ba8a8b78924de4af018232aa2ac56e369220fcd7 Mon Sep 17 00:00:00 2001 From: jenz Date: Sun, 25 Jun 2023 13:26:26 +0200 Subject: [PATCH] redid getclientauthid to only on connect --- .../scripting/unloze_player_time.sp | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/discord_verificiation/scripting/unloze_player_time.sp b/discord_verificiation/scripting/unloze_player_time.sp index 6c8c603a..47def622 100644 --- a/discord_verificiation/scripting/unloze_player_time.sp +++ b/discord_verificiation/scripting/unloze_player_time.sp @@ -10,6 +10,7 @@ Database g_hDatabase; //check if autismbot bool is_bot_player[MAXPLAYERS + 1]; Handle g_h_time_activity = null; +char g_csSID[MAXPLAYERS + 1][65]; char g_cTimeRecords[100][128]; int g_iPlayerTimeServer[MAXPLAYERS + 1]; int g_iPlayerAFKTime; @@ -59,8 +60,6 @@ public Action time_query_activity(Handle timer, any data) { if (IsValidClient(client) && !IsFakeClient(client) && IsPlayerAlive(client)) { - char sAuthID[32]; - GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); char sIP[32]; GetClientIP(client, sIP, sizeof(sIP)); char sQuery[512]; @@ -69,9 +68,9 @@ public Action time_query_activity(Handle timer, any data) int size2 = 2 * strlen(sName) + 1; char[] sEscapedName = new char[size2 + 1]; g_hDatabase.Escape(sName, sEscapedName, size2 + 1); - Format(sQuery, sizeof(sQuery), "update unloze_playtimestats.player_time set `%s` = `%s` + 10 where steam_id = '%s' and ipv4 = '%s'", sServer, sServer, sAuthID, sIP); + Format(sQuery, sizeof(sQuery), "update unloze_playtimestats.player_time set `%s` = `%s` + 10 where steam_id = '%s' and ipv4 = '%s'", sServer, sServer, g_csSID[client], sIP); g_hDatabase.Query(SQL_FinishedQuery, sQuery, _, DBPrio_Low); - Format(sQuery, sizeof(sQuery), "update unloze_playtimestats.player_time set player_name = '%s' where steam_id = '%s' and player_name != '%s'", sEscapedName, sAuthID, sEscapedName); + Format(sQuery, sizeof(sQuery), "update unloze_playtimestats.player_time set player_name = '%s' where steam_id = '%s' and player_name != '%s'", sEscapedName, g_csSID[client], sEscapedName); g_hDatabase.Query(SQL_FinishedQuery, sQuery, _, DBPrio_Low); } } @@ -193,6 +192,7 @@ public void SQL_OnDatabaseConnect(Database db, const char[] error, any data) public void OnClientPostAdminCheck(int client) { + GetClientAuthId(client, AuthId_Steam2, g_csSID[client], sizeof(g_csSID[])); is_bot_player[client] = false; g_iPlayerTimeServer[client] = 0; if(!IsValidClient(client) || IsFakeClient(client)) @@ -204,21 +204,19 @@ public void OnClientPostAdminCheck(int client) insert_client(client); select_client_time_server(client); - char auth[50]; - GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); - if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false)) + if (StrEqual("[U:1:1221121532]", g_csSID[client], false) || StrEqual("STEAM_0:0:610560766", g_csSID[client], false)) { is_bot_player[client] = true; } - if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false)) + if (StrEqual("[U:1:408797742]", g_csSID[client], false) || StrEqual("STEAM_0:0:204398871", g_csSID[client], false)) { is_bot_player[client] = true; } - if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false)) + if (StrEqual("[U:1:1036189204]", g_csSID[client], false) || StrEqual("STEAM_0:0:518094602", g_csSID[client], false)) { is_bot_player[client] = true; } - if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false)) + if (StrEqual("[U:1:120378081]", g_csSID[client], false) || StrEqual("STEAM_0:1:60189040", g_csSID[client], false)) { is_bot_player[client] = true; } @@ -249,9 +247,7 @@ public void select_client_time_server(int client) return; } char sQuery[512]; - char sAuthID[32]; - GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); - 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, sAuthID, sServer); + 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)); } @@ -288,14 +284,13 @@ public void SQL_OnQueryCompletedTimeServer(Database db, DBResultSet results, con public void OnClientDisconnect(int client) { + Format(g_csSID[client], sizeof(g_csSID[]), ""); is_bot_player[client] = false; g_iPlayerTimeServer[client] = 0; } public void insert_client(int client) { - char sAuthID[32]; - GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); char sName[MAX_NAME_LENGTH]; GetClientName(client, sName, sizeof(sName)); int size2 = 2 * strlen(sName) + 1; @@ -304,7 +299,7 @@ public void insert_client(int client) char sIP[32]; GetClientIP(client, sIP, sizeof(sIP)); char sQuery[512]; - Format(sQuery, sizeof(sQuery), "INSERT INTO `player_time` (`steam_id`, `ipv4`, `player_name`, `ze_time`, `mg_time`, `zr_time`, `jb_time`) VALUES ('%s', '%s', '%s', 0, 0, 0, 0) ON DUPLICATE KEY UPDATE `player_name` = '%s'", sAuthID, sIP, sEscapedName, sEscapedName); + Format(sQuery, sizeof(sQuery), "INSERT INTO `player_time` (`steam_id`, `ipv4`, `player_name`, `ze_time`, `mg_time`, `zr_time`, `jb_time`) VALUES ('%s', '%s', '%s', 0, 0, 0, 0) ON DUPLICATE KEY UPDATE `player_name` = '%s'", g_csSID[client], sIP, sEscapedName, sEscapedName); g_hDatabase.Query(SQL_FinishedQuery, sQuery, _, DBPrio_Low); } @@ -398,9 +393,7 @@ public Action Command_Time(int client, int args) return Plugin_Handled; } char sQuery[512]; - char sAuthID[32]; - GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); - Format(sQuery, sizeof(sQuery), "select ze_time, mg_time, zr_time, jb_time from unloze_playtimestats.player_time pt where pt.steam_id = '%s'", sAuthID); + Format(sQuery, sizeof(sQuery), "select ze_time, mg_time, zr_time, jb_time from unloze_playtimestats.player_time pt where pt.steam_id = '%s'", g_csSID[client]); g_hDatabase.Query(SQL_OnQueryCompletedTime, sQuery, GetClientSerial(client)); return Plugin_Handled; }