DIALOG BUG - Help
#1

Hello, i've a dialog for Rcon Security.
its working fine if i type correct defined password. and working fine if i put wrong passowrd.
but it bugs when i leave empty. and press enter without entering any password, its give response. instead of kicking, or counting rconattemps.

here is my code.

On Top i've defined
PHP код:
#define SECOND_RCON_DIALOG 2018
#define SECOND_RCON_PASSWORD "mypassword" 
variable for counting attemps.
PHP код:
new SecondRconAttemps[MAX_PLAYERS]; 
OnRconLoginAttemp( ... )
PHP код:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!
success)
    {
      for(new 
0MAX_PLAYERSi++)
      {
       if(
strcmp(ipPlayerIp(i), true) == 0)
       {
           
SendClientMessage(i,COLOR_DEAD,"You Have Been Kicked Due To Attempting Wrong Rcon Password.");
        
KickEx(i);
        break;
       }
      }
    }
    else
    {
      for(new 
0MAX_PLAYERSi++)
      {
       if(
strcmp(ipPlayerIp(i), true) == 0)
       {
       
SendClientMessage(iCOLOR_ADMIN"Please Enter Second Rcon Password.");
       new 
str1[120];
       
format(str1,sizeof(str1),"%s(%d) Has Been Logged In As First Rcon Admin."PlayerInfo[i][pName], i);
       
ShowPlayerDialog(,SECOND_RCON_DIALOG ,DIALOG_STYLE_PASSWORD,"{FFFFFF}Second Rcon Password","Admin MAXIMUM Security.\nPlease Enter Second Rcon Password To Become Complete Rcon Admin\nOtherwise Get Kicked","login","kick");
       break;
       }
      }
    }
    return 
1;

Under
OnDialogResponse
PHP код:
switch( dialogid )
{
        case 
SECOND_RCON_DIALOG:
        {
        if(!
response) return Kick(playerid);
        if(
response)
        {
        if(!
strcmp(inputtextSECOND_RCON_PASSWORDtrue))
        {
        new 
str[120];
        
format(str,sizeof(str),"[SUCCESS 2ndRcon Pass] %s (%d) Has Been Completely Logged In As Rcon Admin."PlayerInfo[playerid][pName], playerid);
        print(
str);
        
SendClientMessage(playeridCOLOR_ADMIN,"Logged In Completely As Rcon Admin.");
        }else{
        
SecondRconAttemps[playerid] ++;
        if(
SecondRconAttemps[playerid] == 1)
        {
        
SendClientMessage(playeridCOLOR_ERROR"Wrong Second Rcon Password - 1/3");
        
ShowPlayerDialog(playerid ,SECOND_RCON_DIALOG ,DIALOG_STYLE_PASSWORD,"{FFFFFF}Second Rcon Password","Admin MAXIMUM Security.\nPlease Enter Second Rcon Password To Become Complete Rcon Admin\nOtherwise Get Kicked","login","kick");
        }
        if(
SecondRconAttemps[playerid] == 2)
        {
        
SendClientMessage(playeridCOLOR_ERROR"Wrong Second Rcon Password - 2/3");
        
ShowPlayerDialog(playerid ,SECOND_RCON_DIALOG ,DIALOG_STYLE_PASSWORD,"{FFFFFF}Second Rcon Password","Admin MAXIMUM Security.\nPlease Enter Second Rcon Password To Become Complete Rcon Admin\nOtherwise Get Kicked","login","kick");
        }
        if(
SecondRconAttemps[playerid] == 3)
        {
        
SendClientMessage(playeridCOLOR_ERROR"Wrong Second Rcon Password - 3/3 - KICKED");
        
ShowPlayerDialog(playerid ,SECOND_RCON_DIALOG ,DIALOG_STYLE_PASSWORD,"{FFFFFF}Second Rcon Password","Admin MAXIMUM Security.\nPlease Enter Second Rcon Password To Become Complete Rcon Admin\nOtherwise Get Kicked","login","kick");
        
KickEx(playerid);
        }
        return 
1;
        }
        }
    }

Reply
#2

Bump?
Reply
#3

Whats the errors?
I mean when you compiling you get any errors?
Reply
#4

no errors in compiling, its just working fine but if i enter without tyoing any passwrod it give access to rcon admin instead of kicking.
Reply
#5

Код:
public OnRconLoginAttempt(ip[], password[], success) 
{ 
    if(!success) 
    { 
      for(new i = 0; i < MAX_PLAYERS; i++) 
      { 
       if(strcmp(ip, PlayerIp(i), true) == 0) 
       { 
           SendClientMessage(i,COLOR_DEAD,"You Have Been Kicked Due To Attempting Wrong Rcon Password."); 
        KickEx(i); 
        return 0; // instead of break;
       } 
      } 
    } 
    else 
    { 
      for(new i = 0; i < MAX_PLAYERS; i++) 
      { 
       if(strcmp(ip, PlayerIp(i), true) == 0) 
       { 
       SendClientMessage(i, COLOR_ADMIN, "Please Enter Second Rcon Password."); 
       new str1[120]; 
       format(str1,sizeof(str1),"%s(%d) Has Been Logged In As First Rcon Admin.", PlayerInfo[i][pName], i); 
       ShowPlayerDialog(i ,SECOND_RCON_DIALOG ,DIALOG_STYLE_PASSWORD,"{FFFFFF}Second Rcon Password","Admin MAXIMUM Security.\nPlease Enter Second Rcon Password To Become Complete Rcon Admin\nOtherwise Get Kicked","login","kick"); 
       break; 
       } 
      } 
    } 
    return 1; 
}
Not sure if this works though.
Reply
#6

nah not working.... i think its bug in ondialogresponse not in onrconloginattemp.
Reply
#7

As you can see in https://sampwiki.blast.hk/wiki/Strcmp.

The function returs 0 if either of the vars are empty... So you'll have to check it first if its empty...

Here is how you check it:
pawn Код:
if(strlen(inputtext) > 0)
And also BTW... Try using [PAWN] tags in the future.

Oh and also... Please intend your code
Reply
#8

thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)