SA-MP Forums Archive
Scripting 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: Scripting Help (/showthread.php?tid=542120)



Scripting Help - TheRandomManUK - 17.10.2014

Please can you help me so i cn make it so you have to enter your password correctly in 3 attempts then it kicks you, but at the minute if you enter the wrong pass it kicks you






case LOGIN_MENU:
{
new f[40], string[150];
format(f, sizeof(f), USER_FILE, GetName(playerid));
if(!strlen(inputtext)) return SendClientMessage(playerid, RED, "You MUST provide a password.") && Kick(playerid);
else if(!response) return SendClientMessage(playerid, RED, "You MUST login before you can spawn.") && Kick(playerid);
{
new buf[129];
WP_Hash(buf, sizeof (buf), inputtext);
if(strcmp(buf, PlayerInfo[playerid][pPass], false) != 0)
{
SendClientMessage(playerid, RED, "Incorrect password.");
format(string, sizeof(string), "%s [%d] has been kicked from CCNR - Reason: Incorrect password", GetName(playerid), playerid);
SendClientMessage(playerid, RED, string);
Kick(playerid);
return 1;
}
else
{


Re: Scripting Help - TheRandomManUK - 17.10.2014

Can Someone Help me Please?


Re: Scripting Help - AnnaSB - 17.10.2014

At the top of your script add:
pawn Код:
new LoginAttempts[MAX_PLAYERS];
Inside OnPlayerConnect in first lines, add this:
pawn Код:
LoginAttempts[playerid] = 0;
Now the code you used:
pawn Код:
if(strcmp(buf, PlayerInfo[playerid][pPass], false) != 0)
{
    SendClientMessage(playerid, RED, "Incorrect password.");
    if(LoginAttempts[playerid] == 3)
    {
        format(string, sizeof(string), "%s [%d] has been kicked from CCNR - Reason: Incorrect password", GetName(playerid), playerid);
        SendClientMessage(playerid, RED, string);
        Kick(playerid);
    }
    else
    {
        LoginAttempts[playerid]++;
        // Create the same dialog box here again.
    }
    return 1;
}
Also use [pawn] tags for codes, for easier reading.

Hope I helped ^^