new RconAttempt[MAX_PLAYERS]; // This variable will hold the amount of attempts the player has
#define MAX_RCONATTEMPTS 2
// This sets the maximum of attempts to 2
public OnRconLoginAttempt(ip[], password[], success)
if(!success) // this checks if the player didn't succeed to login
{
new string[128], pIP[32], pname[MAX_PLAYER_NAME]; // This will hold the message we are going to send to all players
// We will now have to loop through all the online players because 'playerid' isn't usable in this callback.
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // This is the loop, 'GetPlayerPoolSize' checks the highest ID IG, hence I'd rather use that loop instead of MAX_PLAYERS;
{
if(IsPlayerConnected(i)) // Check if the player is even connected
{
GetPlayerName(i, pname, MAX_PLAYER_NAME); // Get the player's name
GetPlayerIp(i, pIP, 32); // Check the player's IP
if(RconAttempt[i] < MAX_RCONATTEMPTS && !strcmp(ip, pIP)) //Check if the player hasn't reached the MAX_RCONATTEMPTS
{
RconAttempt[i]++; // if it's not reached, we will increase this variable
}
else if(RconAttempt[i] >= MAX_RCONATTEMPTS && !strcmp(ip, pIP)) // Check if the player reached the maximum attempts (2)
{
format(string, sizeof string, "%s has been automatically banned from the server. Reason: Attempting to hack the RCON password.", pname);
SendClientMessageToAll(COLOR_RED, string); // Send the formatted message to everyone in red.
Ban(i); // Ban the player who tried to login twice.
}
}
}
}
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success)
{
new string[128], pIP[32], pname[MAX_PLAYER_NAME];
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, pname, MAX_PLAYER_NAME);
GetPlayerIp(i, pIP, 32);
if(RconAttempt[i] < MAX_RCONATTEMPTS && !strcmp(ip, pIP))
{
RconAttempt[i]++;
}
else if(RconAttempt[i] >= MAX_RCONATTEMPTS && !strcmp(ip, pIP))
{
format(string, sizeof string, "%s has been automatically banned from the server. Reason: Attempting to hack the RCON password.", pname);
SendClientMessageToAll(COLOR_RED, string);
Ban(i);
}
}
}
}
}
format(string, sizeof string, "%s has been automatically banned from the server. Reason: Attempting to hack the RCON password.", pname);
So 3 unsuccessful attempts will ban everyone because you forgot to compare IPs.
|
PHP код:
|
Who uses RCON anyway? I would just straight up block the IP of anyone who tries to login, no matter friend or foe. RCON is too crude a tool to be of any reasonable use so I prefer to disable it completely.
|
Who uses RCON anyway? I would just straight up block the IP of anyone who tries to login, no matter friend or foe. RCON is too crude a tool to be of any reasonable use so I prefer to disable it completely.
|
if(!success) // this checks if the player didn't succeed to login
{
new string[128], pIP[32], pname[MAX_PLAYER_NAME]; // This will hold the message we are going to send to all players
// We will now have to loop through all the online players because 'playerid' isn't usable in this callback.
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // This is the loop, 'GetPlayerPoolSize' checks the highest ID IG, hence I'd rather use that loop instead of MAX_PLAYERS;
{
if(IsPlayerConnected(i)) // Check if the player is even connected
{
GetPlayerName(i, pname, MAX_PLAYER_NAME); // Get the player's name
GetPlayerIp(i, pIP, 32); // Check the player's IP
if(RconAttempt[i] < MAX_RCONATTEMPTS) // Check if the player hasn't reached the MAX_RCONATTEMPTS
{
[B] RconAttempt[i]++; [/B] // if it's not reached, we will increase this variable
}
PHP код:
|
if(RconAttempt[i] < MAX_RCONATTEMPTS && !strcmp(ip, pIP)) //Check if the player hasn't reached the MAX_RCONATTEMPTS
{
RconAttempt[i]++; // if it's not reached, we will increase this variable
}
else if(RconAttempt[i] >= MAX_RCONATTEMPTS && !strcmp(ip, pIP)) // Check if the player reached the maximum attempts (2)
{
format(string, sizeof string, "%s has been automatically banned from the server. Reason: Attempting to hack the RCON password.", pname);
SendClientMessageToAll(COLOR_RED, string); // Send the formatted message to everyone in red.
Ban(i); // Ban the player who tried to login twice.
}
if(strcmp(ip, pIP)) return 1;
if(RconAttempt[i] < MAX_RCONATTEMPTS) //Check if the player hasn't reached the MAX_RCONATTEMPTS
{
RconAttempt[i]++; // if it's not reached, we will increase this variable
}
else if(RconAttempt[i] >= MAX_RCONATTEMPTS) // Check if the player reached the maximum attempts (2)
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // This is the loop, 'GetPlayerPoolSize' checks the highest ID IG, hence I'd rather use that loop instead of MAX_PLAYERS;
{
if(IsPlayerConnected(i)) // Check if the player is even connected
{
GetPlayerName(i, pname, MAX_PLAYER_NAME); // Get the player's name