25.03.2013, 16:54
Assuming you use blueg's mysql plugin
Should work :d
Edit->Too slow
pawn Code:
// At the top \\
new gConn;
#define SQL_HOST_LOCAL "hostname"
#define SQL_USER_LOCAL "user"
#define SQL_PASS_LOCAL "password"
#define SQL_DB_LOCAL "database_name"
#define SQL_HOST_HOST "hostname"
#define SQL_USER_HOST "user"
#define SQL_PASS_HOST "password"
#define SQL_DB_HOST "database_name"
// Anywhere you want(Then add mySQL_init(); in OnGameModeInit callback) \\
stock mySQL_init()
{
gConn = mysql_connect(SQL_HOST_LOCAL, SQL_USER_LOCAL, SQL_DB_LOCAL, SQL_PASS_LOCAL);
if(mysql_ping() > 0) {
printf("» Successfully connected to local database [%s].",SQL_DB_LOCAL);
}
else {
print("» Couldn't connect to local database.");
gConn = mysql_connect(SQL_HOST_HOST, SQL_USER_HOST, SQL_DB_HOST, SQL_PASS_HOST);
if(mysql_ping() > 0) {
printf("» Successfully connected to hosted database [%s].",SQL_DB_HOST);
} else {
printf("» Couldn't connect to any of the databases.Closing server...");
SendRconCommand("exit");
}
}
return 1;
}
Edit->Too slow
