I have just updated my old script and I was able to fix all the errors but one.
Remove it. The newer plugins automatically reconnect so there is really no need to use any type of connection check.
Код:
stock g_mysql_Init()
{
new SQL_HOST[64], SQL_DB[64], SQL_USER[32], SQL_PASS[128], iValue;
new SQL_SHOST[64], SQL_SDB[64], SQL_SUSER[32], SQL_SPASS[128];
new fileString[128], File: fileHandle = fopen("mysql.cfg", io_read);
while(fread(fileHandle, fileString, sizeof(fileString))) {
if(ini_GetValue(fileString, "HOST", SQL_HOST, sizeof(SQL_HOST))) continue;
if(ini_GetValue(fileString, "DB", SQL_DB, sizeof(SQL_DB))) continue;
if(ini_GetValue(fileString, "USER", SQL_USER, sizeof(SQL_USER))) continue;
if(ini_GetValue(fileString, "PASS", SQL_PASS, sizeof(SQL_PASS))) continue;
if(ini_GetValue(fileString, "SHOST", SQL_SHOST, sizeof(SQL_SHOST))) continue;
if(ini_GetValue(fileString, "SDB", SQL_SDB, sizeof(SQL_SDB))) continue;
if(ini_GetValue(fileString, "SUSER", SQL_SUSER, sizeof(SQL_SUSER))) continue;
if(ini_GetValue(fileString, "SPASS", SQL_SPASS, sizeof(SQL_SPASS))) continue;
if(ini_GetInt(fileString, "SERVER", servernumber)) continue;
if(ini_GetInt(fileString, "DEBUG", iValue)) continue;
}
fclose(fileHandle);
mysql_debug(iValue);
MainPipeline = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
setproperty(.name = "pipeline", .value = MainPipeline);
printf("[MySQL] (Main Pipelines) Connecting to %s...", SQL_HOST);
if(mysql_ping(MainPipeline) == -1)
{
printf("[MySQL] (MainPipeline) Fatal Error! Could not connect to MySQL: Host %s - DB: %s - User: %s", SQL_HOST, SQL_DB, SQL_USER);
print("[MySQL] Note: Make sure that you have provided the correct connection credentials.");
SendRconCommand("exit");
}
else
{
print("[MySQL] (MainPipeline) Connection successful toward MySQL Database Server!");
}
ShopPipeline = mysql_connect(SQL_SHOST, SQL_SUSER, SQL_SDB, SQL_SPASS);
printf("[MySQL] (Shop Pipelines) Connecting to %s...", SQL_SHOST);
if(mysql_ping(ShopPipeline) == -1)
{
printf("[MySQL] (ShopPipeline) Fatal Error! Could not connect to MySQL: Host %s - DB: %s - User: %s", SQL_SHOST, SQL_SDB, SQL_SUSER);
print("[MySQL] Note: Make sure that you have provided the correct connection credentials.");
//SendRconCommand("exit");
}
else
{
print("[MySQL] (ShopPipeline) Connection successful toward MySQL Database Server!");
}
#endif
return 1;
}