PDA

View Full Version : Whats wrong with this one +rep


RicaNiel
28/04/2012, 01:55 PM
Guys what's wrong with this one
always show incorrect password while its correct i type it correctly
i need help

i use two experiments but still incorrect i wonder what part am i get wrong

ublic OnPlayerLogin(playerid,password[])
{
new string[128];
if(strcmp(pData[playerid][pPassword],password,true,0))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else
{
logattempts[playerid] += 1;
switch(logattempts[playerid])
{
case 1: string = "Three more Login Attempts";
case 2: string = "Two more Login Attempts";
case 3: string = "One more Login Attempts";
case 4:
{
SendClientMessage(playerid,C_WHITE,"You have been kicked because of ("CORANGE" Failure to Correct password ( 3x )"CWHITE" )");
Kick(playerid);
}
}
new ldialog[500];
format(ldialog,sizeof(ldialog),""CWHITE"Welcome back to RicaNiel Role-Play\n\nUser: "CORANGE"%s"CWHITE"\n\nPlease Enter your password to login\n\n [ "CRED"%s"CWHITE" ]",RemoveUnderScore(playerid),string);
SPD(playerid,D_LOGIN,PASSWORD,""CSERVER"RicaNiel Role-Play",ldialog,"Proceed","Cancel");
}
return 1;
}

and also if i use udb_hash
also incorrect password i typed it correctly

*new string[128];
if(udb_hash(inputtext) == pData[playerid][pPassword])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else
{
logattempts[playerid] += 1;
switch(logattempts[playerid])
{
case 1: string = "Three more Login Attempts";
case 2: string = "Two more Login Attempts";
case 3: string = "One more Login Attempts";
case 4:
{
SendClientMessage(playerid,C_WHITE,"You have been kicked because of ("CORANGE" Failure to Correct password ( 3x )"CWHITE" )");
Kick(playerid);
}
}
new ldialog[500];
format(ldialog,sizeof(ldialog),""CWHITE"Welcome back to RicaNiel Role-Play\n\nUser: "CORANGE"%s"CWHITE"\n\nPlease Enter your password to login\n\n [ "CRED"%s"CWHITE" ]",RemoveUnderScore(playerid),string);
SPD(playerid,D_LOGIN,PASSWORD,""CSERVER"RicaNiel Role-Play",ldialog,"Proceed","Cancel");
}

IstuntmanI
28/04/2012, 01:57 PM
From the first "experiment", change
if(strcmp(pData[playerid][pPassword],password,true,0))
with
if( !strcmp( pData[ playerid ][ pPassword ], udb_hash( password ) ) )

Niko_boy
28/04/2012, 01:59 PM
if you using Hash in register use it in login too same methods btw
anwyays i guess u use one
Try matching the hashed password with login input text hashedi.e. debugging
printf("%s",udb_hash(inputtext));
and match that one in user file

RicaNiel
28/04/2012, 02:07 PM
still same can you fix this one for me ? anyways here is my code

still show wrong password
-----------------------[ 1st experiment ]
public LoadUser_data(playerid,name[],value[])
{
INI_String("Password",pData[playerid][pPassword],100);
return 1;
}

public OnPlayerLogin(playerid,password[])
{
new string[128];
if(strcmp(pData[playerid][pPassword],password,true,0))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else
{
logattempts[playerid] += 1;
switch(logattempts[playerid])
{
case 1: string = "Three more Login Attempts";
case 2: string = "Two more Login Attempts";
case 3: string = "One more Login Attempts";
case 4:
{
SendClientMessage(playerid,C_WHITE,"You have been kicked because of ("CORANGE" Failure to Correct password ( 3x )"CWHITE" )");
Kick(playerid);
}
}
new ldialog[500];
format(ldialog,sizeof(ldialog),""CWHITE"Welcome back to RicaNiel Role-Play\n\nUser: "CORANGE"%s"CWHITE"\n\nPlease Enter your password to login\n\n [ "CRED"%s"CWHITE" ]",RemoveUnderScore(playerid),string);
SPD(playerid,D_LOGIN,PASSWORD,""CSERVER"RicaNiel Role-Play",ldialog,"Proceed","Cancel");
}
return 1;
}

public OnPlayerRegister(playerid,password[])
{
if(!strlen(password)) return SPD(playerid,D_REGISTER,INPUT,""CSERVER"RicaNiel Role-Play",""CWHITE"Welcome to RicaNiel Role-Play\nThis Account is not registerd or ("CRED" Unknown To our data base"CWHITE" )\nPlease Enter your password bellow to register\n\nPlease Put a password","Proceed","Cancel");
if(strlen(password) < 5 ) return SPD(playerid,D_REGISTER,INPUT,""CSERVER"RicaNiel Role-Play",""CWHITE"Welcome to RicaNiel Role-Play\nThis Account is not registerd or ("CRED" Unknown To our data base"CWHITE" )\nPlease Enter your password bellow to register\n\nPlease Enter at least 5 character of your password","Proceed","Cancel");
new INI:data = INI_Open(UserPath(playerid));
INI_SetTag(data,"RicaNiel");
INI_WriteString(data,"Password",password);
INI_Close(data);
return 1;
}


my 2nd Experiment his is with hash now


public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",pData[playerid][pPassword]);
return 1;
}

public OnPlayerLogin(playerid,password[])
{
new string[128];
if(udb_hash(password) == pData[playerid][pPassword])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else
{
logattempts[playerid] += 1;
switch(logattempts[playerid])
{
case 1: string = "Three more Login Attempts";
case 2: string = "Two more Login Attempts";
case 3: string = "One more Login Attempts";
case 4:
{
SendClientMessage(playerid,C_WHITE,"You have been kicked because of ("CORANGE" Failure to Correct password ( 3x )"CWHITE" )");
Kick(playerid);
}
}
new ldialog[500];
format(ldialog,sizeof(ldialog),""CWHITE"Welcome back to RicaNiel Role-Play\n\nUser: "CORANGE"%s"CWHITE"\n\nPlease Enter your password to login\n\n [ "CRED"%s"CWHITE" ]",RemoveUnderScore(playerid),string);
SPD(playerid,D_LOGIN,PASSWORD,""CSERVER"RicaNiel Role-Play",ldialog,"Proceed","Cancel");
}
return 1;
}

public OnPlayerRegister(playerid,password[])
{
if(!strlen(password)) return SPD(playerid,D_REGISTER,INPUT,""CSERVER"RicaNiel Role-Play",""CWHITE"Welcome to RicaNiel Role-Play\nThis Account is not registerd or ("CRED" Unknown To our data base"CWHITE" )\nPlease Enter your password bellow to register\n\nPlease Put a password","Proceed","Cancel");
if(strlen(password) < 5 ) return SPD(playerid,D_REGISTER,INPUT,""CSERVER"RicaNiel Role-Play",""CWHITE"Welcome to RicaNiel Role-Play\nThis Account is not registerd or ("CRED" Unknown To our data base"CWHITE" )\nPlease Enter your password bellow to register\n\nPlease Enter at least 5 character of your password","Proceed","Cancel");
new INI:data = INI_Open(UserPath(playerid));
INI_SetTag(data,"RicaNiel");
INI_WriteInt(data,"Password",udb_hash(password));
INI_Close(data);
return 1;
}

Niko_boy
28/04/2012, 02:23 PM
so the problem is most probable with hashing try using code without login attempt part i.e. else statement //-- part

RicaNiel
28/04/2012, 02:27 PM
so the problem is most probable with hashing try using code without login attempt part i.e. else statement //-- part

uhhmm still same always wrong password :( ??

RicaNiel
28/04/2012, 02:43 PM
anyone?

Niko_boy
28/04/2012, 02:43 PM
had u tried debug part i said ?

RicaNiel
28/04/2012, 02:49 PM
yes but nothing is working

RicaNiel
28/04/2012, 03:04 PM
i already debbugged it but still show error in loging in

ReneG
28/04/2012, 03:13 PM
You are not allowed to post ONE hour after the last post was made, now stomp bumping, and be patient. There is an edit button for a reason.


On topic, your code doesn't make any sense. You are parsing the user's file after he types the password? The player just logged on, so that variable is always zero. Parse the user file before they type in their password.

Niko_boy
28/04/2012, 04:08 PM
@RicaNiel so u debugged it hmm
LOL debug doesnt mean just prinitng had u matched the printed hased login inputted text i.e. password with the one in UserFile ?