public CheckStats(playerid) { for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "money", GetPlayerMoney(i)); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "AdminLevel", (PlayerInfo[i][AdminLevel])); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "score", GetPlayerScore(i)); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "Bombs", (PlayerInfo[i][Bombs])); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "PainKillers", (PlayerInfo[i][PainKillers])); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "Kills", (PlayerInfo[i][Kills])); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "Deaths", (PlayerInfo[i][Deaths])); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "Level", (PlayerInfo[i][Level])); for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))dini_IntSet(file, "RemoteBombs", (PlayerInfo[i][RemoteBombs])); return 1; } |
SetTimerEx("CheckStats", 60*1000, 1, "i", playerid); SetPlayerScore(playerid, dini_Int(file, "score")); GivePlayerMoney(playerid, dini_Int(file, "money")); PlayerInfo[playerid][AdminLevel]=dini_Int(file,"AdminLevel"); PlayerInfo[playerid][Bombs]=dini_Int(file,"Bombs"); PlayerInfo[playerid][PainKillers]=dini_Int(file,"PainKillers"); PlayerInfo[playerid][Level]=dini_Int(file,"Level"); PlayerInfo[playerid][Kills]=dini_Int(file,"Kills"); PlayerInfo[playerid][Deaths]=dini_Int(file,"Deaths"); PlayerInfo[playerid][RemoteBombs]=dini_Int(file,"RemoteBombs"); |
Originally Posted by DJDhan
Also, there is no need to write the stats of a player every minute to a file when you can save the stats under OnPlayerDisconnect.
|
public CheckStats(playerid)
{
for(new i; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
dini_IntSet(file, "money", GetPlayerMoney(i));
dini_IntSet(file, "AdminLevel", PlayerInfo[AdminLevel]);
dini_IntSet(file, "score", GetPlayerScore(i));
dini_IntSet(file, "Bombs", (PlayerInfo[Bombs]));
dini_IntSet(file, "PainKillers", PlayerInfo[PainKillers]);
dini_IntSet(file, "Kills", PlayerInfo[Kills]);
dini_IntSet(file, "Deaths", PlayerInfo[Deaths]);
dini_IntSet(file, "Level", PlayerInfo[Level]);
dini_IntSet(file, "RemoteBombs", PlayerInfo[RemoteBombs]);
break;
}
}
return 1;
}
SetTimerEx("CheckStats", 5000, 1, "i", playerid); //Calls Checkstats every 5 secs.
SetPlayerScore(playerid, dini_Int(file, "score"));
GivePlayerMoney(playerid, dini_Int(file, "money"));
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
PlayerInfo[playerid][Bombs] = dini_Int(file, "Bombs");
PlayerInfo[playerid][PainKillers] = dini_Int(file, "PainKillers");
PlayerInfo[playerid][Level] = dini_Int(file, "Level");
PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
PlayerInfo[playerid][Deaths] = dini_Int(file, "Deaths");
PlayerInfo[playerid][RemoteBombs] = dini_Int(file, "RemoteBombs");