Need Help with login
#1

I want to do this: when someone enters incorrect password, It sends him the remaining attempts of logging in otherwise he will get kick, but I tried to do that and it keeps saying: Incorrect Password! 3 Attempts Of Logging Left Before Being Kicked. it keeps saying 3 attempts, why it's not decreasing? whats the problem in this:

pawn Код:
else
                {
                LoginWarns[playerid] ++;
                new warnmsg[128];
                if(LoginWarns[playerid] < MAX_LOGINS)
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                    format(warnmsg, sizeof(warnmsg), "Incorrect Password! %d Attempt(s) Of Logging Left Before Being Kicked!", MAX_LOGINS-LoginWarns[playerid]);
                    SendClientMessage(playerid, 0xFF0000AA, warnmsg);
                    return 1;
                }
                if(LoginWarns[playerid] == MAX_LOGINS)
                {
                    LoginKickWithMessage(playerid, 0xFF0000AA, "You Have Failed In Logging In, You Have Been Kicked.");
                    LoginWarns[playerid] = 0;
                    return 1;
                }
                }
            }
    }
Reply
#2

Try this.

Код:
if(LoginWarns[playerid] == 0)
{
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have     entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
   if(LoginWarns[playerid] == 5) // login attempts set as you want
   {
        SendClientMessage(playerid, 0xFF0000AA, "You have been kicked out of the server, failed logged in!");
        return Kick(playerid);
   }
   else
   {
      format(warnmsg, sizeof(warnmsg), "Incorrect Password! %d Attempt(s) Of Logging Left Before Being Kicked!",LoginWarns[playerid]);
      SendClientMessage(playerid, 0xFF0000AA, warnmsg);
   }
}
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
return 1;
Reply
#3

Doesn't work..
Reply
#4

show me your "DIALOG_LOGIN"
Reply
#5

pawn Код:
if(dialogid == DIALOG_LOGIN)
    {
            new LoginWarns[MAX_PLAYERS];
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new ip[16], Message3[128];
                GetPlayerIp(playerid, ip, sizeof(ip));
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
                    SetPlayerScore(playerid, LPinfo[playerid][Score]);
                    Info[playerid][Logged] = 1;
                    if(PlayerInfo[playerid][pAdmin] == 0 && Info[playerid][VIPLevel] == 0 && PlayerInfo[playerid][pMT] == 0)
                    {
                    format(Message3, sizeof(Message3), "You Have Logged In As A {00FFFB}Registered Player{FFF700}."), SendClientMessage(playerid, 0xFFF700FF, Message3);
                    }
                    if(PlayerInfo[playerid][pAdmin] > 0)
                    {
                       switch(PlayerInfo[playerid][pAdmin])
                       {
                       case 1: AdmRank = "Trial Moderator";
                       case 2: AdmRank = "Moderator";
                       case 3: AdmRank = "Master Moderator";
                       case 4: AdmRank = "Trial Administrator";
                       case 5: AdmRank = "Administrator";
                       case 6: AdmRank = "Master Administrator";
                       case 7: AdmRank = "Head Administrator";
                       case 8: AdmRank = "Trusted Administrator";
                       case 9: AdmRank = "Co-Owner";
                       case 10: AdmRank = "Owner";
                       }
                       if(Info[playerid][VIPLevel] > 0)
                       {
                           switch(Info[playerid][VIPLevel])
                           {
                           case 1: AccType = "Bronze";
                           case 2: AccType = "Silver";
                           case 3: AccType = "Gold";
                           }
                           if(PlayerInfo[playerid][pMT] > 0)
                           {
                           switch(PlayerInfo[playerid][pMT])
                           {
                           case 1: MTRank = "Management Junior";
                           case 2: MTRank = "Management Senior";
                           case 3: MTRank = "Community Manager";
                           case 4: MTRank = "Staff Director";
                           case 5: MTRank = "Head Of MT";
                           }
                           format(Message3, sizeof(Message3), "You Have Logged In As A(n) {00FFFB}%s Level %d{FFF700} With A {FF00EA}%s{FFF700} Account.", AdmRank, PlayerInfo[playerid][pAdmin], AccType), SendClientMessage(playerid, 0xFFF700FF, Message3);
                           format(Message3, sizeof(Message3), "And As A(n) {00FFFB}%s Level %d{FFF700}.", MTRank, PlayerInfo[playerid][pMT]), SendClientMessage(playerid, 0xFFF700FF, Message3);
                           VIPReward[playerid] = SetTimerEx("VIPMoney", 1380000, true, "d", playerid);
                           SendClientMessage(playerid, 0xFFF700FF, "You Will Be Given Some VIP Money While Living Whole Gameday.");
                           }
                           if(Info[playerid][VIPLevel] >= 1)
                           {
                           if(Info[playerid][Favouriteskin] < -1 || Info[playerid][Favouriteskin] > 299)
                           {
                             Autouseskin[playerid] = 1;
                           }
                           }
                           else
                           {
                           format(Message3, sizeof(Message3), "You Have Logged In As A(n) {00FFFB}%s Level %d{FFF700} With A {FF00EA}%s{FFF700} Account.", AdmRank, PlayerInfo[playerid][pAdmin], AccType), SendClientMessage(playerid, 0xFFF700FF, Message3);
                           OnDuty[playerid] = 0;
                           }
                       }
                       else
                       {
                           format(Message3, sizeof(Message3), "You Have Logged In As A(n) {00FFFB}%s Level %d{FFF700}.", AdmRank, PlayerInfo[playerid][pAdmin]), SendClientMessage(playerid, 0xFFF700FF, Message3);
                           OnDuty[playerid] = 0;
                       }
                    }
                    else if(Info[playerid][VIPLevel] > 0)
                    {
                       switch(Info[playerid][VIPLevel])
                       {
                       case 1: AccType = "Bronze";
                       case 2: AccType = "Silver";
                       case 3: AccType = "Gold";
                       }
                       format(Message3, sizeof(Message3), "You Have Logged In As A {FF00EA}%s{FFF700} Account.", AccType), SendClientMessage(playerid, 0xFFF700FF, Message3);
                       VIPReward[playerid] = SetTimerEx("VIPMoney", 1380000, true, "d", playerid);
                       SendClientMessage(playerid, 0xFFF700FF, "You Will Be Given Some VIP Money While Living Whole Gameday.");
                       if(Info[playerid][VIPLevel] >= 1)
                       {
                       if(Info[playerid][Favouriteskin] < -1 || Info[playerid][Favouriteskin] > 299)
                       {
                         Autouseskin[playerid] = 1;
                       }
                       }
                    }
                    if(Info[playerid][VIPLevel] == 3)
                    {
                    SetPlayerFightingStyle(playerid, fskillid[playerid]);
                    }
                    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                    PlayerAlreadyLoggedIn[playerid] = 1;
                    PlayerAlreadyRegisteredIn[playerid] = 1;
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, LPinfo[playerid][Score]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    UserTimer[playerid] = SetTimerEx("UserSaver", 120000, true, "d", playerid);
                    PlayerDays[playerid] = SetTimerEx("DaysAlive", 1380000, true, "d", playerid);
                    new INI:File = INI_Open(UserPath2(playerid));
                    INI_WriteString(File,"IP", ip);
                    INI_Close(File);
                }
                else
                {
                LoginWarns[playerid] +=1;
                new warnmsg[128];
                if(LoginWarns[playerid] < MAX_LOGINS)
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                    format(warnmsg, sizeof(warnmsg), "Incorrect Password! %d Attempt(s) Of Logging Left Before Being Kicked!", MAX_LOGINS-LoginWarns[playerid]);
                    SendClientMessage(playerid, 0xFF0000AA, warnmsg);
                    return 1;
                }
                if(LoginWarns[playerid] == MAX_LOGINS)
                {
                    LoginKickWithMessage(playerid, 0xFF0000AA, "You Have Failed In Logging In, You Have Been Kicked.");
                    LoginWarns[playerid] = 0;
                    return 1;
                }
                }
            }
    }
Reply
#6

Код:
LoginWarns[playerid]+=1:
should be like this
Код:
LoginWarns[playerid]++;
Reply
#7

Still doesn't work, keeps sending 3 attempts
Reply
#8

Here's a few questions for you:

Why do you keep an array of login warns for each player? Isn't a local variable enough?
Why do you keep creating a new array at every dialog response? (This is the cause of your problem.)

Quote:
Originally Posted by justice96
Посмотреть сообщение
Код:
LoginWarns[playerid]+=1:
should be like this
Код:
LoginWarns[playerid]++;
Both are correct.
Reply
#9

Make that variable global for the player i.e add that to pInfo or PlayerInfo enum
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)