28.11.2017, 05:18
If you're trying to initialize the logging system, use the following:
If you're trying to actually start the database, then I have the following:
* Let me know if I'm missing anything for it to not throw errors. - Just quickly copied and pasted the functions I quickly reviewed. *
Код:
mysql_log( MYSQL_LOG_TYPE );
Код:
public OnGameModeInit() {
new launchTime = GetTickCount();
MySQLConnect();
if(mysql_errno())
{
SendRconCommand( "hostname "GAMEMODE_HOSTNAME" | *error*" );
SetGameModeText( ""GAMEMODE_NAME" | *error*" );
return MysqlErrorMessage( INVALID_PLAYER_ID );
}
else
{
SendRconCommand( "hostname "GAMEMODE_HOSTNAME"" );
SetGameModeText( ""GAMEMODE_NAME"" );
mysql_log( MYSQL_LOG_TYPE );
printf( "-> Gamemode ("GAMEMODE_NAME") successfully launched! (%d ms)", GetTickCount() - launchTime );
}
return 1;
}
public OnGameModeExit() {
mysql_close();
return 1;
}
public MysqlErrorMessage( playerid ) {
if ( playerid == -1 )
return printf( "-> Error sending the query to the database! (Error Code: #%d)", mysql_errno() );
else {
new mysqlError[200];
format( mysqlError, sizeof( mysqlError ), "There was an issue loading your account. Please try and relog. If the issue a persists, make a report on forums." , mysql_errno() );
SendClientMessage( playerid, -1, mysqlError );
PlayerKick( playerid );
printf( "-> Error sending the query to the database! ( Error Code: #%d )", mysql_errno() );
}
return 1;
}
stock MySQLConnect() {
new connecttime = GetTickCount();
MySQL_C1 = mysql_connect( MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
if (mysql_errno()) return print("-> Connect to database '"MYSQL_DB"' has not been established.");
else printf("-> Connect to database '"MYSQL_DB"' was successfully established. (%d ms)", GetTickCount() - connecttime );
return true;
}

