Login Incorrect password
#1

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;
}
Reply
#2

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)