SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/06/2016, 07:12 PM   #1
RedSmokeR
Little Clucker
 
Join Date: May 2016
Posts: 27
Reputation: 0
Post Login/register system help.

Hi guyz,i have made login/register system but i want that if player writes incorrect password 3 times,he will be kicked automatically for incorrect passwords attempts.
RedSmokeR is offline   Reply With Quote
Old 08/06/2016, 07:53 PM   #2
N0FeaR
High-roller
 
N0FeaR's Avatar
 
Join Date: Nov 2011
Location: Sweden
Posts: 2,304
Reputation: 167
Default Re: Login/register system help.

Here is an exemple

PHP Code:
case DIALOG_LOGIN:
        {
            
//if(!response) return Kick(playerid);
            //if(response)
            
switch(response)
            {
                case 
0Kick(playerid);
                case 
1:
                {
                    if(
udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                    {
                        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                        
PlayerLogged[playerid] = true;
                        new 
playername[24];
                        
GetPlayerName(playeridplayernamesizeof(playername));
                        
PlayerInfo[playerid][pName] = playername;
                        
TogglePlayerSpectating(playeridfalse);
                        new 
INI:File INI_Open(UserPath(playerid));
                        
INI_SetTag(File,"Account Info");
                        
INI_WriteString(File"Name"PlayerInfo[playerid][pName]);
                        
INI_Close(File);
                        
ShowPlayerDialog(playeridDIALOG_SUCCESS_2DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                           if(
PlayerInfo[playerid][pBan] == 1)
                        {
                            
SendClientMessage(playeridCOLOR_LIGHTRED"You have been banned for logging into a banned account.");
                            
SetTimerEx("UnsetBan"5000"i"playerid);
                         }
                    }
                    else
                    {
                        if(
GetPVarInt(playerid"WrongPassword") >= 5)
                         {
                              
SendClientMessage(playerid,COLOR_LIGHTRED,"You have been banned for entering the wrong password in five times.");
                            
//BanExtra(playerid,"Wrong Password","Anna-Bot");
                             //format(string, sizeof(string), "%s was banned for Wrong Password by Anna-Bot System.", PlayerName(playerid));
                              //BanLog(string);
                        
}
                           else
                        {
                            new 
string[100];
                            
SetPVarInt(playerid"WrongPassword"1+GetPVarInt(playerid"WrongPassword"));
                             new 
amount GetPVarInt(playerid"WrongPassword");
                              
format(stringsizeof(string),"Invalid password (%d tries left)."amount);
                               
SendClientMessage(playerid,COLOR_LIGHTRED,string);
                            
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Server Account","An existing account is using your playername, please login to the account.\nIf you can't support this dialog select the (next) option.","Login""Next");
                            
//ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\n""Type your password below to login.","Login","Quit");
                            //WrongPassword(playerid);
                            
}
                    }
                    return 
1;
                 }
             }
        }
    } 
__________________
Here is my discord server https://discord.gg/ucVpDkJ
N0FeaR is offline   Reply With Quote
Old 08/06/2016, 07:56 PM   #3
Lucky13
Huge Clucker
 
Lucky13's Avatar
 
Join Date: Dec 2015
Location: Romania
Posts: 276
Reputation: 70
Default Re: Login/register system help.

On top of your script:
Code:
 new gLoginAttempts[MAX_PLAYERS];
OnPlayerConnect & OnPlayerDisconnect:

Code:
gLoginAttempts[playerid]=0;
Now put this code where you have the incorrect password:

Code:
gLoginAttempts[playerid]++;
if(gLoginAttempts[playerid] == 3) return Kick(playerid);
And when they login successfully:
Code:
gLoginAttempts[playerid]=0; // We reset them in case he managed to login from the 2nd attempt.
Lucky13 is offline   Reply With Quote
Old 08/06/2016, 07:56 PM   #4
Sime30
Huge Clucker
 
Join Date: Oct 2012
Location: Should I stay or should I go
Posts: 348
Reputation: 31
Default Re: Login/register system help.

- You create an int player-variable.
pawn Code:
new LoginAttempts[MAX_PLAYERS];
- You increase it's value everytime a player writes a wrong password.
pawn Code:
LoginAttempts[playerid]++;
- You check if the player wrote his password wrong for 3 times.
pawn Code:
if(LoginAttempts[playerid] == 3)

Also, reset this player-variable OnPlayerConnect
pawn Code:
LoginAttempts[playerid] = 0;

EDIT: Too many of you replied
Sime30 is offline   Reply With Quote
Old 08/06/2016, 08:45 PM   #5
RedSmokeR
Little Clucker
 
Join Date: May 2016
Posts: 27
Reputation: 0
Default Re: Login/register system help.

Ok guyz,i'ill try it.Thanks
RedSmokeR is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Register & Login system (verification code + return password + auto login [by ip]) benel1 Filterscripts 20 26/11/2014 09:05 PM
the best login/register system without admin system and show in dialog misho1 Help Archive 2 06/05/2011 12:24 AM
where can i download an admin system and an login and register system dendudes123 Help Archive 3 19/06/2010 06:13 PM


All times are GMT. The time now is 12:00 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.