Save all players
#1

I would like to add SetTimer every 1 minute to OnGameModeInit so that the accounts are saved to all players. I do not want it to be for one player only for all players. How to do it in MySQL BlueG?
It does not work:
Code:
forward SavePlayersAll();
public SavePlayersAll()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
	if(IsPlayerConnected(i))
	{
	    	if(pLogged[i])
	    	{
			new query[650];
			PlayerInfo[i][Money] = GetPlayerMoney(i);
			mysql_format(g_SQL, query, sizeof(query), "UPDATE `accounts` SET `Money` = %d WHERE `ID` = %d LIMIT 1", PlayerInfo[i][Money], PlayerInfo[i][ID]);
			mysql_tquery(g_SQL, query);
	     	}
	}
    }
    SendClientMessageToAll(-1, "All accounts have been saved!");
    return 1;
}
Reply
#2

Check if mysql_log.txt has any errors.
Reply
#3

There are no logs. When I use the CMD command it saves but SetTimer does not write down every 1 minute and nothing happens, there are no logs.
Reply
#4

What you're requesting is what the function does, if you're asking for a timer then it's:

pawn Code:
SetTimer("SavePlayersAll", 60000, true);
If it's not working (what you said) then use debugs, is pLogged positive? Is it set to true? Use debugs.
Reply
#5

Thanks! The problem was that SetTimer was at the bottom.
Code:
SetTimer("SavePlayersAll", 60000, true);
return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)