SA-MP Forums Archive
Login problem - 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 problem (/showthread.php?tid=159155)



Login problem[SOLVED] - [XST]O_x - 12.07.2010

Hey guys.
Seems like an error occurred on my register/login system.

Code:
pawn Код:
dcmd_register(playerid, params[])
{
    if(dini_Exists(file) ||  pInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid,Red,"ERROR: You are already registered/logged in.");
    else if(!params[0])
        return SendClientMessage(playerid,Red,"USAGE: /register [password]");
    else if(strlen(params) > 10 || strlen(params) < 4)
        return SendClientMessage(playerid,Red,"ERROR: Current password lengths are between 4 and 10.");

    else
    {
        new password = num_hash(params);
        dini_Create(file);
        pInfo[playerid][Password] = password;
        dini_IntSet(file, "Password", pInfo[playerid][Password]);
        SendClientMessage(playerid, Green,"You are successfuly registered,and logged in,thank you for registering,have fun!");
        pInfo[playerid][Logged] = 1;
    }
    return 1;
}
dcmd_login(playerid, params[])
{
    if(!dini_Exists(file))
        return SendClientMessage(playerid, Red, "ERROR: Please register before you try to login.");
    else if(pInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid, Red, "ERROR: You are already logged-in.");
    else if(!params[0])
        return SendClientMessage(playerid, Red, "USAGE: /login [password]");
    else
    {
        new password = num_hash(params);
        if(pInfo[playerid][Password] == password)
        {
            pInfo[playerid][Logged] = 1;
            return SendClientMessage(playerid, lBlue, "You have successfully logged in to your account.");
        }
        else
        return SendClientMessage(playerid, Red, "ERROR: Incorrect password.");
    }
}
Indentation fucked up? Probably.

Anyway,after I register it successfully hashes the password,but when I try to log-in,it says incorrect password.

I hope you guys can help me solve this one!


Re: Login problem - cessil - 12.07.2010

so when they join does it get the password from the file and save it into pInfo[playerid][Password] before they try to login?


Re: Login problem - [XST]O_x - 12.07.2010

Quote:
Originally Posted by cessil
Посмотреть сообщение
so when they join does it get the password from the file and save it into pInfo[playerid][Password] before they try to login?
Wait,what?

I don't get you,but some confusion occurred in there,but I don't know what.

Edit: I've followed this tutorial:
https://sampwiki.blast.hk/wiki/Creating_...erScript#Login


Re: Login problem - oliverrud - 12.07.2010

It should check in the players text file place, not like that, the player haven't even logged in so I doubt they have loaded any pInfo yet.

I don't know that much of Dini, I'm using MySQL so can't help further on.


Re: Login problem - [XST]O_x - 12.07.2010

Erm D:
Okay then,maybe anyone else could help?


Re: Login problem - novox - 12.07.2010

before you do the password check (if they match) make sure you get the stored password, i don't see anywhere in your script where you do that


Re: Login problem - MadeMan - 12.07.2010

Where do you save player's password to pInfo[playerid][Password] ?


Re: Login problem - [XST]O_x - 12.07.2010

dini_IntSet(file, "Password", pInfo[playerid][Password]);

And also in OnPlayerDisconnect.


Re: Login problem - MadeMan - 12.07.2010

pawn Код:
new password = num_hash(params);
if(dini_Int(file, "Password") == password)



Re: Login problem - [XST]O_x - 12.07.2010

Like this?
pawn Код:
dcmd_login(playerid, params[])
{
    format(file,sizeof(file),PlayerFile,pName(playerid));
    if(!dini_Exists(file))
        return SendClientMessage(playerid, Red, "ERROR: Please register before you try to login.");
    else if(pInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid, Red, "ERROR: You are already logged-in.");
    else if(!params[0])
        return SendClientMessage(playerid, Red, "USAGE: /login [password]");
    else
    {
        new password = num_hash(params);
        if(dini_Int(file, "Password") == password)
        {
            pInfo[playerid][Logged] = 1;
            return SendClientMessage(playerid, lBlue, "You have successfully logged in to your account.");
        }
        else
        return SendClientMessage(playerid, Red, "ERROR: Incorrect password.");
    }
}
Because that didn't work either o.O