SAMP Gitlab CI Test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. // maxips FS limits the number of players connecting from a
  2. // single IP address.
  3. #include <a_samp>
  4. #define MAX_CONNECTIONS_FROM_IP 3
  5. //---------------------------------------------
  6. public OnFilterScriptInit()
  7. {
  8. printf("\n*** Player IP limiting FS (maxips) Loaded. Max connections from 1 IP = %d\n",MAX_CONNECTIONS_FROM_IP);
  9. }
  10. //---------------------------------------------
  11. // GetNumberOfPlayersOnThisIP
  12. // Returns the number of players connecting from the
  13. // provided IP address
  14. stock GetNumberOfPlayersOnThisIP(test_ip[])
  15. {
  16. new against_ip[32+1];
  17. new x = 0;
  18. new ip_count = 0;
  19. for(x=0; x<MAX_PLAYERS; x++) {
  20. if(IsPlayerConnected(x)) {
  21. GetPlayerIp(x,against_ip,32);
  22. if(!strcmp(against_ip,test_ip)) ip_count++;
  23. }
  24. }
  25. return ip_count;
  26. }
  27. //---------------------------------------------
  28. public OnPlayerConnect(playerid)
  29. {
  30. new connecting_ip[32+1];
  31. GetPlayerIp(playerid,connecting_ip,32);
  32. new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);
  33. if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP) {
  34. printf("MAXIPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
  35. Kick(playerid);
  36. return 1;
  37. }
  38. return 0;
  39. }
  40. //---------------------------------------------