Guest User

AntiBot.pwn

a guest
Apr 23rd, 2019
1,022
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.00 KB | None | 0 0
  1. /*==================================
  2.  
  3.     Anti-Bot v1.0
  4.     github.com/RyderAsthana/Anti-Bot
  5.     Credits - Rajat
  6.  
  7. ==================================*/
  8. #include <a_samp>
  9. main()
  10. {
  11.     print("Loading ANTI-BOT script by Rajat");
  12. }
  13. //================================ Config ==============================
  14. #define MAX_BOT_CONNECTIONS 2
  15. //================================ OnFilterScriptInit ==============================
  16. public OnFilterScriptInit()
  17. {
  18.     print("Anti Bot DDOS script by Rajat loaded.");
  19.    
  20.     return 1;
  21. }
  22. //================================ OnFilterScriptExit ==============================
  23. public OnFilterScriptExit()
  24. {
  25.     print("Anti Bot DDOS script by Rajat Unloaded.");
  26.     return 1;
  27. }
  28. //================================ Config ==============================
  29. public OnPlayerConnect(playerid)
  30. {
  31.     new PlayerName[25];
  32.     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  33.     if(CountIP(GetIP(playerid)) >= MAX_BOT_CONNECTIONS) return BanAllBots(playerid), 0;
  34.     printf("%s Just connected to the server.", PlayerName);
  35.     return 1;
  36. }
  37. //================================ OnPlayerConnect ==============================
  38. public OnPlayerDisconnect(playerid, reason)
  39. {
  40.     new PlayerName[25];
  41.     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  42.     printf("%s Just left the server.", PlayerName);
  43.     return 1;
  44. }
  45. //================================ stock ==============================
  46. stock CountIP(ip[]) // Counts how many connections from one IP.
  47. {
  48.     new b = 0;
  49.     for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !strcmp(GetIP(i),ip)) b++;
  50.     return b;
  51. }
  52.  
  53. stock GetIP(playerid) // Fetches the player IP.
  54. {
  55.     new ip[16];
  56.     GetPlayerIp(playerid,ip,sizeof(ip));
  57.     return ip;
  58. }
  59. stock BanAllBots(playerid) // Bans the player.
  60. {
  61.     new PlayerName[25];
  62.     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  63.     printf("%s was Banned due to MANY Connections.", PlayerName);
  64.     Ban(playerid);
  65.     return 1;
  66. }
  67. // ==========================================END OF THE SCRIPT=======================================
Add Comment
Please, Sign In to add comment