Login Tries Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Login Tries Help (
/showthread.php?tid=493882)
Login Tries Help -
sonushan - 10.02.2014
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;
Re: Login Tries Help -
Kyance - 10.02.2014
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
Re: Login Tries Help -
sonushan - 10.02.2014
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
Re: Login Tries Help -
sonushan - 10.02.2014
Bump
Re: Login Tries Help -
CuervO - 10.02.2014
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.
Re: Login Tries Help -
sonushan - 10.02.2014
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.