Mysql p
#6

If you're trying to initialize the logging system, use the following:
Код:
mysql_log( MYSQL_LOG_TYPE );
If you're trying to actually start the database, then I have the following:
Код:
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;

}
* Let me know if I'm missing anything for it to not throw errors. - Just quickly copied and pasted the functions I quickly reviewed. *
Reply


Messages In This Thread
Mysql p - by Hunud - 27.11.2017, 12:28
Re: Mysql p - by Hunud - 27.11.2017, 12:50
Re: Mysql p - by rfr - 27.11.2017, 16:15
Re: Mysql p - by Hunud - 27.11.2017, 17:05
Re: Mysql p - by Meller - 27.11.2017, 17:54
Re: Mysql p - by Daymen - 28.11.2017, 05:18

Forum Jump:


Users browsing this thread: 1 Guest(s)