19.09.2014, 20:26
pawn Код:
//Under OnGameMode
SetTimer("SavePlayerData",180000,1);
//.....
public SavePlayerData()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if( IsPlayerConnected( i ) )
{
new query[600];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d,`Money`=%d,`Cookies`=%d,`Kills`=%d,`Deaths`=%d,`Score`=%d,`Banned`=%d,`Bannedfor`=%s,`Bannedby`=%e,`BannedDate`=%d WHERE `ID`=%d",\
pInfo[i][Admin], pInfo[i][Money], pInfo[i][Cookies], pInfo[i][Kills], pInfo[i][Deaths],pInfo[i][Score],pInfo[i][Banned], pInfo[i][Bannedfor], pInfo[i][Bannedby], pInfo[i][BannedDate] ,pInfo[i][ID]);
//We update the table(`players`) by getting player's admin level, vip level, money, and positions and save them in the database
mysql_tquery(mysql, query, "", "");
}
new str[128];
SendClientMessageToAll(0x009D00DB,"Your player data have been saved into(Database)");
format(str, sizeof(str),"* Admin AutoSave (ID:007) saved all regged player stats (Total %d)",GetOnLinePlayers());
IRC_GroupSay(groupID, IRC_CHANNEL, str);
}
return 1;
}