DOF2 Saves Account But Do not Load Data
#1

you will Help me much... +4 Reps (1 per day)
It saves the file with the account data, but when I leave the server and back, it appears the screen to register again and erases all data.
sorry for asking very on this forum, I'm doing this project alone.

pawn Код:
else if(dialogid == DIALOG_ID_LOGIN)
{
LoadPlayer(playerid);
Stock
pawn Код:
stock LoadPlayer(playerid)
{
        new fFile[86];
        if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid)){
        GiveItem[playerid][MED_KIT]         = DOF2_GetInt(fFile, "Items_MED");
        GiveItem[playerid][CZ550]             = DOF2_GetInt(fFile, "Items_CZ550");
        GiveItem[playerid][M4A1]             = DOF2_GetInt(fFile, "Items_M4A1");
        GiveItem[playerid][BANDAGE]         = DOF2_GetInt(fFile, "Items_Bandage");
        GiveItem[playerid][FULL_BOTTLE]         = DOF2_GetInt(fFile, "Items_FullBottle");
        GiveItem[playerid][MAP]             = DOF2_GetInt(fFile, "Items_Map");
        GiveItem[playerid][EMPTY_BOTTLE]    = DOF2_GetInt(fFile, "Items_EmptyBottle");
        SpielerInfo[playerid][pLevel]         = DOF2_GetInt(fFile, "Level");
        SpielerInfo[playerid][Backpack]         = DOF2_GetInt(fFile, "Backpack");
        SpielerInfo[playerid][pAliveMinutes]     = DOF2_GetInt(fFile, "AliveMinutes");
        SpielerInfo[playerid][pAliveSeconds]     = DOF2_GetInt(fFile, "AliveSeconds");
        SpielerInfo[playerid][pBlood]         = DOF2_GetInt(fFile, "Blood");
        SpielerInfo[playerid][pTemparatur1]     = DOF2_GetInt(fFile, "Temparatur");
        SpielerInfo[playerid][pLive]             = DOF2_GetInt(fFile, "Live");
        SpielerInfo[playerid][pDurst]         = DOF2_GetInt(fFile, "Durst");
        SpielerInfo[playerid][pBan]             = DOF2_GetInt(fFile, "Banned");
        SpielerInfo[playerid][isMapUsed]         = DOF2_GetInt(fFile, "MapUsed");
        SpielerInfo[playerid][isAdmin]         = DOF2_GetInt(fFile, "AdminPlayer");
        SpielerInfo[playerid][PosX]             = DOF2_GetFloat(fFile, "PosX");
        SpielerInfo[playerid][PosY]             = DOF2_GetFloat(fFile, "PosY");
        SpielerInfo[playerid][PosZ]             = DOF2_GetFloat(fFile, "PosZ");
        SpielerInfo[playerid][Pass]             = DOF2_GetInt(fFile, "Passw");

    }
    return 1;
}
To Save:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
SavePlayer(playerid);
return 1;
}
stock:
pawn Код:
stock SavePlayer(playerid){

        new name[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid)){
        if(GetPVarInt(playerid,"Eingeloggt") == 1){
        new fFile[86];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerPos(playerid, SpielerInfo[playerid][PosX], SpielerInfo[playerid][PosY], SpielerInfo[playerid][PosZ]);
                        format(fFile, sizeof(fFile), "%s.txt", name);
            DOF2_CreateFile(fFile);

            DOF2_SetInt(fFile, "Passw", SpielerInfo[playerid][Pass]);
                        DOF2_SetInt(fFile, "Level", GetPlayerScore(playerid));
                        DOF2_SetInt(fFile, "Items_MED", GiveItem[playerid][MED_KIT]);
                        DOF2_SetInt(fFile, "Items_CZ550", GiveItem[playerid][CZ550]);
                        DOF2_SetInt(fFile, "Items_M4A1", GiveItem[playerid][M4A1]);
                        DOF2_SetInt(fFile, "Items_Bandage", GiveItem[playerid][BANDAGE]);
                        DOF2_SetInt(fFile, "Items_FullBottle", GiveItem[playerid][FULL_BOTTLE]);
                        DOF2_SetInt(fFile, "Items_Map", GiveItem[playerid][MAP]);
                        DOF2_SetInt(fFile, "Items_Items_EmptyBottle", GiveItem[playerid][EMPTY_BOTTLE]);
                        DOF2_SetInt(fFile, "Backpack", SpielerInfo[playerid][Backpack]);
                        DOF2_SetInt(fFile, "AliveMinutes", SpielerInfo[playerid][pAliveMinutes]);
                        DOF2_SetInt(fFile, "AliveSeconds", SpielerInfo[playerid][pAliveSeconds]);
                        DOF2_SetInt(fFile, "Blood", SpielerInfo[playerid][pBlood]);
                        DOF2_SetInt(fFile, "Temparatur", SpielerInfo[playerid][pTemparatur1]);
                        DOF2_SetInt(fFile, "Live", SpielerInfo[playerid][pLive]);
                        DOF2_SetInt(fFile, "Durst", SpielerInfo[playerid][pDurst]);
                        DOF2_SetInt(fFile, "Banned", SpielerInfo[playerid][pBan]);
                        DOF2_SetInt(fFile, "MapUsed", SpielerInfo[playerid][isMapUsed]);
                        DOF2_SetInt(fFile, "AdminPlayer", SpielerInfo[playerid][isAdmin]);
                        DOF2_SetFloat(fFile, "Backpack", SpielerInfo[playerid][Backpack]);
                        DOF2_SetFloat(fFile, "PosX", SpielerInfo[playerid][PosX]);
                        DOF2_SetFloat(fFile, "PosY", SpielerInfo[playerid][PosY]);
                        DOF2_SetFloat(fFile, "PosZ", SpielerInfo[playerid][PosZ]);
                        DOF2_SetString(fFile, "BanReason", SpielerInfo[playerid][pBanGrund]);
                        DOF2_SetString(fFile, "BanTime", SpielerInfo[playerid][pBanTime]);
                        DOF2_SetString(fFile, "BanDate", SpielerInfo[playerid][pBanDate]);
                        DOF2_SetString(fFile, "BanIP", SpielerInfo[playerid][pBanIP]);
                        DOF2_SaveFile(); // you must save the data with this ^^


        }
    }
    return 1;
}
Dialog login box:
pawn Код:
if(dialogid == DIALOG_ID_REGISTER){
CreateAccount(playerid,MD5_Hash(inputtext));
return 1;
}
Stock:
pawn Код:
public Account(playerid)
{
    new string[256];
    if(GetPVarInt(playerid,"Eingeloggt") == 0){
        new name[MAX_PLAYER_NAME];
  new pp[40];
  GetPlayerName(playerid, name, 32);
  format(pp, 40, "%s.ini", name);
  if(DOF2_FileExists(pp))
  {
    format(string,sizeof(string),"{FFFFFF}Welcome back '%s' to DayZ 0.1\nPlease enter your {FF1E00}password{FFFFFF} now to login!",GetName(playerid));
       ShowPlayerDialog(playerid,DIALOG_ID_LOGIN,DIALOG_STYLE_PASSWORD,"{FFAA00}Welcome to DayZ 0.1",string,"Login","Exit");
  }
   else
   {
        format(string,sizeof(string),"{FFFFFF}Welcome '%s' DayZ 0.1\nPlease enter a {FF1E00}password{FFFFFF} to continue.\n{55FF00}Important: {FFE600}Your password should be safe!",GetName(playerid));
         ShowPlayerDialog(playerid,DIALOG_ID_REGISTER,DIALOG_STYLE_PASSWORD,"{FFAA00}Welcome to DayZ 0.1",string,"Register","Exit");

     }
     }
}
Reply
#2

Its because you havent stored the file path into the string in LoadPlayer function.
pawn Код:
format(fFile, sizeof(fFile), "%s.txt", name);
Reply
#3

not work, its reset the account when i leave from the server and join again... register box
pawn Код:
stock LoadPlayer(playerid)
{
        new fFile[90];
        if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid)){
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(fFile, sizeof(fFile), "%s.txt", name);
        GiveItem[playerid][MED_KIT]         = DOF2_GetInt(fFile, "Items_MED");
        GiveItem[playerid][CZ550]             = DOF2_GetInt(fFile, "Items_CZ550");
        GiveItem[playerid][M4A1]             = DOF2_GetInt(fFile, "Items_M4A1");
        GiveItem[playerid][BANDAGE]         = DOF2_GetInt(fFile, "Items_Bandage");
        GiveItem[playerid][FULL_BOTTLE]         = DOF2_GetInt(fFile, "Items_FullBottle");
        GiveItem[playerid][MAP]             = DOF2_GetInt(fFile, "Items_Map");
        GiveItem[playerid][EMPTY_BOTTLE]    = DOF2_GetInt(fFile, "Items_EmptyBottle");
        SpielerInfo[playerid][pLevel]         = DOF2_GetInt(fFile, "Level");
        SpielerInfo[playerid][Backpack]         = DOF2_GetInt(fFile, "Backpack");
        SpielerInfo[playerid][pAliveMinutes]     = DOF2_GetInt(fFile, "AliveMinutes");
        SpielerInfo[playerid][pAliveSeconds]     = DOF2_GetInt(fFile, "AliveSeconds");
        SpielerInfo[playerid][pBlood]         = DOF2_GetInt(fFile, "Blood");
        SpielerInfo[playerid][pTemparatur1]     = DOF2_GetInt(fFile, "Temparatur");
        SpielerInfo[playerid][pLive]             = DOF2_GetInt(fFile, "Live");
        SpielerInfo[playerid][pDurst]         = DOF2_GetInt(fFile, "Durst");
        SpielerInfo[playerid][pBan]             = DOF2_GetInt(fFile, "Banned");
        SpielerInfo[playerid][isMapUsed]         = DOF2_GetInt(fFile, "MapUsed");
        SpielerInfo[playerid][isAdmin]         = DOF2_GetInt(fFile, "AdminPlayer");
        SpielerInfo[playerid][PosX]             = DOF2_GetFloat(fFile, "PosX");
        SpielerInfo[playerid][PosY]             = DOF2_GetFloat(fFile, "PosY");
        SpielerInfo[playerid][PosZ]             = DOF2_GetFloat(fFile, "PosZ");
        SpielerInfo[playerid][Pass]             = DOF2_GetInt(fFile, "Passw");

    }
    return 1;
}
Reply
#4

I am curious if DOF2_CreateFile will delete the already existing one.

Well, why would you create a file everytime on saving?? Just create it once while registering a user and use fexist rather.

Follow some Tutorials for help.
https://sampforum.blast.hk/showthread.php?tid=281736
Reply
#5

It worked, When the player enters the server, it load the .ini file was .txt.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)