Why This Won't Save The Players' Information?
#2

Instead of doing it ongamemodeinit, just do it under onplayerdisconnect. So when players disconnect, it will save their data no matter what.

pawn Код:
stock SaveUser(playerid)
{
    new INI:File = INI_Open(UserPath(i));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(i));
    INI_WriteInt(File,"Admin",PlayerInfo[i][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[i][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[i][pDeaths]);
    INI_WriteInt(File,"Score",LPinfo[i][Score]);
    INI_WriteInt(File,"Drugs",LPinfo[i][Drugs]);
    INI_WriteInt(File,"Adrenaline",LPinfo[i][Adre]);
    INI_WriteInt(File,"Registered",1);
    INI_WriteInt(File,"Logged",0);
    INI_WriteInt(File,"VIPLevel",Info[i][VIPLevel]);
    INI_WriteInt(File,"Banned",Info[i][Banned]);
    INI_WriteInt(File,"MissionsCompleted",Info[i][MissionsCompleted]);
    INI_WriteInt(File,"MissionsFailed",Info[i][MissionsFailed]);
    INI_WriteInt(File,"Robbed",Info[i][Robbed]);
    INI_WriteInt(File,"MaximumRobbed",Info[i][MaximumRobbed]);
    INI_WriteInt(File,"Muted",Info[i][Muted]);
    INI_WriteInt(File,"Jailed",Info[i][Jailed]);
    INI_WriteInt(File,"MuteWarnings",Info[i][MuteWarnings]);
    INI_WriteInt(File,"Warnings",Info[i][Warnings]);
    INI_WriteInt(File,"TimesKicked",Info[i][TimesKicked]);
    INI_WriteInt(File,"EventsWon",Info[i][EventsWon]);
    INI_WriteInt(File,"EventsLost",Info[i][EventsLost]);
    INI_Close(File);
    return 1;


//onplayerdisonnect
for(new i; i < MAX_PLAYERS; i++)
{
      SaveUser(i);
}
}
EDIT: I don't remember if onplayerdisconnect is called when a gamemode exits. Or if yini would even have a chance to write once you exit.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)