Password isn't saved [YINI]
#1

What's the wrong? Please help, important to me.

pawn Код:
enum xInfo
{
    xPass[129],
    xNovac,
    xAdmin,
    xPol,
    xGodine,
    xDrzava,
    xPayDayTime,
    xOnlineMin,
    xOnlineHours,
    xLevel,
    xRespekt,
    xWarns
}
new PlayerInfo[MAX_PLAYERS][xInfo];

//OnPlayerConnect
if(fexist(Path(playerid)))
    {
        for(new i = 0; i < 7; i++) TextDrawShowForPlayer(playerid, LoginTD[playerid][i]);
        INI_ParseFile(Path(playerid),"UcitajPodatke_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{0066FF}Login - {0099FF}Dobrodosli","{808080}Vaљ racun je registrovan.\nPre nego sto pocnete sa igrom, morate se ulogovati. Upisite svoju sifru.","Uloguj","Izadji");
        SetPlayerCameraPos(playerid, 784.8425,-2122.6650,-16.5498);
        SetPlayerCameraLookAt(playerid, 666.5518,-2100.6987,-1.6760);
    }
    else
    {
        for(new i = 0; i < 8; i++) TextDrawShowForPlayer(playerid, ConnectTD[playerid][i]);
        SetPlayerVirtualWorld(playerid, playerid+1);
        SetPVarInt(playerid,"Registrovan",0);
        SetTimerEx("Registracija",5000,0,"d",playerid);
        return 1;
    }
//Dialog
case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))
                {
                    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"|Prijava za let|","""{686868}Da bi ste se ukrcali na avion, morate upisati sifru.\n\nOvu sifru cete koristiti da se prijavite u Los Santos.\n\n{800000}Napomena: {686868}To ce vam biti sifra accounta.","Prijava","Izadji");
                    return 1;
                }
                new hashpass[129];
                WP_Hash(hashpass,sizeof(hashpass),inputtext);
                new INI:file = INI_Open(Path(playerid));
                INI_ParseFile(Path(playerid),"UcitajPodatke_%s",.bExtra = true, .extra = playerid);
                INI_SetTag(file,"User");
                INI_WriteString(file,"Password",hashpass);
                INI_WriteInt(file,"Cash",0);
                INI_WriteInt(file,"Admin",0);
                INI_WriteInt(file,"Pol",PlayerInfo[playerid][xPol]);
                INI_WriteInt(file,"Godine",PlayerInfo[playerid][xGodine]);
                INI_WriteInt(file,"Drzava",PlayerInfo[playerid][xDrzava]);
                INI_WriteInt(file,"Level", PlayerInfo[playerid][xLevel]);
                INI_WriteInt(file,"PlacaTime", PlayerInfo[playerid][xPayDayTime]);
                INI_WriteInt(file,"OnlineM", PlayerInfo[playerid][xOnlineMin]);
                INI_WriteInt(file,"OnlineH", PlayerInfo[playerid][xOnlineHours]);
                INI_WriteInt(file,"Respekti", PlayerInfo[playerid][xRespekt]);
                INI_WriteInt(file, "Upozorenja", PlayerInfo[playerid][xWarns]);
                INI_Close(file);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Avion | Ukrcavanje","{686868}Uspeљno ste se prijavili.\n\nSada se moћete ukrcati na avion.","Ukrcaj se","");
                SetPVarInt(playerid,"Registrovan",1);
                return 1;
            }
        }
        case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                new hashpass[129];
                WP_Hash(hashpass,sizeof(hashpass),inputtext);
                if(!strcmp(hashpass,PlayerInfo[playerid][xPass]))
                {
                    INI_ParseFile(Path(playerid),"UcitajPodatke_%s",.bExtra = true, .extra = playerid);
                    pLogged{playerid} = (true);
                    SetPVarInt(playerid,"Ulogiran",1);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][xNovac]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][xLevel]);
                    TogglePlayerSpectating(playerid, 0);
                    KreirajBox(playerid,"Xperia","Uspesno si se ulogirao.");
                    SetTimerEx("UkloniInfoBox",3000,0,"d",playerid);
                    XSetSpawnInfo(playerid);
                    for(new i = 0; i < 7; i++) TextDrawHideForPlayer(playerid, LoginTD[playerid][i]);
                    UpdatePlayer();
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"Upisali ste netacnu lozinku.\nPokusajte ponovo.","Uloguj","Izadji");
                    return 1;
                }
            }
        }

forward UcitajPodatke_User(playerid, name[], value[]);
public UcitajPodatke_User(playerid, name[], value[])
{
    INI_String("Password", PlayerInfo[playerid][xPass],129);
    INI_Int("Cash", PlayerInfo[playerid][xNovac]);
    INI_Int("Admin", PlayerInfo[playerid][xAdmin]);
    INI_Int("Pol", PlayerInfo[playerid][xPol]);
    INI_Int("Godine", PlayerInfo[playerid][xGodine]);
    INI_Int("Drzava", PlayerInfo[playerid][xDrzava]);
    INI_Int("Level", PlayerInfo[playerid][xLevel]);
    INI_Int("PlacaTime", PlayerInfo[playerid][xPayDayTime]);
    INI_Int("OnlineM", PlayerInfo[playerid][xOnlineMin]);
    INI_Int("OnlineH", PlayerInfo[playerid][xOnlineHours]);
    INI_Int("Respekti", PlayerInfo[playerid][xRespekt]);
    INI_Int("Upozorenja", PlayerInfo[playerid][xWarns]);
    return 1;
}

stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),IgracevFolder,name);
    return str;
}

stock UpdatePlayer()
{
    foreach(Player, i)
    {
        if(fexist(Path(i)))
        {
            new hashpass[129];
            new INI:file = INI_Open(Path(i));
            INI_ParseFile(Path(i),"UcitajPodatke_%s", .bExtra = true, .extra = i);
            INI_SetTag(file,"User");
            INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file,"Cash",GetPlayerMoney(i));
            INI_WriteInt(file,"Admin",PlayerInfo[i][xAdmin]);
            INI_WriteInt(file,"Pol",PlayerInfo[i][xPol]);
            INI_WriteInt(file,"Godine",PlayerInfo[i][xGodine]);
            INI_WriteInt(file,"Drzava",PlayerInfo[i][xDrzava]);
            INI_WriteInt(file,"Level", PlayerInfo[i][xLevel]);
            INI_WriteInt(file,"PlacaTime", PlayerInfo[i][xPayDayTime]);
            INI_WriteInt(file,"OnlineM", PlayerInfo[i][xOnlineMin]);
            INI_WriteInt(file,"OnlineH", PlayerInfo[i][xOnlineHours]);
            INI_WriteInt(file,"Respekti", PlayerInfo[i][xRespekt]);
            INI_WriteInt(file, "Upozorenja", PlayerInfo[i][xWarns]);
            INI_Close(file);
        }
    }
    return 1;
}
Reply
#2

... what's the error you're receiving? You can't just post code, say "help me" and leave it at that.

Explain what isn't working!
Reply
#3

Title: "Password isn't saved [YINI]"

No error, just don't save the password
Reply
#4

Oh shit, sorry. :P

Use print statements under your register dialog to determine if the input text is being received. Then make another one to see what the hash is after going through Whirlpool. And, then make another one RETRIEVING the data from the file after your write to it.
Reply
#5

Why do you need to parse the file when they're registering? Try removing it(INI_ParseFile).
Reply
#6

RealCop228, I don't understand you. Can you do it?

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
Why do you need to parse the file when they're registering? Try removing it(INI_ParseFile).
I deleted it but doesn't work
Reply
#7

As Realcop said: Use prints between every line to get the information of what's being saved and whatnot.

print would be the most fitting function to use, as you'd want to output the content of inputtext and hashpass (who both are strings - no need to use printf).
Reply
#8

pawn Код:
new hashpass[129];
            new INI:file = INI_Open(Path(i));
            INI_ParseFile(Path(i),"UcitajPodatke_%s", .bExtra = true, .extra = i);
            INI_SetTag(file,"User");
            INI_WriteString(file,"Password",hashpass);
Why are you creating a variable 'hashpass', then setting this blank/null variable as your password? As far as I can see, this code is running straight after you log in.
Reply
#9

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
new hashpass[129];
            new INI:file = INI_Open(Path(i));
            INI_ParseFile(Path(i),"UcitajPodatke_%s", .bExtra = true, .extra = i);
            INI_SetTag(file,"User");
            INI_WriteString(file,"Password",hashpass);
Why are you creating a variable 'hashpass', then setting this blank/null variable as your password? As far as I can see, this code is running straight after you log in.
He's using WP_Hash (Whirlpool) and stores the hash of inputtext into hashpass - how did you miss that part of the code?
Reply
#10

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
new hashpass[129];
            new INI:file = INI_Open(Path(i));
            INI_ParseFile(Path(i),"UcitajPodatke_%s", .bExtra = true, .extra = i);
            INI_SetTag(file,"User");
            INI_WriteString(file,"Password",hashpass);
Why are you creating a variable 'hashpass', then setting this blank/null variable as your password? As far as I can see, this code is running straight after you log in.
Doesn't work :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)