Login Tries - 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 (
/showthread.php?tid=318744)
Login Tries -
emokidx - 16.02.2012
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
Re: Login Tries -
Nonameman - 16.02.2012
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.
Re: Login Tries -
emokidx - 16.02.2012
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
Re: Login Tries -
Nonameman - 16.02.2012
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?
Re: Login Tries -
emokidx - 17.02.2012
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.
Re: Login Tries -
Nonameman - 17.02.2012
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