26.12.2014, 20:08
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
variable for counting attemps.
OnRconLoginAttemp( ... )
Under
OnDialogResponse
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"
PHP код:
new SecondRconAttemps[MAX_PLAYERS];
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;
}
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;
}
}
}
}