Advertisement
Ygzeb

Check IP SA-MP

Feb 18th, 2015
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.09 KB | None | 0 0
  1. // Basic SA-MP script against bots.
  2.  
  3. //==============================================================================
  4. // Includes.
  5. //==============================================================================
  6. #include <a_samp>
  7. //==============================================================================
  8. //------------------------------------------------------------------------------
  9. //                         Configuration.
  10. //------------------------------------------------------------------------------
  11. //==============================================================================
  12. //==============================================================================
  13. // Define IPS.
  14. //==============================================================================
  15. #define IPS 7
  16. //==============================================================================
  17. //------------------------------------------------------------------------------
  18. //                         Publics.
  19. //------------------------------------------------------------------------------
  20. //==============================================================================
  21. //==============================================================================
  22. // Public - OnPlayerConnect.
  23. //==============================================================================
  24. public OnPlayerConnect(playerid)
  25. {
  26. new Connecting[32+1];
  27. GetPlayerIp(playerid, Connecting, 32);
  28. new Num = GetNumberOfPlayersOnThisIP(Connecting);
  29. if(Num > IPS)
  30. {
  31. printf("MAX IPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, IPS, Connecting);
  32. BanEx(playerid, "Bots");
  33. return 1;
  34. }
  35. return 0;
  36. }
  37. //==============================================================================
  38. // Stock - GetNumberOfPlayersOnThisIP.
  39. //==============================================================================
  40. stock GetNumberOfPlayersOnThisIP(Test[])
  41. {
  42. new Against[32+1];
  43. new X = 0;
  44. new Count = 0;
  45. for(X = 0; X < MAX_PLAYERS; X++)
  46. {
  47. if(IsPlayerConnected(X))
  48. {
  49. GetPlayerIp(X, Against, 32);
  50. if(!strcmp(Against, Test)) Count++;
  51. }
  52. }
  53. return Count;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement