SetTimer("SaveAllData", 180000, 1);
forward SaveAllData();
public SaveAllData()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if( IsPlayerConnected( i ) )
{
new query[150+1000];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP` = '%e', `Admin` = %d, `VIP` = %d, `Kills` = %d,`Cookies` = %d,`Cakes` = %d,`Icecream` = %d, `Deaths` = %d, `Score` = %d, `Money` = %d, `Hours` = %d,\
`Minutes` = %d, `RaceWon` = %d WHERE `ID` = %d",
IP[i], pData[i][Admin], pData[i][VIP], pData[i][Kills],pData[i][Cookies],pData[i][Cakes],pData[i][Icecream], pData[i][Deaths], GetPlayerScore(i),\
GetPlayerMoney(i), pData[i][pHours], pData[i][pMinutes],pData[i][RaceWon],pData[i][ID]);
mysql_query(mysql, query);
}
new str[128];
SendClientMessageToAll(0x009D00DB,"Your player data have been saved into(Database)");
format(str, sizeof(str),"* AutoSaveSystem saved all the online player stats (Total %d)",GetOnLinePlayers());
IRC_GroupSay(groupID, IRC_CHANNEL, str);
}
return 1;
}
forward SaveAllData();
public SaveAllData()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if( IsPlayerConnected( i ) )
{
new query[236+75];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP` = '%e', `Admin` = %d, `VIP` = %d, `Kills` = %d,`Cookies` = %d,`Cakes` = %d,`Icecream` = %d, `Deaths` = %d, `Score` = %d, `Money` = %d, `Hours` = %d,\
`Minutes` = %d, `RaceWon` = %d WHERE `ID` = %d",
IP[i], pData[i][Admin], pData[i][VIP], pData[i][Kills],pData[i][Cookies],pData[i][Cakes],pData[i][Icecream], pData[i][Deaths], GetPlayerScore(i),\
GetPlayerMoney(i), pData[i][pHours], pData[i][pMinutes],pData[i][RaceWon],pData[i][ID]);
mysql_query(mysql, query);
}
}
//put it outside the loop. Fixed
new str[128];
SendClientMessageToAll(0x009D00DB,"Your player data have been saved into(Database)");
format(str, sizeof(str),"* AutoSaveSystem saved all the online player stats (Total %d)",GetOnLinePlayers());
IRC_GroupSay(groupID, IRC_CHANNEL, str);
return 1;
}
forward SaveAllData();
public SaveAllData()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if( IsPlayerConnected( i ) )
{
new query[150+1000];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP` = '%e', `Admin` = %d, `VIP` = %d, `Kills` = %d,`Cookies` = %d,`Cakes` = %d,`Icecream` = %d, `Deaths` = %d, `Score` = %d, `Money` = %d, `Hours` = %d,\
`Minutes` = %d, `RaceWon` = %d WHERE `ID` = %d",
IP[i], pData[i][Admin], pData[i][VIP], pData[i][Kills],pData[i][Cookies],pData[i][Cakes],pData[i][Icecream], pData[i][Deaths], GetPlayerScore(i),\
GetPlayerMoney(i), pData[i][pHours], pData[i][pMinutes],pData[i][RaceWon],pData[i][ID]);
mysql_query(mysql, query);
new str[128];
SendClientMessageToAll(0x009D00DB,"Your player data have been saved into(Database)");
format(str, sizeof(str),"* AutoSaveSystem saved all the online player stats (Total %d)",GetOnLinePlayers());
IRC_GroupSay(groupID, IRC_CHANNEL, str);
}
}
return 1;
}
|
Logical enough since you've put the messages to be sent under the Loop! Moving the code outside the loop will fix it. Also, use foreach or GetPlayerPoolSize loops!
|
forward SaveAllData();
public SaveAllData()
{
new query[300];
foreach(new i: Player)
{
mysql_format(mysql, query, sizeof query, "UPDATE `players` SET `IP` = '%e', `Admin` = %d, `VIP` = %d, `Kills` = %d,`Cookies` = %d,`Cakes` = %d,`Icecream` = %d, `Deaths` = %d, `Score` = %d, `Money` = %d, `Hours` = %d,\
`Minutes` = %d, `RaceWon` = %d WHERE `ID` = %d",
IP[i], pData[i][Admin], pData[i][VIP], pData[i][Kills],pData[i][Cookies],pData[i][Cakes],pData[i][Icecream], pData[i][Deaths], GetPlayerScore(i),
GetPlayerMoney(i), pData[i][pHours], pData[i][pMinutes],pData[i][RaceWon],pData[i][ID]);
mysql_query(mysql, query);
}
new str[128];
SendClientMessageToAll(0x009D00DB,"Your player data have been saved into Database.");
format(str, sizeof(str),"* Auto Save System has saved all the online player stats (Total %d)",GetOnLinePlayers());
IRC_GroupSay(groupID, IRC_CHANNEL, str);
return 1;
}