Notes won't save in the userfile
#1

When I log off, my notes aren't saved in the userfile.

This is the code, what's wrong with it?

pawn Код:
public SavePlayer(playerid) // NOTES SAVES ONLY!
{
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "Accounts/%s.ini", pName);
    new File: UserFile = fopen(string, io_write);
    if (UserFile)
    {
        new var[32];
        format(var, 32, "Note1=%s\n", pInfo[playerid][pNote1]);fwrite(UserFile, var);
        format(var, 32, "Note2=%s\n", pInfo[playerid][pNote2]);fwrite(UserFile, var);
        format(var, 32, "Note3=%s\n", pInfo[playerid][pNote3]);fwrite(UserFile, var);
        format(var, 32, "Note4=%s\n", pInfo[playerid][pNote4]);fwrite(UserFile, var);
        format(var, 32, "Note5=%s\n", pInfo[playerid][pNote5]);fwrite(UserFile, var);
    }
    fclose(UserFile);
}
I search for "Note1" in the userfile but it's not there :/
Reply
#2

You created the folder Accounts, in scriptfiles ?
Reply
#3

Yes, I have a gamemode which is reading values from the user files fine, but in this filterscript it won't. When I logged out, it created me a new .ini file named " .ini" with those values inside. Is it because the Gamemode is using that file on player disconnect too and they conflict?

EDIT: Changed it a bit, still doesn't save

pawn Код:
public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, pName[playerid], sizeof(pName));
    print(pName[playerid]);
    LoadPlayer(playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SavePlayer(playerid);
    return 1;
}
pawn Код:
public SavePlayer(playerid) // NOTES SAVES ONLY!
{
    new string[128];
    format(string, sizeof(string), "VHRP_Scriptfiles/Accounts/%s.ini", pName[playerid]);
    new File: UserFile = fopen(string, io_write);
    if (UserFile)
    {
        new var[100];
        format(var, 100, "Note1=%s\n", pInfo[playerid][pNote1]);fwrite(UserFile, var);
        format(var, 100, "Note2=%s\n", pInfo[playerid][pNote2]);fwrite(UserFile, var);
        format(var, 100, "Note3=%s\n", pInfo[playerid][pNote3]);fwrite(UserFile, var);
        format(var, 100, "Note4=%s\n", pInfo[playerid][pNote4]);fwrite(UserFile, var);
        format(var, 100, "Note5=%s\n", pInfo[playerid][pNote5]);fwrite(UserFile, var);
    }
    fclose(UserFile);
}
Reply
#4

Are you closing the file after opening it on the GM?
Reply
#5

Yes. Is that the problem? Any way to go around it? Because I don't have the .pwn of the gamemode (except for the old backup almost a year old).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)