12.08.2013, 12:12
In this script what exactly do i have to change, i keep making mistakes. Could someone just highlight the main parts, i have my own XAMPP database created but i'm just not good at the scripting part.
// Custom Functions
// g_mysql_Init()
// Description: Called with Gamemode Init.
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) received! Can not connect to MySQL Host %s - DB: %s - User: %s", SQL_HOST, SQL_DB, SQL_USER);
print("[MySQL]Note: Be sure you provide the information correctly to connect..");
SendRconCommand("exit");
}
else
{
print("[MySQL] (MainPipeline) Connection successful toward MySQL Database Server!");
}
#if defined SHOPAUTOMATED
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) received! Can not connect to MySQL: Host %s - DB: %s - User: %s", SQL_SHOST, SQL_SDB, SQL_SUSER);
print("[MySQL] Note: Be sure you provide the information correctly to connect.
//SendRconCommand("exit");
}
else
{
print("[MySQL] (ShopPipeline) You successfully connected to MySQL Database Server!");
}
#endif
return 1;
// Custom Functions
// g_mysql_Init()
// Description: Called with Gamemode Init.
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) received! Can not connect to MySQL Host %s - DB: %s - User: %s", SQL_HOST, SQL_DB, SQL_USER);
print("[MySQL]Note: Be sure you provide the information correctly to connect..");
SendRconCommand("exit");
}
else
{
print("[MySQL] (MainPipeline) Connection successful toward MySQL Database Server!");
}
#if defined SHOPAUTOMATED
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) received! Can not connect to MySQL: Host %s - DB: %s - User: %s", SQL_SHOST, SQL_SDB, SQL_SUSER);
print("[MySQL] Note: Be sure you provide the information correctly to connect.
//SendRconCommand("exit");
}
else
{
print("[MySQL] (ShopPipeline) You successfully connected to MySQL Database Server!");
}
#endif
return 1;