Password problem
#1

Players can press enter and be logged in without typing in a password.
How can I fix this?

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{  
    if(dialogid == 1)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(strcmp(inputtext,pInfo[playerid][Pass]) == 0)
            {
                INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
                SetPlayerFightingStyle(playerid,pInfo[playerid][Style]);
                SpawnPlayer(playerid);
               
                new str[10];
                format(str,sizeof(str),"$%i",pInfo[playerid][Cash]);
                PlayerTextDrawShow(playerid,Info[playerid]);
                PlayerTextDrawSetString(playerid,Info[playerid],str);
            }
            else
            {
                ShowPlayerDialog(playerid,1,3,"Login","{FF6347}Incorrect password!\n{A9C4E4}Type in your password to login","Login","Cancel");
                return 1;
            }
        }
    }
    return 1;
}
Reply
#2

INI_ParseFile(Path(playerid),"loadaccount_%s",.bEx tra = true, .extra = playerid);
Reply
#3

If he doesn't type anything you can use this:
pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,1,3,"Login","{FF6347}Incorrect password!\n{A9C4E4}Type in your password to login","Login","Cancel");
Post that ^ under:
pawn Код:
if(strcmp(inputtext,pInfo[playerid][Pass]) == 0)
Reply
#4

Strcmp returns 0 (false) if the strings match. Source: https://sampwiki.blast.hk/wiki/Strcmp

Therefore, this:

pawn Код:
if(strcmp(inputtext,pInfo[playerid][Pass]) == 0)
Should become:

pawn Код:
if(!strcmp(inputtext,pInfo[playerid][Pass], false))
Reply
#5

@OP saving passwords in clear text is a big no no
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)