Login script allows any password
#1

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();
    			
                }
            }
        }
Reply
#2

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;
Reply
#3

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;
}
Reply
#4

Nope i am still able to enter a wrong password
Reply
#5

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();
               
                }
            }
        }
Reply
#6

thats what i have got that doesnt stop it.
Reply
#7

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");
Reply
#8

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

@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?
Reply
#10

That still doesnt work and System64 im using SII =P
Reply
#11

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();
    }

Reply
#12

yes i am saving compiling and restarting the server before retesting
Reply
#13

that doesnt work either.
Reply
#14

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

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

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...
Reply
#17

i have already tried false and returning ShowPlayerDialog neither work
Reply
#18

And iggy that didnt work either ='(
Reply
#19

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.
Reply
#20

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


Forum Jump:


Users browsing this thread: 1 Guest(s)