1
0

antiflood.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. forward AOnPlayerConnect(playerid);
  7. public AOnPlayerConnect(playerid)
  8. {
  9. new ConnIP[16];
  10. GetPlayerIp(playerid,ConnIP,16);
  11. new compare_IP[16];
  12. new number_IP = 0;
  13. for(new i=0; i<MAX_PLAYERS; i++) {
  14. if(IsPlayerConnected(i)) {
  15. GetPlayerIp(i,compare_IP,16);
  16. if(!strcmp(compare_IP,ConnIP)) number_IP++;
  17. }
  18. }
  19. if((GetTickCount() - Join_Stamp) < Time_Limit)
  20. exceed=1;
  21. else
  22. exceed=0;
  23. if(strcmp(ban_s, ConnIP, false) == 0 && exceed == 1 )
  24. {
  25. Same_IP++;
  26. if(Same_IP > SAME_IP_CONNECT)
  27. {
  28. Ban(playerid);
  29. Same_IP=0;
  30. }
  31. }
  32. else
  33. {
  34. Same_IP=0;
  35. }
  36. if(number_IP > IP_LIMIT)
  37. Kick(playerid);
  38. GetStampIP(playerid);
  39. return 1;
  40. }
  41. stock GetStampIP(playerid){
  42. new S_IP[16];
  43. Join_Stamp=GetTickCount();
  44. GetPlayerIp(playerid,S_IP,16);
  45. format(ban_s, 16, "%s", S_IP);
  46. }