Mysql saving problem
#1

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;
}
Reply
#2

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");
Reply
#3

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 ?
Reply
#4

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

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;
}
Reply
#6

Try it. One way to find out
Reply
#7

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
Reply
#8

This happen only when you use /gmx?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)