SA-MP Forums Archive
Login Incorrect password - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Login Incorrect password (/showthread.php?tid=254272)



Login Incorrect password - jamesbond007 - 10.05.2011

always getting an incorrect password even with the right pass ... plz help ..

pawn Code:
dcmd_login(playerid, params[])
{
    if(strlen(params)==0) return SendClientMessage(playerid, red, "USAGE: /login [password]");
    if(PlayerInfo[playerid][Registered] == 0) return SendClientMessage(playerid, red, "Error: You must be registered to log in.");
    if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid, red, "Error: You are already logged in!");
    new pname[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(str, sizeof(str),"users/%s.txt",pname);
    if(PlayerInfo[playerid][Registered] == 1)
    {
        new string[128], File:ftw = fopen(str,io_read);
        while(fread(ftw, string))
        {
            if(strcmp(string, params, false, strlen(params)) == 0)
            {
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                PlayerInfo[playerid][LoggedIn] = true;
                SendClientMessage(playerid, red, "Account: You have successfully logged in.");
            }
            else return SendClientMessage(playerid, red, "Error: Incorrect Password.");
        }
        fclose(ftw);
    }
    return 1;
}



Re: Login Incorrect password - JaTochNietDan - 10.05.2011

Well you're only reading the first line, so you're assuming that the first line is the un-encrypted password? It doesn't make a lot of sense, how are you storing the password in the first place?


- jamesbond007 - 10.05.2011

thanks but how do i read the whole file
pawn Code:
new string[128], File:ftw = fopen(str,io_read);
            fread(ftw, string);
            if(strcmp(params, string, false) == 0)
            {
                PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                PlayerInfo[playerid][LoggedIn] = true;
                SendClientMessage(playerid, red, "Account: You have successfully logged in.");
            }
            else return SendClientMessage(playerid, red, "Error: Incorrect Password.");
            fclose(ftw);
-NVM- Fixed it ! ty vm