Help with login with 3 warnings.
#1

Hello, when players come to server and login when is password wrong players will be kicked. Now how to add 3-more warn?. When on 3.rd players type wrong password , player will be kicked. Sry for my English.
PHP код:
// Process the login-dialog
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 properley
                
}
                else
                {
                    
SendClientMessage(playerid0xFFFFFFFFTXT_WrongPassword);
                
//    Kick(playerid);
                
}
            }
            else
            {
                
SendClientMessage(playerid0xFFFFFFFFTXT_WrongPassword);
                
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
#2

Some one?
Reply
#3

At the top of your script

pawn Код:
new LoginAttemps[MAX_PLAYERS];

forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);

Then edit your code in this part

pawn Код:
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 properley
                }
                else
                {
                      LoginAttempts[playerid]++;
                      if(LoginAttempts[playerid] >= 3)  {
                      SetTimerEx("KickPlayer", 200, false, "i" playerid);
                      SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
                      }
                }
Reply
#4

I getting error:
Dialogs.inc(67) : error 017: undefined symbol "LoginAttempts"
Dialogs.inc(67) : warning 215: expression has no effect
Dialogs.inc(67) : error 001: expected token: ";", but found "]"
Dialogs.inc(67) : error 029: invalid expression, assumed zero
Dialogs.inc(67) : fatal error 107: too many error messages on one line

PHP код:
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 properley 
                

                else 
                { 
                    
LoginAttempts[playerid]++;
                    if(
LoginAttempts[playerid] >= 3)  { 
                    
SetTimerEx("KickPlayer"200false"i" playerid);
                    
SendClientMessage(playerid0xFFFFFFFFTXT_WrongPassword); 
                    }
                }
        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;

Where i faill?
Reply
#5

Did you add the variable at the top of your script like I have said?

Also remember to add

pawn Код:
LoginAttempts[playerid]=0;
Under OnPlayerConnect
Reply
#6

I defined: TO TOP.

new LoginAttemps[MAX_PLAYERS];
forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);
Reply
#7

Quote:
Originally Posted by NixsaHD
Посмотреть сообщение
I defined: TO TOP.

new LoginAttemps[MAX_PLAYERS];
forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);
Sorry my bad

Change

pawn Код:
new LoginAttemps[MAX_PLAYERS];
To

pawn Код:
new LoginAttempts[MAX_PLAYERS];


Also

PHP код:

public OnPlayerConnect(playerid)
{
         
LoginAttempts[playerid] = 0;
         return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)