I can't login -
newbienoob - 16.05.2012
I tried to follow
this tutorial. Everything was fine, but I can't login
pawn Код:
if(dialogid == login)
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_hash(inputtext) == pInfo[playerid][pass])
{
INI_ParseFile(Path(playerid),"loaduser_%s",.bExtra = true, .extra = playerid);
GivePlayerMoney(playerid,pInfo[playerid][money]);
SetPlayerScore(playerid,pInfo[playerid][score]);
}
else
{
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password. \nThe name is registered. Enter your password to login to your account.","Login","Quit");
}
return 1;
}
}
It says "You have entered an incorrect password...".
Re: I can't login -
ReneG - 16.05.2012
You have to parse the file
before checking if the passwords match.
pawn Код:
if(udb_hash(inputtext) == pInfo[playerid][pass])
{
INI_ParseFile(Path(playerid),"loaduser_%s",.bExtra = true, .extra = playerid);
GivePlayerMoney(playerid,pInfo[playerid][money]);
SetPlayerScore(playerid,pInfo[playerid][score]);
}
The code is comparing the dialog text to pInfo[playerid][pass] when you haven't even loaded it yet. So when it's not loaded the password equals zero, thus not being able to log you in.
Re: I can't login -
ViniBorn - 16.05.2012
pass are an integer?
Re: I can't login -
ReneG - 16.05.2012
Quote:
Originally Posted by Viniborn
pass are an integer?
|
Yea, udb_hash specifically returns an integer. Strange, I know.
pawn Код:
/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Re: I can't login -
newbienoob - 16.05.2012
Quote:
Originally Posted by VincentDunn
You have to parse the file before checking if the passwords match.
pawn Код:
if(udb_hash(inputtext) == pInfo[playerid][pass]) { INI_ParseFile(Path(playerid),"loaduser_%s",.bExtra = true, .extra = playerid); GivePlayerMoney(playerid,pInfo[playerid][money]); SetPlayerScore(playerid,pInfo[playerid][score]); }
The code is comparing the dialog text to pInfo[playerid][pass] when you haven't even loaded it yet. So when it's not loaded the password equals zero, thus not being able to log you in.
|
How??
Re: I can't login -
ReneG - 16.05.2012
Under OnPlayerConnect...
Check if the userfile exists and then parse it with INI_Parsefile.
This tutorial by Kush is where I learned.
https://sampforum.blast.hk/showthread.php?tid=273088
Re: I can't login -
newbienoob - 16.05.2012
Yea I follow that tutorial, but still not working.
Under OnPlayerConnect
pawn Код:
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid),"loaduser_%s",.bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","The name is registered. Enter your password to login to your account.","Login","Quit");
}
Re: I can't login -
JaKe Elite - 16.05.2012
Try Parsing it with INI_ParseFile
before doing this
pawn Код:
if(udb_hash(inputtext) == pInfo[playerid][pass])
Re: I can't login -
ReneG - 16.05.2012
Quote:
Originally Posted by newbienoob
Yea I follow that tutorial, but still not working.
Under OnPlayerConnect
pawn Код:
if(fexist(Path(playerid))) { INI_ParseFile(Path(playerid),"loaduser_%s",.bExtra = true, .extra = playerid); ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","The name is registered. Enter your password to login to your account.","Login","Quit"); }
|
I think there is a bug with INI_ParseFile in 0.3e. I tried making a register script, but y_ini hadn't been working on the latest RC's.
EDIT:Try debugging
pawn Код:
INI_ParseFile(Path(playerid),"loaduser_%s",.bExtra = true, .extra = playerid);
// extra code here
printf("[debug] Password: %d", pInfo[playerid][pass]); // print the password to see if it was parsed correctly.
Add that print line, and go try to login. If you look at your server console afterwards and just see
Then there is either a flaw in your code, or y_ini.
Re: I can't login -
newbienoob - 16.05.2012
[debug] Password: 0
(From my server console)
Re: I can't login -
ReneG - 16.05.2012
I suggest consulting ****** with this. Did not work for me either, and I am pretty much 100% sure there is no flaw in the test code.
Re: I can't login -
newbienoob - 16.05.2012
Ok
Re: I can't login -
Ballu Miaa - 17.05.2012
Damn same problem with
INI_Parsefile.