SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/02/2017, 03:00 PM   #1
Hunud
Huge Clucker
 
Join Date: Jun 2016
Posts: 460
Reputation: 8
Default OnDialogRespond Login

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 ?!

Code:
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;
Hunud is offline   Reply With Quote
Old 17/02/2017, 03:08 PM   #2
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,047
Reputation: 519
Default Re: OnDialogRespond Login

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 Code:
    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
__________________

SERVER.LVCNR.NET:7777
Threshold is offline   Reply With Quote
Old 17/02/2017, 03:26 PM   #3
Hunud
Huge Clucker
 
Join Date: Jun 2016
Posts: 460
Reputation: 8
Default Re: OnDialogRespond Login

Ok thanks but when i type wrong password login dialog dissapear it should be show
Hunud is offline   Reply With Quote
Old 17/02/2017, 03:32 PM   #4
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,047
Reputation: 519
Default Re: OnDialogRespond Login

Did you use the code I provided...?
__________________

SERVER.LVCNR.NET:7777
Threshold is offline   Reply With Quote
Old 17/02/2017, 03:34 PM   #5
Hunud
Huge Clucker
 
Join Date: Jun 2016
Posts: 460
Reputation: 8
Default Re: OnDialogRespond Login

Quote:
Originally Posted by Threshold View Post
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!
Hunud is offline   Reply With Quote
Old 17/02/2017, 03:53 PM   #6
Hunud
Huge Clucker
 
Join Date: Jun 2016
Posts: 460
Reputation: 8
Default Re: OnDialogRespond Login

Please! Sorry for DP
Hunud is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Register & Login system (verification code + return password + auto login [by ip]) benel1 Filterscripts 20 26/11/2014 09:05 PM
ondialogrespond bug? Super_Panda Scripting Help 3 26/10/2011 07:23 PM
When player login to the server[/register & /login] Taz86 Help Archive 5 20/06/2010 09:09 AM
how does i make auto login and login before spawn ? reddead15 Help Archive 7 03/05/2010 02:26 AM
Can Any One Convert this scripted cmd login to dialog login system cssbart Help Archive 0 07/03/2010 05:57 PM


All times are GMT. The time now is 02:01 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.