Login Tries Help
#1

Hello everyone
I have to give player 3 login tries but this code is working for only 1 try after 1 try if you enter wrong password then the player will get kicked.
Код:
                                if ((GetPVarInt(playerid, "LoginTries") + 3) <= 3)
   				{
					SetPVarInt(playerid, "LoginTries", GetPVarInt(playerid, "LoginTries") + 1);
					SendClientMessage(playerid, -1, "Incorrect password. Please try again (you have 3 tries left).");
					DisplayDialogForPlayer(playerid, 1);
				}
				else if ((GetPVarInt(playerid, "LoginTries") + 2) <= 2)
   				{
					SetPVarInt(playerid, "LoginTries", GetPVarInt(playerid, "LoginTries") + 1);
					SendClientMessage(playerid, -1, "Incorrect password. Please try again (you have 2 tries left).");
					DisplayDialogForPlayer(playerid, 1);
				}
				else if ((GetPVarInt(playerid, "LoginTries") + 1) <= 1)
   				{
					SetPVarInt(playerid, "LoginTries", GetPVarInt(playerid, "LoginTries") + 1);
					SendClientMessage(playerid, -1, "Incorrect password. Please try again (you have 1 tries left).");
					DisplayDialogForPlayer(playerid, 1);
				}
				else
				{
					SendClientMessage(playerid, LIGHTRED, "You have entered an incorrect password too many times. You have been kicked.");
		    	   	Kick(playerid);
				}
		  		return 1;
Reply
#2

Here's my version.

pawn Код:
new LWarns[MAX_PLAYERS]; //Above all code, short for "LoginWarns"


/*blablablablablablablablblblbl OnDialogResponse blablblablblablbalbalabllb*/

case DIALOG_LOGIN:
        {
            if ( !response ) Kick ( playerid );
            else
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {

                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    PlayerInfo[playerid][pLoggedIn] = 1;
                   
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
                   
                   
                                //stuff here
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","{FFFFFF}You have entered an {FF9933}incorrect {FFFFFF}password.\nType your password below to login.","Login","Quit");
                    LWarns{ playerid }++; //Increases
                    if(LWarns{ playerid } == 1) //If he has failed 1x, he gets vvvv message
                    {
                        SendClientMessage(playerid, COLOR_ORANGE, "* Two more invalid logins and you will be kicked!");
                    }
                    if(LWarns{ playerid } == 2) //If he has failed 2x, he gets vvvvv message
                    {
                        SendClientMessage(playerid, COLOR_RED, "* One more invalid login and you will be kicked!");
                    }
                    if(LWarns{ playerid } == 3) //If he has failed 3x, he gets kicked.
                    {
                        new string[74], pName[MAX_PLAYERS];
                        GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
                        SendClientMessage(playerid, COLOR_RED, "* You've been kicked for multiple failed logins!");
                        SetTimerEx("KickTimer", 150, false, "i", playerid);
                    }
                }
            }
        }


/*blablablblablblablblbl Kicktimer bblalablablblbl*/

forward KickTimer(playerid);
public KickTimer(playerid)
{
    Kick(playerid);
    return 1;
}
;d
Reply
#3

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Here's my version.

pawn Код:
new LWarns[MAX_PLAYERS]; //Above all code, short for "LoginWarns"


/*blablablablablablablablblblbl OnDialogResponse blablblablblablbalbalabllb*/

case DIALOG_LOGIN:
        {
            if ( !response ) Kick ( playerid );
            else
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {

                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    PlayerInfo[playerid][pLoggedIn] = 1;
                   
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
                   
                   
                                //stuff here
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","{FFFFFF}You have entered an {FF9933}incorrect {FFFFFF}password.\nType your password below to login.","Login","Quit");
                    LWarns{ playerid }++; //Increases
                    if(LWarns{ playerid } == 1) //If he has failed 1x, he gets vvvv message
                    {
                        SendClientMessage(playerid, COLOR_ORANGE, "* Two more invalid logins and you will be kicked!");
                    }
                    if(LWarns{ playerid } == 2) //If he has failed 2x, he gets vvvvv message
                    {
                        SendClientMessage(playerid, COLOR_RED, "* One more invalid login and you will be kicked!");
                    }
                    if(LWarns{ playerid } == 3) //If he has failed 3x, he gets kicked.
                    {
                        new string[74], pName[MAX_PLAYERS];
                        GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
                        SendClientMessage(playerid, COLOR_RED, "* You've been kicked for multiple failed logins!");
                        SetTimerEx("KickTimer", 150, false, "i", playerid);
                    }
                }
            }
        }


/*blablablblablblablblbl Kicktimer bblalablablblbl*/

forward KickTimer(playerid);
public KickTimer(playerid)
{
    Kick(playerid);
    return 1;
}
;d
Can you please edit my code
Reply
#4

Bump
Reply
#5

pawn Код:
SetPVarInt(playerid,"LoginTries", GetPVarInt(playerid, "LoginTries")+1);
if(GetPVarInt(playerid,"LoginTries") != 4)
{
    new message[64];
    DisplayDialogForPlayer(playerid, 1);
    format(message, sizeof(message),"Incorrect password. Please try again. (%d/4 tries).",GetPVarInt(playerid,"LoginTries"));
    SendClientMessage(playerid, -1, message);
}
else
{
    SendClientMessage(playerid, LIGHTRED, "You have entered an incorrect password too many times. You have been kicked."),
    Kick(playerid);
}
return 1;
And don't be impatient, don't bump each hour. Minimum time to bump is 24 hours.
Reply
#6

Quote:
Originally Posted by CuervO
Посмотреть сообщение
pawn Код:
SetPVarInt(playerid,"LoginTries", GetPVarInt(playerid, "LoginTries")+1);
if(GetPVarInt(playerid,"LoginTries") != 4)
{
    new message[64];
    DisplayDialogForPlayer(playerid, 1);
    format(message, sizeof(message),"Incorrect password. Please try again. (%d/4 tries).",GetPVarInt(playerid,"LoginTries"));
    SendClientMessage(playerid, -1, message);
}
else
{
    SendClientMessage(playerid, LIGHTRED, "You have entered an incorrect password too many times. You have been kicked."),
    Kick(playerid);
}
return 1;
And don't be impatient, don't bump each hour. Minimum time to bump is 24 hours.
thank you sir it works and sorry I didn't know the Bump minimum time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)