Login Tries
#1

pawn Код:
case DIALOG_LOGIN:
        {
            if(!response) Kick(playerid);
            new iStr[128],Tries;
            switch(Tries)
            {
            case 3:
            { // 3 tries = kick
                GetPlayerName(playerid,pname,sizeof(pname));
                format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pname);
                SendClientMessageToAll(red,iStr);
                return Kick(playerid);
            }
            case 0:
            {
                if(!strlen(inputtext))
                {
                    Tries++;
                    format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",Tries);
                    return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login",iStr,"Login","Leave");
                   
                }
       
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    pLogged[playerid] = 1;
                    SendClientMessage(playerid,white,"You've successfully logged in.");
                    SetPlayerScore(playerid,PlayerInfo[playerid][pScore]); //Loading player score
                    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]); //Loading player money
                }
                else
                {
                    Tries++;
                    format(iStr,sizeof(iStr),"Incorrect password.(you will see your password now) Tries: %i/3",Tries);
                    return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"LOGIN",iStr,"Login","Leave");
                   
                }
            }
    }
when i enter wrong password the tries go to 1/3 but no further.
also if anything else is wrong please correct me
Reply
#2

This is because you create a new Tries variable when the response of the dialog happens.
I'd delete it and create a global Tries[MAX_PLAYERS] variable, so it will store the count of player tries, won't be cleared every times a player give bad password.
Reply
#3

ok thnx will test later
also can you help in changing the udb hash to whirlpool? i counldnt do it, it saved the pass as 0
Reply
#4

I don't really understand what you want me to do, change the udb_hash to WP_Hash in the database/txt file or change it in the .pwn file?
Reply
#5

pawn Код:
new buf1[128]; //global var
INI_WriteInt(iFile,"Pass", WP_Hash(buf1, 129, inputtext)); // on the register dialog

if(WP_Hash(buf1, 129, inputtext) == PlayerInfo[playerid][pPass]) //login dialog
it doesnt hash it, the password simply becomes 0, and you can login with any password.
Reply
#6

pawn Код:
new buffer[512]; // declare it with bigger size than 196
WP_Hash(buffer, sizeof(buffer), inputtext);
if (strcmp(buffer, pass, false) == 0) // compare them this way
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)