[MySQL] after crash no saving
#1

hello, when server crashes unecspectly all server players who is in server at the moment has no save and they all get 0 everything,

pawn Код:
public OnGameModeExit()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        MySQL_Save(i);
    }
    mysql_close( );
        return 1;
}
Reply
#2

There honestly isn't a good way to prevent this. One thing about MySQL is that it takes a little longer to process than say... a file-based system. If you aren't threading your queries and you have 20 people online, if the server exits unexpectedly, most of the players won't get their data saved.

I have found it best to make your own restart commands and before the server restarts, you would save all server/player data. I'm not sure if there's a way to prevent the "gmx" command from being used, but if there is, it might be a good idea. However, a fresh start is generally better (closing the SA:MP server, then re-opening it).
Reply
#3

why my server restarts i don't know thats the deal, and in my server awerage playing ~ 70 players so i thing that mysql didint save it quick as it should save, so i need a solution, maybe a timer whos saving all players data in some time?
Reply
#4

You SHOULD already have a timer saving player data every like 15-30 minutes anyways...

Get yourself y_timers and foreach. Then add this to your code somewhere! It saves data every 15 minutes.

pawn Код:
task savePlayerData[60000*15]()
{
    foreach(new i : Player)
    {
        MySQL_Save(i);
    }
    return 1;
}
What you COULD do is replace mysql_close() with this:

pawn Код:
defer delayConnectionClose();
Then add this in the same place you added the other timer (the first piece of code I gave you).

pawn Код:
timer delayConnectionClose[1000]()
{
    mysql_close();
}
It will AT LEAST allow some more MySQL queries to process before it just closes the connection.
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You SHOULD already have a timer saving player data every like 15-30 minutes anyways...

Get yourself y_timers and foreach. Then add this to your code somewhere! It saves data every 15 minutes.

pawn Код:
task savePlayerData[60000*15]()
{
    foreach(new i : Player)
    {
        MySQL_Save(i);
    }
    return 1;
}
What you COULD do is replace mysql_close() with this:

pawn Код:
defer delayConnectionClose();
Then add this in the same place you added the other timer (the first piece of code I gave you).

pawn Код:
timer delayConnectionClose[1000]()
{
    mysql_close();
}
It will AT LEAST allow some more MySQL queries to process before it just closes the connection.
tryed that, still non saving all the players, whit dini i don't have this problem
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)