07.07.2017, 06:09
You are checking for one thing two times:
The `!strcmp(ip, pIP)` It can be done like this:
And in addition to this you are getting every player's name while you only need one players name:
And also delay declaring global variables.
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.
}
PHP код:
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)
{
PHP код:
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