Guest User

Insanity Anti-Bunny Hopping

a guest
Oct 8th, 2010
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.27 KB | None | 0 0
  1. /*
  2. ////////////////////////////////////////////////////////////////////////////////
  3.  
  4.                       • Insanity Anti-Bunny Hopping •
  5.  
  6. - Description
  7.  
  8.   The filterscript avoid the use of Bunny Hopping in your server sending a message to the ao admins
  9.   online or kicking the player(you can configure it), if you use the GodFather,
  10.   you can use CallRemoteFunction to send a message to admins and/or call the function KickLog.
  11.  
  12. - Author
  13.  
  14.   Allan Jader (CyNiC)
  15.  
  16.  
  17. - Note
  18.  
  19.   You can change how much you want the filterscript, leaving the credit to creator.
  20.  
  21. ////////////////////////////////////////////////////////////////////////////////
  22. */
  23. //Extern
  24. #include <a_samp>
  25.  
  26. //Message Color
  27. #define COLOR_WHITE 0xFFFFFFAA
  28.  
  29. //Configuration
  30. #define MODE 0 //   Mode 0: SEND A MESSAGE TO ADMINS / Mode 1: KICK THE PLAYER
  31. #define MAX_WARNINGS 3
  32.  
  33. //Variables
  34. new oldanim[MAX_PLAYERS][32],
  35. PlayerSequence[MAX_PLAYERS][100],
  36. count[MAX_PLAYERS],
  37. pTimer[MAX_PLAYERS];
  38.  
  39. //Forwards
  40. forward CheckBunnyHopping(playerid);
  41. forward ResetPlayer(playerid);
  42.  
  43. //Functions
  44. public OnFilterScriptInit()
  45. {
  46.     for(new i=0; i<MAX_PLAYERS; i++)
  47.     {
  48.         if(IsPlayerConnected(i))
  49.         {
  50.             pTimer[i]=SetTimerEx("CheckBunnyHopping",100,true,"d",i);
  51.         }  
  52.     }  
  53.     return 1;
  54. }  
  55.        
  56. public OnPlayerConnect(playerid)
  57. {
  58.     pTimer[playerid]=SetTimerEx("CheckBunnyHopping",100,true,"d",playerid);
  59.     return 1;
  60. }  
  61.  
  62. public OnPlayerDisconnect(playerid)
  63. {
  64.     KillTimer(pTimer[playerid]);
  65.     return 1;
  66. }
  67.        
  68. public CheckBunnyHopping(playerid)
  69. {  
  70.     new animlib[32];
  71.     new animname[32];        
  72.     GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);        
  73.     if(strcmp(oldanim[playerid],animname,true) != 0)
  74.     {                      
  75.         strcat(PlayerSequence[playerid],oldanim[playerid],100);
  76.         count[playerid]++;
  77.         if(count[playerid] >= 3 && GetPVarInt(playerid,"HasSended") == 0)
  78.         {              
  79.             if(strfind(PlayerSequence[playerid],"JUMP_LAUNCH",true) != -1
  80.             && strfind(PlayerSequence[playerid],"JUMP_LAND",true) != -1
  81.             && strfind(PlayerSequence[playerid],"JUMP_GLIDE",true) != -1)
  82.             {                  
  83.                 new string[80];
  84.                 count[playerid]=0;
  85.                 format(PlayerSequence[playerid],1,"");     
  86.                 #if MODE == 0
  87.                 format(string,80,"[WARNING] %s are doing Bunny Hopping!",GetNick(playerid));
  88.                 for(new i=0; i<MAX_PLAYERS; i++)
  89.                 {
  90.                     if(IsPlayerConnected(i) && IsPlayerAdmin(i))
  91.                     {
  92.                         SendClientMessage(i,COLOR_WHITE,string);
  93.                     }
  94.                 }          
  95.                 #else
  96.                 if(GetPVarInt(playerid,"Warnings") == MAX_WARNINGS)
  97.                 {
  98.                     format(string,80,"[WARNING] %s has kicked for doing Bunny Hopping!",GetNick(playerid));
  99.                     SendClientMessageToAll(COLOR_WHITE,string);
  100.                     Kick(playerid);
  101.                     return 1;
  102.                 }              
  103.                 #endif
  104.                 SendClientMessage(playerid,COLOR_WHITE,"You're doing Bunny Hopping, stop or you will be kicked.");
  105.                 SetPVarInt(playerid,"HasSended",1);
  106.                 SetPVarInt(playerid,"Warnings",GetPVarInt(playerid,"Warnings")+1);
  107.                 SetTimerEx("ResetPlayer",5000,false,"d",playerid);
  108.             }
  109.             format(PlayerSequence[playerid],1,"");
  110.             count[playerid]=0;
  111.         }  
  112.     }  
  113.     format(oldanim[playerid],32,"%s",animname);
  114.     return 1;
  115. }
  116.  
  117. public ResetPlayer(playerid) return SetPVarInt(playerid,"HasSended",0);
  118.    
  119. GetNick(playerid) {
  120. new N[MAX_PLAYER_NAME];
  121. GetPlayerName(playerid, N, sizeof N);
  122. return N;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment