Make a function that will get the player's stats every maybe 5 seconds. Then save it like:
pawn Код:
dini_Int(archivo, "Score", GetPlayerScore(playerid));
Here is an example:
Make 3 new variables at the top of your script: new SaveStats[32],file[32],Name[32];
pawn Код:
forward Save(playerid)
public Save(playerid)
{
if(PlayerData[playerid][Logged] == 1 && Spawned[playerid] == 1 && IsSpecing[playerid] == 0 && !IsPlayerNPC(playerid) && IsPlayerConnected(playerid))//Nevermind these, you will see the relevance of it when you make your admin script.
{
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "Accounts/%s.ini", Name);
if(dini_Exists(file))
{
dini_IntSet(file, "Cash", GetPlayerCash(playerid));
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "AdminLevel", PlayerData[playerid][AdminLevel]);
}
}
}
Just do this when the player logs in:
pawn Код:
SaveStats[playerid] = SetTimerEx("Save",5000,true,"i",playerid);
When they disconnect:
pawn Код:
KillTimer(SaveStats[playerid]);