02.10.2015, 02:13
[quote=jeffery30162;3588815]I do have a lot of saving on my server in the mysql database but it only saves every 30 minutes or when I shut down the server. Also it saves the players data when they disconnect.
I would try to delay the saving between each player, like 2 second for each player, this could probably prevent the server from "hanging"..
Example:
Also, You don't have to save everything every 30 minutes, try to decrease them and just save the important stuff, and try to get a database at the save host.
I would try to delay the saving between each player, like 2 second for each player, this could probably prevent the server from "hanging"..
Example:
pawn Код:
new CurrentID;
//Every 30 minute
TrySavingAllWithoutLag()
{
CurrentID = -1;
TimerName();
}
Save(playerid) return 1;//Replace with your saving function.
forward TimerName();
public TimerName()
{
if(++CurrentID == GetPlayerPoolSize()+1) return 1;
if(IsPlayerConnected(CurrentID)) Save(CurrentID);
SetTimer("TimerName", 2000, false);
return 1;
}
//Note: It was never tested and not guaranteed to work, it's just an idea.