Guest User

Maxip

a guest
Oct 21st, 2013
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.99 KB | None | 0 0
  1. #include <a_samp>
  2. #define MAX_CONNECTIONS_FROM_IP     3 //change this to what ever you want...this will be the max connections from the IP
  3. public OnFilterScriptInit()
  4. {
  5.     printf("\n*** Player IP limiting FS (maxips) Loaded. Max connections from 1 IP = %d\n",MAX_CONNECTIONS_FROM_IP);
  6. }
  7.  
  8. stock GetNumberOfPlayersOnThisIP(test_ip[])
  9. {
  10.     new against_ip[32+1];
  11.     new x = 0;
  12.     new ip_count = 0;
  13.     for(x=0; x<MAX_PLAYERS; x++) {
  14.         if(IsPlayerConnected(x)) {
  15.             GetPlayerIp(x,against_ip,32);
  16.             if(!strcmp(against_ip,test_ip)) ip_count++;
  17.         }
  18.     }
  19.     return ip_count;
  20. }
  21.  
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25.     new connecting_ip[32+1];
  26.     GetPlayerIp(playerid,connecting_ip,32);
  27.     new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);
  28.    
  29.     if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP) {
  30.         printf("MAXIPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
  31.         Kick(playerid);
  32.         return 1;
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment