SA-MP Forums Archive
PING with "a_mysql" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PING with "a_mysql" (/showthread.php?tid=510966)



PING with "a_mysql" - jcvag44800 - 03.05.2014

Hello,

I would like to know how obtain the ping from the include "a_samp.inc" ?

I test like that:

Код:
	if(mysql_ping()==0)
	{
		print("MYSQL: Database connection established.");
		return 1;
	}
But mysql_ping doesn't exist...
How I can do that ?

Regards


Re: PING with "a_mysql" - Vince - 03.05.2014

I newer versions, this function doesn't exist because the MySQL plugin will automatically reconnect if it loses connection. I suppose you could check if the connection handle is valid (i.e. > 0).


Re: PING with "a_mysql" - iZN - 03.05.2014

There is mysql_errno, so simply:

pawn Код:
mysql_connect(.....

if(mysql_errno() != 0)
{
    print(!"MySQL: Failed to connect.");
    SendRconCommand("exit");
    return false;
}
print(!"MySQL: Connecting successful!");