SA-MP Forums Archive
Login script allows any password - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Login script allows any password (/showthread.php?tid=269840)

Pages: 1 2


Login script allows any password - slymatt - 18.07.2011

When ive registered the server places the password in the user file but when i come to actually logging in say my password is password123 and i enter asdfjasdfjkf it still accepts it. Heres the code:

Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][Pass],"Pass",20);

                if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                }
                new Float:x, Float:y, Float:z, Float:a;
                SetPlayerScore(playerid, INI_ReadInt("Score"));
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid, INI_ReadInt("Cash"));
				PlayerInfo[playerid][Admin] = INI_ReadInt("Admin");
				PlayerInfo[playerid][Skin] = INI_ReadInt("Skin");
				x = INI_ReadFloat("Savedpositionx");
				y = INI_ReadFloat("Savedpositiony");
				z = INI_ReadFloat("Savedpositionz");
				a = INI_ReadFloat("Savedpositiona");
				SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], x, y, z, a, 0, 0, 0, 0, 0, 0);
				SetPlayerInterior(playerid, 3);
				SpawnPlayer(playerid);
				INI_Close();
    			
                }
            }
        }



Re: Login script allows any password - Bakr - 18.07.2011

You do not stop the code from executing even if the player gets the incorrect password. You can stop the code by adding a return 1; after this line, like so:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
return 1;



Re: Login script allows any password - _Aleksandar - 18.07.2011

try this..

Код:
if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) 
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
return false;
}



Re: Login script allows any password - slymatt - 18.07.2011

Nope i am still able to enter a wrong password


Re: Login script allows any password - Bakr - 18.07.2011

Make sure to replace returns after both times you show a dialog in that section of code:
pawn Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                return 1;
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][Pass],"Pass",20);

                if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                return 1;
                }
                new Float:x, Float:y, Float:z, Float:a;
                SetPlayerScore(playerid, INI_ReadInt("Score"));
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid, INI_ReadInt("Cash"));
                PlayerInfo[playerid][Admin] = INI_ReadInt("Admin");
                PlayerInfo[playerid][Skin] = INI_ReadInt("Skin");
                x = INI_ReadFloat("Savedpositionx");
                y = INI_ReadFloat("Savedpositiony");
                z = INI_ReadFloat("Savedpositionz");
                a = INI_ReadFloat("Savedpositiona");
                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], x, y, z, a, 0, 0, 0, 0, 0, 0);
                SetPlayerInterior(playerid, 3);
                SpawnPlayer(playerid);
                INI_Close();
               
                }
            }
        }



Re: Login script allows any password - slymatt - 18.07.2011

thats what i have got that doesnt stop it.


Re: Login script allows any password - FireCat - 18.07.2011

pawn Код:
if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");



Re: Login script allows any password - System64 - 18.07.2011

man I have the same problem, somebody should make a tutorial using y_ini and whirlpool :/


Re: Login script allows any password - Bakr - 18.07.2011

@FireCat: Your code is doing nothing different than what mine and the other above poster's does.

@slymatt: Then I'm not convinced. Are you sure you're showing the player that dialog when they connect to insert their password? Are you saving, compiling and restarting the server before re-testing the script?


Re: Login script allows any password - slymatt - 18.07.2011

That still doesnt work and System64 im using SII =P


Re: Login script allows any password - MoroDan - 18.07.2011

Quote:
Originally Posted by slymatt
Посмотреть сообщение
When ive registered the server places the password in the user file but when i come to actually logging in say my password is password123 and i enter asdfjasdfjkf it still accepts it. Heres the code:

Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][Pass],"Pass",20);

                if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                }
                new Float:x, Float:y, Float:z, Float:a;
                SetPlayerScore(playerid, INI_ReadInt("Score"));
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid, INI_ReadInt("Cash"));
				PlayerInfo[playerid][Admin] = INI_ReadInt("Admin");
				PlayerInfo[playerid][Skin] = INI_ReadInt("Skin");
				x = INI_ReadFloat("Savedpositionx");
				y = INI_ReadFloat("Savedpositiony");
				z = INI_ReadFloat("Savedpositionz");
				a = INI_ReadFloat("Savedpositiona");
				SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], x, y, z, a, 0, 0, 0, 0, 0, 0);
				SetPlayerInterior(playerid, 3);
				SpawnPlayer(playerid);
				INI_Close();
    			
                }
            }
        }
Try this:
PHP код:
case DIALOG_LOGIN:
{
    if(!
response) return Kick playerid );
    if(!
strlen(inputtext))
    {
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
        return 
1;
    }
    if(
INI_Open(getINI(playerid)))
    {
        
INI_ReadString(PlayerInfo[playerid][Pass],"Pass",20);
        if(
strcmp(inputtext,PlayerInfo[playerid][Pass],false))
        {
            
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
            return 
1;
        }
        new 
Float:xFloat:yFloat:zFloat:a;
        
SetPlayerScore(playeridINI_ReadInt("Score"));
        
ResetPlayerMoney(playerid);
        
GivePlayerMoney(playeridINI_ReadInt("Cash"));
        
PlayerInfo[playerid][Admin] = INI_ReadInt("Admin");
        
PlayerInfo[playerid][Skin] = INI_ReadInt("Skin");
        
INI_ReadFloat("Savedpositionx");
        
INI_ReadFloat("Savedpositiony");
        
INI_ReadFloat("Savedpositionz");
        
INI_ReadFloat("Savedpositiona");
        
SetSpawnInfo(playerid0PlayerInfo[playerid][Skin], xyza000000);
        
SetPlayerInterior(playerid3);
        
SpawnPlayer(playerid);
        
INI_Close();
    }




Re: Login script allows any password - slymatt - 18.07.2011

yes i am saving compiling and restarting the server before retesting


Re: Login script allows any password - slymatt - 18.07.2011

that doesnt work either.


Re: Login script allows any password - slymatt - 18.07.2011

is there a way of doing something like
Код:
if(PlayerInfo[playerid][Pass] == inputtext)
I just cant work it out.


Re: Login script allows any password - iggy1 - 18.07.2011

This will check if the password stored in the playerinfo var matches the string that inputtext holds.
pawn Код:
if(!strcmp(PlayerInfo[playerid][Pass], inputtext))



Re: Login script allows any password - _Aleksandar - 18.07.2011

OMG you must return false; not true...
here:
Код:
if(!strlen(inputtext)) 
    { 
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit"); 
        return 1; 
    }
and here:
Код:
 if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) 
        { 
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit"); 
            return 1; 
        }
also you can return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit"); without returning false...


Re: Login script allows any password - slymatt - 18.07.2011

i have already tried false and returning ShowPlayerDialog neither work


Re: Login script allows any password - slymatt - 18.07.2011

And iggy that didnt work either ='(


Re: Login script allows any password - Jofi - 18.07.2011

I had once something like this when password encryption didn't work correctly.
When i opened that account file "password= " part was empty and script allowed to use any password at login..

Soo.. check account file to make sure there is password saved.

E: Oh sorry didn't read whole post.


Re: Login script allows any password - slymatt - 18.07.2011

dang this is a bad things ='( i cant work it out at all haha thanks for trying though jofi