AntiFlood.pwn 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <a_samp>
  2. #define IP_LIMIT 2 // = Max connections from one single IP
  3. #define SAME_IP_CONNECT 4 // = The number of connects from the same IP before banning the flooder
  4. new Same_IP=0,Join_Stamp,ban_s[25],exceed=0;
  5. #define Time_Limit 3500 // = The time span between connects, adjust it to your own specifications
  6. public OnPlayerConnect(playerid)
  7. {
  8. new ConnIP[16];
  9. GetPlayerIp(playerid,ConnIP,16);
  10. new compare_IP[16];
  11. new number_IP = 0;
  12. for(new i=0; i<MAX_PLAYERS; i++) {
  13. if(IsPlayerConnected(i)) {
  14. GetPlayerIp(i,compare_IP,16);
  15. if(!strcmp(compare_IP,ConnIP)) number_IP++;
  16. }
  17. }
  18. if((GetTickCount() - Join_Stamp) < Time_Limit)
  19. exceed=1;
  20. else
  21. exceed=0;
  22. if(strcmp(ban_s, ConnIP, false) == 0 && exceed == 1 )
  23. {
  24. Same_IP++;
  25. if(Same_IP > SAME_IP_CONNECT)
  26. {
  27. Ban(playerid);
  28. Same_IP=0;
  29. }
  30. }
  31. else
  32. {
  33. Same_IP=0;
  34. }
  35. if(number_IP > IP_LIMIT)
  36. Kick(playerid);
  37. GetStampIP(playerid);
  38. return 1;
  39. }
  40. stock GetStampIP(playerid){
  41. new S_IP[16];
  42. Join_Stamp=GetTickCount();
  43. GetPlayerIp(playerid,S_IP,16);
  44. format(ban_s, 16, "%s", S_IP);
  45. }