SA-MP Forums Archive
Y_INI Saving Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Y_INI Saving Problem (/showthread.php?tid=489208)



Y_INI Saving Problem - [WA]iRonan - 21.01.2014

I am having problems with Y_INI, the userfile doesn't overwrite existing things but writes the file again.

How a normal user file looks like:
pawn Код:
[Player Stats]
Score = 0
Deaths = 0
Admin = 5
Gmute = 0
Vip = 0
Health = 100
How mine looks like:
pawn Код:
[Player Stats]
Score = 5
Deaths = 0
Admin = 5
Gmute = 1
Vip = 0
Health = 100
[Player Stats]
Score = 0
Deaths = 0
Admin = 5
Gmute = 0
Vip = 0
Health = 100
[Player Stats]
Score = 0
Deaths = 0
Admin = 5
Gmute = 0
Vip = 0
Health = 100
[Player Stats]
Score = 1
Deaths =2
Admin = 5
Gmute = 0
Vip = 0
Health = 100
It seems to be occuring at OnPlayerDisconnect.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
    {
        new INI:file = INI_Open(Path(playerid));
        INI_SetTag(file, "[Player Stats]");
        INI_WriteInt(file,"Score",GetPlayerScore(playerid));
        INI_WriteInt(file,"Deaths",pStats[playerid][deaths]);
        INI_WriteInt(file,"Admin",pStats[playerid][admin]);
        INI_WriteInt(file,"Health",pStats[playerid][health]);
        INI_WriteInt(file,"Vip",pStats[playerid][vip]);
        INI_WriteInt(file,"Gmute",pStats[playerid][gmute]);
        INI_Close(file);
        SaveInventory(playerid);
        new pname[MAX_PLAYER_NAME], string[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof(pname));
        switch(reason)
        {
            case 0: format(string, sizeof(string), TEXT_LEFTCRASHED, pname);
            case 1: format(string, sizeof(string), TEXT_LEFTMANUAL, pname);
            case 2: format(string, sizeof(string), TEXT_LEFTKICKED, pname);
        }
        SendClientMessageToAll(0xAAAAAAAA, string);
        return 1;
    }
What can be the problem?


Re: Y_INI Saving Problem - EiresJason - 21.01.2014

I think this should only happen if the tags are different.

Try setting this as the tag to see if it fixes it. The square brackets are automatically created with INI_SetTag so it's not needed. I also think I did something like this months ago and it caused the same error.

pawn Код:
INI_SetTag(file, "Player Stats");
(Going out so I won't be able to reply for a few hours if it doesn't fix it and no one else replies.)