SA-MP Forums Archive
MySQL not loading on server restart - 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: MySQL not loading on server restart (/showthread.php?tid=415194)



MySQL not loading on server restart - dthompson - 12.02.2013

Hello,

My server is connecting to my corresponding MySQL server each time I restart my server from my host's control panel (a mass restart), however, when I restart my server via. rcon gmx, it never reloads the SQL.

It's a strange bug but I was wondering if anyone could help me with it. Here is my OnGameModeInit and OnGameModeExit parts of my code:

Код:
public OnGameModeInit()
{
    mainconnection = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    sqlconnection = mysql_connect(HOUSE_HOST, HOUSE_USER, HOUSE_NAME, HOUSE_PASSWORD);

.....
Defines.. (all the SQL_Host and blah blah below are filled in, in my game mode)

Код:
//Server database
#define SQL_HOST "N/A" // The SQL host that the game mode will connect to.
#define SQL_USER "N/A"
#define SQL_PASS "N/A"
#define SQL_DB 	 "N/A"

#define HOUSE_TABLE_NAME "Houses"

//House database
#define HOUSE_HOST "N/A"
#define HOUSE_USER "N/A"
#define HOUSE_PASSWORD "N/A"
#define HOUSE_NAME "N/A"
Код:
public OnGameModeExit()
{
	for(new i=1; i < MAX_DVEHICLES; i++)
	{
		if(VehicleCreated[i])
		{
			DestroyVehicle(VehicleID[i]);
			if(VehicleCreated[i] == VEHICLE_DEALERSHIP)
			{
				Delete3DTextLabel(VehicleLabel[i]);
			}
		}
	}
	for(new i=1; i < MAX_DEALERSHIPS; i++)
	{
		if(DealershipCreated[i])
		{
			Delete3DTextLabel(DealershipLabel[i]);
		}
	}
	TextDrawHideForAll(Textdraw0);
	TextDrawDestroy(Textdraw0);
	TextDrawHideForAll(Textdraw1);
	TextDrawDestroy(Textdraw1);
	FadeExit();
	Delete3DTextLabel(Text3D:armysupplies);
    return 1;
}
Cheers


Re: MySQL not loading on server restart - iggy1 - 12.02.2013

Try closing the connection in OnGameModeExit, this MUST be done to prevent an exception/mem leak. IIRC.


Re: MySQL not loading on server restart - dthompson - 12.02.2013

I've tried that with

mysql_close(sqlconnection);
mysql_close(mainconnection);

Still nothing.
Any other tips?


Re: MySQL not loading on server restart - dthompson - 12.02.2013

Still not working.. does anyone else have any other ideas? This is sort of important :P


Re: MySQL not loading on server restart - adsy - 12.02.2013

do you have mySQL_init(); under OnGameModeInit() ??


Re: MySQL not loading on server restart - dthompson - 12.02.2013

MySQL Init just returns an error, don't think that fits in with my plugin...


Re: MySQL not loading on server restart - adsy - 12.02.2013

sorry, I assumed bluegills r7 as you didnt mention which plugin you were using.


Re: MySQL not loading on server restart - dthompson - 12.02.2013

No, no. My fault entirely. I am using Strikenkid's I believe.. however, I have tried BlueG's as well, same traffic.