SA-MP Forums Archive
For loop or OnRconLoginAttemp bug ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: For loop or OnRconLoginAttemp bug ? (/showthread.php?tid=105333)



For loop or OnRconLoginAttemp bug ? - UsaBoy91 - 28.10.2009

pawn Код:
public OnRconLoginAttempt(ip[], password[], success)
{
  //#if allow == true
  if(!success) //If the password was incorrect
  {
    new playerip[16];
        print("OnRconLoginAttempt - Called ~");
    for(new i; i < MAX_PLAYERS; i++)
    {
      GetPlayerIp(i, playerip, sizeof(playerip));
      if(!strcmp(ip, playerip, true))
      {
        SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!");
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s !",ip, password);
        Ban(i);
      }
    }
    print("OnRconLoginAttempt - Called after ~ for loop ~");
  }
  //#endif
  return 1;
}
I type /rcon login wrong_password , i got banned , but in server_log i recive 300 msg ( 300 = MAX_PLAYERS )

http://pastebin.com/m18d31b53


Re: For loop or OnRconLoginAttemp bug ? - Sergei - 28.10.2009

Try adding 'break;' after Ban(i)


Re: For loop or OnRconLoginAttemp bug ? - Daren_Jacobson - 28.10.2009

his fix would work, but it is probobly because if the player isn't connected GetPlayerIp doesn't put anything into playerip, meaning it equals what it used too.


Re: For loop or OnRconLoginAttemp bug ? - Sergei - 28.10.2009

Ah yes, IsPlayerConnected misses in your loop. Consider using foreach by the way


Re: For loop or OnRconLoginAttemp bug ? - MenaceX^ - 28.10.2009

Non logged players have 255.255.255.255 as their IP, which cannot be compared that way.
Useless to add it.
Wiki: https://sampwiki.blast.hk/wiki/OnRconLoginAttemptMy bad, it is the code from wiki, use break or return.