Y_INI Saving Problem
#1

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?
Reply
#2

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.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)