moved db connection again to try and finally avoid invalid db handles

This commit is contained in:
Christian 2021-03-02 10:21:14 +01:00
parent 49469c6b56
commit de116bb1da

View File

@ -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,6 +100,7 @@ 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);
}
@ -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();
}
//----------------------------------------------------------------------------------------------------