Mauzen

Anti-CBug 1.0

Jan 23rd, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.75 KB | None | 0 0
  1. /*
  2.     Extremely simple CBug detector/Anti-CBug
  3.     Version 1.0 (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. // Used for getting shot intervals
  19. new lastDShot[MAX_PLAYERS];
  20.  
  21. // If 1, extra cbug shots are unsynced automatically
  22. new removeCBugs = 1;
  23. // If 1, OnPlayerCBug is called on cbug usages
  24. new alertCBugs = 1;
  25.  
  26.  
  27. // Callback forward
  28. forward OnPlayerCBug(playerid, interval);
  29.  
  30.  
  31. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  32. {  
  33.     // Avoid driveby false alarms
  34.     if (!IsPlayerInAnyVehicle(playerid) && (removeCBugs || alertCBugs))
  35.     {
  36.         // Only execute for deagle shots
  37.         if (weaponid == 24)
  38.         {
  39.             // Normal deagle shots shouldnt be faster than 700ms
  40.             // Check if time difference is positive to avoid GetTickCount-reset false alarms
  41.             if (GetTickCount() - lastDShot[playerid] < 700 && GetTickCount() - lastDShot[playerid] >= 0)
  42.             {              
  43.                 if (alertCBugs) CallLocalFunction("OnPlayerCBug", "ii", playerid, GetTickCount() - lastDShot[playerid]);
  44.                 return !removeCBugs;
  45.             }
  46.             lastDShot[playerid] = GetTickCount();
  47.         }
  48.     }
  49.     return CallLocalFunction("ACBUG_OnPlayerWeaponShot", "iiiifff", playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  50. }
  51. #if defined _ALS_OnPlayerWeaponShot
  52.     #undef OnPlayerWeaponShot
  53. #else
  54.     #define _ALS_OnPlayerWeaponShot
  55. #endif
  56. #define OnPlayerWeaponShot ACBUG_OnPlayerWeaponShot
  57. forward ACBUG_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
Advertisement
Add Comment
Please, Sign In to add comment