From de116bb1da7ce515218d98370f7b28ba69e2c67f Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 2 Mar 2021 10:21:14 +0100 Subject: [PATCH] moved db connection again to try and finally avoid invalid db handles --- RaceTimer/scripting/unloze_racetimer_redux.sp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index 34d02ea7..43edb81b 100644 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -48,6 +48,7 @@ public Plugin myinfo = public void OnPluginStart() { //cmds + AutoExecConfig(); RegConsoleCmd("sm_toptime", cmd_timerCheckTop, "checking top 10"); RegConsoleCmd("sm_mytime", cmd_timerCheckSelf, "checking your personal time"); RegConsoleCmd("sm_stages", cmd_timerCheckStage, "Checking race stages"); @@ -66,11 +67,15 @@ public void OnPluginStart() continue; } OnClientCookiesCached(i); - OnClientPostAdminCheck(i); } - OnMapStart(); } +public void OnConfigsExecuted() +{ + Database.Connect(SQL_OnDatabaseConnect, "racetimercss"); +} + + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -86,10 +91,6 @@ public void SQL_OnDatabaseConnect(Database db, const char[] error, any data) char sQuery[g_dLength]; Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS `zetimer_table` (`steam_auth` VARCHAR(254) NOT NULL, `name` VARCHAR(254) NOT NULL, PRIMARY KEY (`steam_auth`))"); g_dDatabase.Query(SQL_OnConnectFinished, sQuery, _, DBPrio_High); - - g_bDisplaySpecial = unloze_gBSpecialMapDisplay(); - GetCurrentMap(g_cMapname, sizeof(g_cMapname)); - startTimer(); } public void SQL_OnConnectFinished(Database db, DBResultSet results, const char[] error, any data) @@ -99,8 +100,9 @@ public void SQL_OnConnectFinished(Database db, DBResultSet results, const char[] LogError("Database error: %s", error); return; } + OnMapStart(); for(int i = 1; i <= MaxClients; i++) - OnClientPostAdminCheck(i); + OnClientPostAdminCheck(i); } public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] error, DataPack data) @@ -167,14 +169,14 @@ public void OnMapStart() { static Handle hHostName; if((hHostName = FindConVar("hostname")) == INVALID_HANDLE) - { return; - } char line[g_dLength]; GetConVarString(hHostName, line, sizeof(line)); if (StrContains(line, "EVENT", false) > -1) g_bEventBool = true; - Database.Connect(SQL_OnDatabaseConnect, "racetimercss"); + g_bDisplaySpecial = unloze_gBSpecialMapDisplay(); + GetCurrentMap(g_cMapname, sizeof(g_cMapname)); + startTimer(); } //----------------------------------------------------------------------------------------------------