Save all players - 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: Save all players (
/showthread.php?tid=665585)
Save all players -
KamilPolska - 09.04.2019
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;
}
Re: Save all players -
Markski - 09.04.2019
Check if mysql_log.txt has any errors.
Re: Save all players -
KamilPolska - 10.04.2019
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.
Re: Save all players -
TheToretto - 10.04.2019
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.
Re: Save all players -
KamilPolska - 10.04.2019
Thanks! The problem was that SetTimer was at the bottom.
Code:
SetTimer("SavePlayersAll", 60000, true);
return 1;