OnDialogRespond Login
#1

Hi i have problem

When player register his password got saved very well! But when player connect he got login screen dialog for login but he can type anything password he want he will be logged in! what problem ?!

Код:
if (dialogid ==  DIALOG_LOGIN)
    {
		if(!response)
  		{
    		SCM(playerid, COLOR_WHITE, "SERVER: You have been kicked out of the server because you failed to respond.");
		    Kick(playerid);
    	}

		new hashpass[129];
		WP_Hash(hashpass,sizeof(hashpass),inputtext);
		if(!strcmp(hashpass, pInfo[playerid][e_USER_PASSWORD], false))
		{
            SetPVarInt(playerid, "gLogged", 1);
		    SCM(playerid, COLOR_WHITE, "SERVER: You have successfully logged into your account.");
			INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
			SetPlayerScore(playerid, pInfo[playerid][e_USER_SCORES]);
			GivePlayerMoney(playerid, pInfo[playerid][e_USER_MONEY]);
		}
	}
	else
	{
		if(GetPVarInt(playerid, "FailedLoginAttempt") == 0)
		{
			SetPVarInt(playerid, "FailedLoginAttempt", 1);
			SCM(playerid, COLOR_RED, "SERVER: The password you have entered is incorrect, please try again (1/3 attempts used).");
		}
		else if(GetPVarInt(playerid, "FailedLoginAttempt") == 1)
		{
			SetPVarInt(playerid, "FailedLoginAttempt", 2);
 			SCM(playerid, COLOR_RED, "SERVER: The password you have entered is incorrect, please try again (2/3 attempts used).");
   		}
		else if(GetPVarInt(playerid, "FailedLoginAttempt") == 2)
		{
			SetPVarInt(playerid, "FailedLoginAttempt", 3);
			SCM(playerid, COLOR_RED, "SERVER: The password you have entered is incorrect, please try again (3/3 attempts used).");
		}
		else if(GetPVarInt(playerid, "FailedLoginAttempt") == 3)
		{
			DeletePVar(playerid, "FailedLoginAttempt");
			SCM(playerid, COLOR_RED, "SERVER: You have used up all your login attempts, and hence got kicked.");
			Kick(playerid);
		}
			new L_DIALOG[380];
 			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login:", L_DIALOG, "Login", "");
			return 1;
  		}
  		return 1;
Reply
#2

Your password is not being loaded correctly. Meaning 'pInfo[playerid][e_USER_PASSWORD]' is empty.

Strcmp returns 0 if either of the two strings being compared are empty/null.

EDIT: And please learn to indent your code... otherwise you will end up making simple but stupid mistakes.
PHP код:
    if(dialogid ==  DIALOG_LOGIN)
    {
        if(!
response)
        {
            
SCM(playeridCOLOR_WHITE"SERVER: You have been kicked out of the server because you failed to respond.");
            
Kick(playerid);
            return 
1;
        }
        new 
hashpass[129];
        
WP_Hash(hashpasssizeof(hashpass), inputtext);
        if(!
strcmp(hashpasspInfo[playerid][e_USER_PASSWORD], false))
        {
            
SetPVarInt(playerid"gLogged"1);
            
SCM(playeridCOLOR_WHITE"SERVER: You have successfully logged into your account.");
            
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra true, .extra playerid);
            
SetPlayerScore(playeridpInfo[playerid][e_USER_SCORES]);
            
GivePlayerMoney(playeridpInfo[playerid][e_USER_MONEY]);
        }
        else
        {
            new 
loginint GetPVarInt(playerid"FailedLoginAttempt");
            if(
loginint >= 3)
            {
                
DeletePVar(playerid"FailedLoginAttempt");
                
SCM(playeridCOLOR_RED"SERVER: You have used up all your login attempts, and hence got kicked.");
                
Kick(playerid);
            }
            else
            {
                new 
fstr[91], L_DIALOG[380];
                
format(fstrsizeof(fstr), "SERVER: The password you have entered is incorrect, please try again (%d/3 attempts used)."loginint 1);
                
SCM(playeridCOLOR_REDfstr);
                
SetPVarInt(playerid"FailedLoginAttempt"loginint 1);
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD,"Login:"L_DIALOG"Login""");
            }
        }
        return 
1
Reply
#3

Ok thanks but when i type wrong password login dialog dissapear it should be show
Reply
#4

Did you use the code I provided...?
Reply
#5

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Did you use the code I provided...?
Yes i did! But when i first time enter wrong password dialog dissapear, but it should be still there unit i fail with 3/3 login attempts!
Reply
#6

Please! Sorry for DP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)