Mauzen

Anti-CBug 1.1

Jan 23rd, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Extremely simple CBug detector/Anti-CBug
  3.     Version 1.1 (1/23/2014)
  4.  
  5.     Made by Mauzen (msoll(at)web.de)
  6.    
  7.     This include allows to unsync extra deagle shots automatically,
  8.     and calls OnPlayerCBug once a cbug was detected.
  9.    
  10.     Use as you like, but dont remove this header.  
  11. */
  12.  
  13. #if (!defined VectorSize)
  14.     #error "The Anti-CBug include requires at least SA-MP 0.3z RC3"
  15. #endif
  16.  
  17.  
  18. // The minimum intervals between two shots, everything below that
  19. // is treated as CBug
  20. #define CBUG_INTERVAL_DEAGLE    700
  21. #define CBUG_INTERVAL_SHOTGUN   1000
  22. #define CBUG_INTERVAL_COMBATSG  340
  23. #define CBUG_INTERVAL_COUNTRY   850
  24. #define CBUG_INTERVAL_SNIPER    850
  25.  
  26.  
  27. // Used for getting shot intervals
  28. new lastDShot[MAX_PLAYERS];
  29.  
  30. // If 1, extra cbug shots are unsynced automatically
  31. new removeCBugs = 1;
  32. // If 1, OnPlayerCBug is called on cbug usages
  33. new alertCBugs = 1;
  34.  
  35.  
  36. // Callback forward
  37. forward OnPlayerCBug(playerid, weaponid, interval);
  38.  
  39.  
  40. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  41. {  
  42.     // Avoid driveby false alarms
  43.     if (!IsPlayerInAnyVehicle(playerid) && (removeCBugs || alertCBugs))
  44.     {
  45.         new interval = 0;
  46.         switch (weaponid)
  47.         {
  48.             case 24: interval = CBUG_INTERVAL_DEAGLE;
  49.             case 25: interval = CBUG_INTERVAL_SHOTGUN;
  50.             case 27: interval = CBUG_INTERVAL_COMBATSG;
  51.             case 33: interval = CBUG_INTERVAL_COUNTRY;
  52.             case 34: interval = CBUG_INTERVAL_SNIPER;
  53.         }
  54.        
  55.         // Check if used weapon is a CBug-Weapon
  56.         if (interval > 0) {    
  57.             // Check if time difference is positive to avoid GetTickCount-reset false alarms
  58.             if (GetTickCount() - lastDShot[playerid] < interval && GetTickCount() - lastDShot[playerid] >= 0)
  59.             {              
  60.                 if (alertCBugs) CallLocalFunction("OnPlayerCBug", "iii", playerid, weaponid, GetTickCount() - lastDShot[playerid]);
  61.                 return !removeCBugs;
  62.             }
  63.             lastDShot[playerid] = GetTickCount();
  64.         }
  65.     }
  66.     #if defined ACBUG_OnPlayerWeaponShot
  67.         return ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  68.     #else
  69.         return 1;
  70.     #endif
  71. }
  72. #if defined _ALS_OnPlayerWeaponShot
  73.     #undef OnPlayerWeaponShot
  74. #else
  75.     #define _ALS_OnPlayerWeaponShot
  76. #endif
  77. #define OnPlayerWeaponShot ACBUG_OnPlayerWeaponShot
  78. #if defined ACBUG_OnPlayerWeaponShot
  79.     forward ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  80. #endif
Advertisement
Add Comment
Please, Sign In to add comment