I set a timer on plugin_init, to connect to the SQL database after 1 second.
This is the connection:
PHP Code:
public MYSQLX_Init()
{
new sqlhostname[35],sqluser[35],sqlpass[35],sqldbname[35];
get_cvar_string("zp_sql_host", sqlhostname,34);
get_cvar_string("zp_sql_user", sqluser,34);
get_cvar_string("zp_sql_pass", sqlpass,34);
get_cvar_string("zp_sql_db", sqldbname,34);
// Determine the database information
new szError[256], iErrNum;
// Set up the tuple that will be used for threading
g_DBTuple = SQL_MakeDbTuple(sqlhostname, sqluser, sqlpass, sqldbname );
// Attempt to connect
g_DBConn = SQL_Connect(g_DBTuple, iErrNum, szError, 255);
if (!g_DBConn)
{
log_to_file("ZP-Bank.log", "[ZP-APS] Database Connection Failed: [%d] %s", iErrNum, szError);
return;
}
DBConnection = true;
server_print("[ZP-APS] MySQL database connection successful");
}