Advertisement
Guest User

Untitled

a guest
Feb 15th, 2012
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.83 KB | None | 0 0
  1. // maxips FS limits the number of players connecting from a
  2. // single IP address.
  3.  
  4. #include <a_samp>
  5.  
  6. #define MAX_CONNECTIONS_FROM_IP     3
  7. #define MAX_CONNECT_IN_ROW 3
  8. #define MAX_REJOIN_TIME 4000
  9. new ipCheck[25], IPfound, IPtime;
  10. //---------------------------------------------
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.     printf("\n*** Player IP limiting FS (maxips) Loaded. Max connections from 1 IP = %d\n",MAX_CONNECTIONS_FROM_IP);
  15. }
  16.  
  17. //---------------------------------------------
  18. // GetNumberOfPlayersOnThisIP
  19. // Returns the number of players connecting from the
  20. // provided IP address
  21.  
  22. stock GetNumberOfPlayersOnThisIP(test_ip[])
  23. {
  24.     new against_ip[32+1];
  25.     new x = 0;
  26.     new ip_count = 0;
  27.     for(x=0; x<MAX_PLAYERS; x++) {
  28.         if(IsPlayerConnected(x)) {
  29.             GetPlayerIp(x,against_ip,32);
  30.             if(!strcmp(against_ip,test_ip)) ip_count++;
  31.         }
  32.     }
  33.     return ip_count;
  34. }
  35.  
  36. //---------------------------------------------
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40.     new connecting_ip[32+1];
  41.     GetPlayerIp(playerid,connecting_ip,32);
  42.     new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);
  43.  
  44.     if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP) {
  45.         printf("MAXIPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
  46.         Kick(playerid);
  47.         return 1;
  48.     }
  49.     new watIP[25];
  50.     GetPlayerIp(playerid, watIP, 25);
  51.     if(strcmp(ipCheck, watIP, false) == 0 && ( GetTickCount() - IPtime ) < MAX_REJOIN_TIME )
  52.     {
  53.         IPfound++;
  54.         if(IPfound > MAX_CONNECT_IN_ROW)
  55.         {
  56.             new str[100];
  57.             format(str, 100, "banip %s", watIP);
  58.             SendRconCommand(str);
  59.             Kick(playerid);
  60.             IPfound=0;
  61.         }
  62.     }
  63.     else
  64.     {
  65.         IPfound=0;
  66.     }
  67.     format(ipCheck, 25, "%s", watIP);
  68.  
  69.     IPtime=GetTickCount();
  70.     return 0;
  71. }
  72.  
  73. //---------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement