Another Login Problem! -
Hunud - 10.04.2017
Hi,
After i fixed my previous problem now i have this! Read carefully, When i have to register my password got saved for sure all fine example (mypassword123), but when i came to login and type example (123) which isn't not my password i got message "The password you entered is incorrect" BUT I am logged in and i can counitnue with gaming
I'm really confused right now! All help with be appricated +REP if helped!
Код:
if( response )
{
new string1[30], hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass, PlayerInfo[playerid][PASSWORD], false))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][MONEY]);
SetPVarInt(playerid, "gLogged", 1);
SendClientMessage(playerid, -1, "SERVER: You have successfully logged!");
}
else
{
if(GetPVarInt(playerid, "FailedLoginAttempt") == 0)
{
SetPVarInt(playerid, "FailedLoginAttempt", 1);
SendClientMessage(playerid, -1, "SERVER: The password you have entered is incorrect (1/3 attempts used).");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 1)
{
SetPVarInt(playerid, "FailedLoginAttempt", 2);
SendClientMessage(playerid, -1, "SERVER: The password you have entered is incorrect (2/3 attempts used).");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 2)
{
SetPVarInt(playerid, "FailedLoginAttempt", 3);
SendClientMessage(playerid, -1, "SERVER: The password you have entered is incorrect (3/3 attempts used).");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 3)
{
DeletePVar(playerid, "FailedLoginAttempt");
SendClientMessage(playerid, -1, "SERVER: You have used up all your login attempts, and hence got kicked.");
Kick(playerid);
}
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", string1, "Login", "Cancel");
}
}
}
}
return 1;
}
Re: Another Login Problem! -
Kane - 10.04.2017
Not sure but this could work:
Код:
if(!strcmp(hashpass, PlayerInfo[playerid][PASSWORD], false))
Remove the !
Re: Another Login Problem! -
Hunud - 10.04.2017
Same problem, it's should pass though all failedloginattempt if i type password wrong and kick me at the end! and if i type a correct password it should be ok
Re: Another Login Problem! -
khRamin78 - 10.04.2017
EDITED: NVM its wrong
Re: Another Login Problem! -
Hunud - 10.04.2017
When i first time enter wrong password "Server Closed Connection" without any wrong password message
Re: Another Login Problem! -
khRamin78 - 10.04.2017
and i forget to tell at last part using Kick(playerid); will kick him instatly and he wont see that ClientMessage
if you wanted him to see that you have to use timers
like this:
PHP код:
forward KickPlayer(playerid);
if(GetPVarInt(playerid, "FailedLoginAttempt") == 3)
{
DeletePVar(playerid, "FailedLoginAttempt");
SendClientMessage(playerid, -1, "SERVER: You have used up all your login attempts, and hence got kicked.");
SetTimerEx("KickPlayer",1000,false,"i",playerid);
}
public KickPlayer(playerid)
{
Kick(playerid);
return 1;
}
Re: Another Login Problem! -
Hunud - 10.04.2017
Thanks for trying to help me out but now! When i type wrong password i got message "The password you have entered is incorrect (1/3 attempts used)" but i am in class selection and i can spawn myself, there is no dialog to return back to login xD
Re: Another Login Problem! -
coool - 10.04.2017
what are you doing you have to use else if. Your code means, if a variable is 0 increase it by 1, again check is it one and then again increase it then its 2 and so on.
EDIT: Big mistake the return will work.
Re: Another Login Problem! -
Hunud - 10.04.2017
I did it like this and it's only show first password is incorrect and there is no dialog return for other and i can spawn myself!
Код:
if(GetPVarInt(playerid, "FailedLoginAttempt") == 0)
{
SetPVarInt(playerid, "FailedLoginAttempt", 1);
SendClientMessage(playerid, -1, "SERVER: The password you have entered is incorrect (1/3 attempts used).");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", string1, "Login", "Cancel");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 1)
{
SetPVarInt(playerid, "FailedLoginAttempt", 2);
SendClientMessage(playerid, -1, "SERVER: The password you have entered is incorrect (2/3 attempts used).");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", string1, "Login", "Cancel");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 2)
{
SetPVarInt(playerid, "FailedLoginAttempt", 3);
SendClientMessage(playerid, -1, "SERVER: The password you have entered is incorrect (3/3 attempts used).");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", string1, "Login", "Cancel");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 3)
{
DeletePVar(playerid, "FailedLoginAttempt");
SendClientMessage(playerid, -1, "SERVER: You have used up all your login attempts, and hence got kicked.");
Kick(playerid);
}
Re: Another Login Problem! -
khRamin78 - 10.04.2017
im to bussy i cant make you sosry