SA-MP Forums Archive
Mysql saving problem - 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 saving problem (/showthread.php?tid=510607)



Mysql saving problem - ShoortyFl - 01.05.2014

So, i've created mysql sys, but i have a problem. It happens sometime and i don't know why. When i use rcon gmx command all user data sets to 0 without any reason that i'm aware. Please help me.

Updating Syst:



Код:
public OnPlayerDisconnect(playerid, reason)
{
	UpdateIgraca(playerid);
	return 1;
}
Код:
stock UpdateIgraca(playerid)
{
	new Query[2000];
	format(Query, sizeof(Query), "UPDATE `igraci` SET `Novac` = '%d', `Registrovan` = '%d', `Level` = '%d', `Iskustvo` = '%d', `PDPoeni` = '%d', `Admin` = '%d', `Godine` = '%d', `Spol` = '%d', `Drzava` = '%d', `Skin` = '%d', `Posao` = '%d', `PosaoUgovor` = '%d', `Banovan` = '%d' WHERE `Ime` = '%s'", PI[playerid][Novac], PI[playerid][Registrovan], PI[playerid][Level],
	PI[playerid][Exp], PI[playerid][PayDayPoeni], PI[playerid][Admin], PI[playerid][Godine], PI[playerid][Spol], PI[playerid][Drzava], PI[playerid][Skin], PI[playerid][Posao], PI[playerid][PosaoUgovor], PI[playerid][Banovan], ImeIgraca(playerid));
	mysql_query(Query);
	return 1;
}



Re: Mysql saving problem - AphexCCFC - 01.05.2014

Restarting the server is actually OnGameModeExit.
I suggest you make a command to kick all players (calls OnPlayerDisconnect and saves stats) then set a timer to restart the server using:

pawn Код:
SendRconCommand("gmx");



Re: Mysql saving problem - ShoortyFl - 01.05.2014

Is there any way to create something like adding function Update in GameModeExit so players don't have to exit the server and relog bc of kicking ?


Re: Mysql saving problem - AphexCCFC - 01.05.2014

Gamemode exits and players lose the connection before it has chance to save player accounts.


Re: Mysql saving problem - ShoortyFl - 01.05.2014

Can i simply create something like this ?

Код:
CMD:gmx(playerid, params[])
{
	foreach(Player, i)
	{
	    UpdateIgraca(i);
	}
	gmxtimer = SetTimer("Restart", 1000, true)
	return 1;
}

public Restart()
{
    SendRconCommand("gmx");
	return 1;
}



Re: Mysql saving problem - AphexCCFC - 01.05.2014

Try it. One way to find out


Re: Mysql saving problem - ShoortyFl - 01.05.2014

Well actually i dont know if its going to work, the lost of data is not expected server works for a while and then it just resets all variables to 0 in phpmyadmin


Re: Mysql saving problem - AphexCCFC - 01.05.2014

This happen only when you use /gmx?