Advertisement
Kyance

SAMP - Silent Aimbot Detector (untested version)

Dec 21st, 2014
895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.51 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <foreach>
  4. #include <callbacks>
  5.  
  6. #define COLOR_NOTES 0x2894FFFF
  7. #define COLOR_NOTES2 0xFF0000AA
  8. #define BULLET_HIT_TYPE_PLAYER 1
  9. #define PUB:%0(%1)  forward %0(%1); \
  10.                     public %0(%1)
  11.  
  12. //------------------------------ VARIABLEs ---------------------------------------
  13.  
  14. new
  15.     bool:IsAFK[ MAX_PLAYERS char ],
  16.     TimesDetected[ MAX_PLAYERS ] = 0
  17. ;
  18.  
  19. //------------------------------ FILTERSCRIPT-CALLBACKs ---------------------------------------
  20.  
  21. #if defined FILTERSCRIPT
  22.  
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     print("\n[abd] Aimbot Detection enabled\n[abd] Version: 4.0.0\n[abd] Created by: Kyance");
  27.     return 1;
  28. }
  29. public OnFilterScriptExit()
  30. {
  31.     foreach(Player, i) ResetStats(i);
  32.     print("\n[abd] Aimbot Detection disabled\n[abd] Version: 4.0.0\n[abd] Created by: Kyance");
  33.     return 1;
  34. }
  35. #endif
  36.  
  37. //------------------------------ MAIN-CALLBACKs ----------------------------------
  38.  
  39. public OnPlayerPause(playerid)
  40. {
  41.     IsAFK{ playerid } = true;
  42.     return 1;
  43. }
  44. public OnPlayerResume(playerid, time)
  45. {
  46.     IsAFK{ playerid } = false;
  47.     return 1;
  48. }
  49. public OnPlayerConnect(playerid)
  50. {
  51.     ResetStats(playerid);
  52.     return 1;
  53. }
  54. public OnPlayerDisconnect(playerid, reason)
  55. {
  56.     ResetStats(playerid);
  57.     return 1;
  58. }
  59. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  60. {
  61.     if(hittype == BULLET_HIT_TYPE_PLAYER && !IsPlayerNPC(hitid))
  62.     {
  63.         if(!IsAFK{ hitid })
  64.         {
  65.             new
  66.                 surf = GetPlayerSurfingVehicleID(playerid),
  67.                 tsurf = GetPlayerSurfingVehicleID(hitid)
  68.             ;
  69.             if(surf == INVALID_VEHICLE_ID && tsurf == INVALID_VEHICLE_ID && !IsPlayerInAnyVehicle(hitid))
  70.             {
  71.                 new
  72.                     Float:targetpkl = NetStats_PacketLossPercent(hitid),
  73.                     Float:playerpkl = NetStats_PacketLossPercent(playerid)
  74.                 ;
  75.                 if(targetpkl < 0.8 && playerpkl < 0.8)
  76.                 {
  77.                     new
  78.                         Float:fOriginX, Float:fOriginY, Float:fOriginZ,
  79.                         Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ
  80.                     ;
  81.                     GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
  82.                     CheckForAimbot(playerid, hitid, fHitPosX, fHitPosY, fHitPosZ);
  83.                 }
  84.             }
  85.         }
  86.     }
  87.     return 1;
  88. }
  89.  
  90. //------------------------------ STOCKs and TIMERs ----------------------------------
  91.  
  92. stock CheckForAimbot(playerid, targetid = INVALID_PLAYER_ID, Float:fX, Float:fY, Float:fZ)
  93. {
  94.     if(targetid != INVALID_PLAYER_ID)
  95.     {
  96.         if(!IsPlayerInRangeOfPoint(targetid, 3.0, fX, fY, fZ))
  97.         {
  98.             new string[78];
  99.             TimesDetected[playerid]++;
  100.             printf("[abd] %s(%s) has %d/10 aimbot warnings.", GetName(playerid), PlayerIP(playerid), TimesDetected[playerid]);
  101.             if(TimesDetected[playerid] >= 3 && TimesDetected[playerid] <= 5)
  102.             {
  103.                 format(string, sizeof(string), "* %s(%d) is POSSIBLY using aimbot - %d warnings", GetName(playerid), playerid, playerid, playerid, TimesDetected[playerid]);
  104.                 SendClientMessageToAll(COLOR_NOTES2, string);
  105.             }
  106.             else if(TimesDetected[playerid] >= 10)
  107.             {
  108.                 format(string, sizeof(string), "* %s(%d) is kicked for receiving 10 aimbot warnings.", GetName(playerid), playerid);
  109.                 SendClientMessageToAll(COLOR_NOTES2, string), printf("[abd] %s(%s) has been kicked for receiving 10 aimbot warnings.", GetName(playerid), PlayerIP(playerid));
  110.                 Kick(playerid);
  111.             }
  112.         }
  113.     }
  114. }
  115. stock GetName(playerid)
  116. {
  117.     new name[24];
  118.     GetPlayerName(playerid,name,sizeof(name));
  119.     return name;
  120. }
  121. stock PlayerIP(playerid)
  122. {
  123.     new ip[16];
  124.     GetPlayerIp(playerid, ip, sizeof(ip));
  125.     return ip;
  126. }
  127. stock ResetStats(playerid)
  128. {
  129.     IsAFK{ playerid } = false;
  130.     TimesDetected[playerid] = 0;
  131. }
  132.  
  133. //------------------------------ COMMANDs ----------------------------------
  134.  
  135. CMD:suspects(playerid, params[]) {
  136.     new count = 0, string[64];
  137.     SendClientMessage(playerid, -1, "[ Suspect List ]");
  138.     foreach(Player, i)
  139.     {
  140.         if(TimesDetected[i] >= 3)
  141.         {
  142.             count++;
  143.             format(string, sizeof(string), "{FC4949}%s{FFFFFF}({FC4949}%d{FFFFFF})", GetName(i), i);
  144.             SendClientMessage(playerid, -1, string);
  145.         }
  146.     }
  147.     if(!count) SendClientMessage(playerid, -1, "No suspects detected.");
  148.     return 1;
  149. }
  150.  
  151. CMD:clearsuspects(playerid, params[]) {
  152.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_NOTES2, "* You're not an admin!");
  153.     foreach(Player, i)
  154.     {
  155.         ResetStats(i);
  156.     }
  157.     SendClientMessage(playerid, COLOR_NOTES, "* Suspect list successfully cleared!");
  158.     return 1;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement