SA-MP Forums Archive
OnDialogRespond Login - 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)
+--- Thread: OnDialogRespond Login (/showthread.php?tid=628952)



OnDialogRespond Login - Hunud - 17.02.2017

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;



Re: OnDialogRespond Login - Threshold - 17.02.2017

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



Re: OnDialogRespond Login - Hunud - 17.02.2017

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


Re: OnDialogRespond Login - Threshold - 17.02.2017

Did you use the code I provided...?


Re: OnDialogRespond Login - Hunud - 17.02.2017

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!


Re: OnDialogRespond Login - Hunud - 17.02.2017

Please! Sorry for DP