Need login
#1

i wanna a login if you in the wrong password you get kicked how to make it 5?

Код:
// Process the login-dialog
Dialog_Login(playerid, response, inputtext[])
{
	switch (response) // Check which button was clicked
	{
	    case 1: // Player clicked "Login"
		{
			// Check if the player entered a password
			if (strlen(inputtext) > 0)
			{
				// Check if the entered password is the same as the password saved in the player's account
			    if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
				{
					APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
                    BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
					SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properly
				}
				else
				{
					SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
					Kick(playerid);
				}
			}
			else
			{
				SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
				Kick(playerid);
			}
		}
	    case 0: // Player clicked "Cancel"
		{
			// Show a message that the player must be logged in to play on this server
			SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
		    // Kick the player
			Kick(playerid);
		}
	}

	return 1;
}
Reply
#2

Try it:
PHP код:
#define MAX_FAIL_LOGINS 5
new FailLogin[MAX_PLAYERS];
Dialog_Login(playeridresponseinputtext[])
{
    switch (
response// Check which button was clicked
    
{
        case 
1// Player clicked "Login"
        
{
            
// Check if the player entered a password
            
if (strlen(inputtext) > 0)
            {
                
// Check if the entered password is the same as the password saved in the player's account
                
if (strcmp(APlayerData[playerid][PlayerPassword], inputtextfalse) == 0)
                {
                    
APlayerData[playerid][LoggedIn] = true// The player has logged in properly
                    
BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
                    
SendClientMessage(playerid0xFFFFFFFFTXT_LoggedIn); // Send a message to the client to inform him that he logged in properly
                
}
                else
                {
                    
SendClientMessage(playerid0xFFFFFFFFTXT_WrongPassword);
                    
Kick(playerid);
                }
            }
            else
            {
            new 
strs[256];
            
FailLogin[playerid]++;
            
format(stringsizeof(string), "The password you have entered was incorrect. Attempts(%d)"FailLogin[playerid]);
            
ShowPlayerDialog(playerid,Dialog_Login,DIALOG_STYLE_INPUT,"Login",strs,"Login","Cancel");
            if(
FailLogin[playerid] == MAX_FAIL_LOGINS)
            {
            new 
string[128]; format(stringsizeof(string), "%s has been kicked (Failed Logins)",Name(playerid) );
            
SendClientMessageToAll(-1string);
            
Kick(playerid);
            }
            }
        }
        case 
0// Player clicked "Cancel"
        
{
            
// Show a message that the player must be logged in to play on this server
            
SendClientMessage(playerid0xFFFFFFFFTXT_PlayerMustLogin);
            
// Kick the player
            
Kick(playerid);
        }
    }
    return 
1;

Reply
#3

......
Reply
#4

.....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)