DIALOG BUG - Help -
danish007 - 26.12.2014
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 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);
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;
}
Under
OnDialogResponse
PHP код:
switch( dialogid )
{
case SECOND_RCON_DIALOG:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strcmp(inputtext, SECOND_RCON_PASSWORD, true))
{
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(playerid, COLOR_ADMIN,"Logged In Completely As Rcon Admin.");
}else{
SecondRconAttemps[playerid] ++;
if(SecondRconAttemps[playerid] == 1)
{
SendClientMessage(playerid, COLOR_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(playerid, COLOR_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(playerid, COLOR_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;
}
}
}
}
Re: DIALOG BUG - Help -
danish007 - 27.12.2014
Bump?
Re: DIALOG BUG - Help -
Luicy. - 27.12.2014
Whats the errors?
I mean when you compiling you get any errors?
Re: DIALOG BUG - Help -
danish007 - 27.12.2014
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.
Re: DIALOG BUG - Help -
JaydenJason - 27.12.2014
Код:
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.
Re: DIALOG BUG - Help -
danish007 - 27.12.2014
nah not working.... i think its bug in ondialogresponse not in onrconloginattemp.
Re: DIALOG BUG - Help -
Ahmad45123 - 27.12.2014
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
Re: DIALOG BUG - Help -
danish007 - 30.12.2014
thanks +rep