Advertisement
Kyance

SAMP - Aimbot Detection ( v4.0.0 )

Oct 30th, 2014
3,051
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.36 KB | None | 0 0
  1. //Made by Kyance, assisted by Threshold do NOT remove credits.
  2. //Version 4.0.0, fixed over 5 bugs since v1.0 BETA, and done over 10 improvements :p
  3.  
  4. //Previous update -> Fixed the aimbot giving out false results when a player is "surfing" a vehicle, AKA: Standing on a moving vehicle.
  5. //Latest update -> Attempting to improve performance ..
  6.  
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <foreach>
  10. #include <sscanf2>
  11. #include <callbacks>
  12.  
  13. #define COLOR_NOTES 0x2894FFFF
  14. #define COLOR_NOTES2 0xFF0000AA
  15. #define DIALOG_SUSPECTLIST 123
  16. #define BULLET_HIT_TYPE_PLAYER 1
  17. #define PUB:%0(%1)  forward %0(%1); \
  18.                     public %0(%1)
  19. //------------------------------ VARIABLES ---------------------------------------
  20. new
  21.     bool: DetectedForAimbot[ MAX_PLAYERS char ],
  22.     bool: IsAFK[ MAX_PLAYERS char ],
  23.     bool: CoolDown[ MAX_PLAYERS char ],
  24.     TimesDetected[ MAX_PLAYERS ] = 0,
  25.     ToggleCoolDown[ MAX_PLAYERS ]
  26. ;
  27.  
  28. #if defined FILTERSCRIPT
  29.  
  30.  
  31. public OnFilterScriptInit()
  32. {
  33.     print("\n [abd] Aimbot Detection fs loaded\n [abd] Version: 4.0.0(DEBUG MODE)\n [abd] Created by: Kyance");
  34.     return 1;
  35. }
  36. public OnFilterScriptExit()
  37. {
  38.     foreach(Player, i) ResetStats(i);
  39.     print("\n [abd] Aimbot Detection fs unloaded\n [abd] Version: 4.0.0(DEBUG MODE)\n [abd] Created by: Kyance");
  40.     return 1;
  41. }
  42. #endif
  43. //------------------------------ CALLBACKS ----------------------------------
  44. public OnPlayerPause(playerid)
  45. {
  46.     IsAFK{ playerid } = true;
  47.     return 1;
  48. }
  49. public OnPlayerResume(playerid, time)
  50. {
  51.     IsAFK{ playerid } = false;
  52.     return 1;
  53. }
  54. public OnPlayerConnect(playerid)
  55. {
  56.     ResetStats(playerid);
  57.     return 1;
  58. }
  59. public OnPlayerDisconnect(playerid, reason)
  60. {
  61.     ResetStats(playerid);
  62.     return 1;
  63. }
  64. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  65. {
  66.     if(issuerid != INVALID_PLAYER_ID)
  67.     {
  68.         if(!CoolDown{ playerid } && ToggleCoolDown[issuerid]) CoolDown{ issuerid } = true, SetTimerEx("ResetCoolDown", 2500, false, "i", issuerid);
  69.     }
  70.     return 1;
  71. }
  72. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  73. {
  74.     if(hittype == BULLET_HIT_TYPE_PLAYER && !IsPlayerNPC(hitid))
  75.     {
  76.         if(!IsAFK{ hitid } && !CoolDown{ playerid })
  77.         {
  78.             new surf = GetPlayerSurfingVehicleID(playerid), tsurf = GetPlayerSurfingVehicleID(hitid);
  79.             if(surf == INVALID_VEHICLE_ID && tsurf == INVALID_VEHICLE_ID && !IsPlayerInAnyVehicle(hitid))
  80.             {
  81.                 new
  82.                     Float:targetpkl = NetStats_PacketLossPercent(hitid),
  83.                     Float:playerpkl = NetStats_PacketLossPercent(playerid)
  84.                 ;
  85.                 if(targetpkl < 0.8 && playerpkl < 0.8)
  86.                 {
  87.                     new Float:fOriginX, Float:fOriginY, Float:fOriginZ, Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
  88.                     GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
  89.                     CheckForAimbot(playerid, fHitPosX, fHitPosY, fHitPosZ, hitid);
  90.                 }
  91.                 else printf("[abd] skipping '%s' and(or) '%s' due to packetloss being above 0.8", GetName(playerid), GetName(hitid));
  92.             }
  93.             else printf("[abd] skipping '%s' and(or) '%s' due to valid surf-vehicle/in-vehicle", GetName(playerid), GetName(hitid));
  94.         }
  95.         else printf("[abd] skipping '%s' and(or) '%s' due to target being afk/player having cooldown", GetName(playerid), GetName(hitid));
  96.     }
  97.     return 1;
  98. }
  99. //------------------------------ STOCKs and TIMERs ----------------------------------
  100. stock CheckForAimbot(playerid, Float:fX, Float:fY, Float:fZ, attacked = INVALID_PLAYER_ID)
  101. {
  102.     if(attacked != INVALID_PLAYER_ID)
  103.     {
  104.         if(!IsPlayerInRangeOfPoint(attacked, 3.0, fX, fY, fZ))
  105.         {
  106.             TimesDetected[playerid]++;
  107.             printf("ABD: %s(IP: %s) has received %d/10 aimbot warnings.", GetName(playerid), PlayerIP(playerid), TimesDetected[playerid]);
  108.             new string[110];
  109.             if(TimesDetected[playerid] >= 3 && TimesDetected[playerid] <= 5)
  110.             {
  111.                 format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot (%d warnings)", GetName(playerid), playerid, playerid, playerid, TimesDetected[playerid]);
  112.                 SendClientMessageToAll(COLOR_NOTES2, string), string = "\0";
  113.                 DetectedForAimbot{ playerid } = true;
  114.             }
  115.             else if(TimesDetected[playerid] >= 10)
  116.             {
  117.                 format(string, sizeof(string), "KICK: %s(%d) has been auto-kicked for receiving 10 aimbot warnings.", GetName(playerid), playerid);
  118.                 SendClientMessageToAll(COLOR_NOTES2, string), string = "\0", Kick(playerid);
  119.                 printf("ABD: %s(IP: %s) has been kicked for receiving 8 aimbot warnings.", GetName(playerid), PlayerIP(playerid));
  120.             }
  121.             string = "\0";
  122.         }
  123.     }
  124.     else printf("[abd] error! 'attacked'(%d) was an invalid id!", attacked);
  125. }
  126. stock GetName(playerid)
  127. {
  128.     new pnameid[24];
  129.     GetPlayerName(playerid,pnameid,sizeof(pnameid));
  130.     return pnameid;
  131. }
  132. stock PlayerIP(playerid)
  133. {
  134.     new str[16];
  135.     GetPlayerIp(playerid, str, sizeof(str));
  136.     return str;
  137. }
  138. PUB:ResetCoolDown(playerid)
  139. {
  140.     CoolDown{ playerid } = false;
  141.     SetTimerEx("ToggleCoolDownTimer", 3500, false, "i", playerid);
  142.     return 1;
  143. }
  144. PUB:ToggleCoolDownTimer(playerid)
  145. {
  146.     ToggleCoolDown[playerid] = 1;
  147.     return 1;
  148. }
  149.  
  150. stock ResetStats(playerid)
  151. {
  152.     CoolDown{ playerid } = false, DetectedForAimbot{ playerid } = false, IsAFK{ playerid } = false;
  153.     ToggleCoolDown[playerid] = 1, TimesDetected[playerid] = 0;
  154. }
  155. //------------------------------ COMMANDS ----------------------------------
  156. CMD:suspects(playerid, params[]) {
  157.     new count = 0, string1[48], string2[320];
  158.     foreach(Player, i)
  159.     {
  160.         if(DetectedForAimbot{ i })
  161.         {
  162.             count++;
  163.             format(string2, sizeof(string2), "%s\n{FC4949}%s{FFFFFF}({FC4949}%d{FFFFFF})", string2, GetName(i), i);
  164.         }
  165.     }
  166.     format(string1, sizeof(string1), "{FC4949}%d {FFFFFF}suspects detected", count);
  167.    
  168.     if(count) ShowPlayerDialog(playerid, DIALOG_SUSPECTLIST, DIALOG_STYLE_LIST, string1, string2, "Close", "");
  169.     else ShowPlayerDialog(playerid, DIALOG_SUSPECTLIST, DIALOG_STYLE_LIST, "0 suspects detected", "No aimboters have been detected.", "Close", "");
  170.     string1 = "\0", string2 = "\0";
  171.     return 1;
  172. }
  173.  
  174. CMD:clearsuspects(playerid, params[]) {
  175.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_NOTES2, "* You're not an admin!");
  176.     foreach(Player, i) ResetStats(i);
  177.     SendClientMessage(playerid, COLOR_NOTES, "* Suspect list successfully cleared!");
  178.     return 1;
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement