Kyance

SAMP - Aimbot Detection ( v3.6.1 - Made by Kyance )

Jul 23rd, 2014
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.04 KB | None | 0 0
  1. //Made by Kyance, assisted by Threshold do NOT remove credits.
  2. //Version 3.6.1, fixed over 5 bugs since v1.0 BETA :p
  3.  
  4. //Latest update -> Fixed the aimbot giving out false results when a player is "surfing" a vehicle, AKA: Standing on a moving vehicle.
  5.  
  6. #include <a_samp>
  7. #include <zcmd>
  8. #include <foreach>
  9. #include <sscanf2>
  10. #include <callbacks>
  11.  
  12. #define COLOR_NOTES 0x2894FFFF
  13. #define COLOR_NOTES2 0xFF0000AA
  14. #define COLOR_RED 0xAA3333AA
  15.  
  16. #define DIALOG_SUSPECTLIST 123
  17.  
  18. #define BULLET_HIT_TYPE_NONE                0
  19. #define BULLET_HIT_TYPE_PLAYER              1
  20. #define BULLET_HIT_TYPE_VEHICLE             2
  21. #define BULLET_HIT_TYPE_OBJECT              3
  22. #define BULLET_HIT_TYPE_PLAYER_OBJECT       4
  23.  
  24. #if defined FILTERSCRIPT
  25.  
  26.  
  27. public OnFilterScriptInit()
  28. {
  29.     print("\n [abd] Aimbot Detection fs loaded\n [abd] Version: 3.6.1\n [abd] Created by: Kyance");
  30.     HitMarkersCreated = 0;
  31.     foreach(Player, i)
  32.     {
  33.         DetectedForAimbot{ i } = false;
  34.         HitMarkerEnabled[i] = 0;
  35.         CoolDown[i] = 0;
  36.         ToggleCoolDown[i] = 1;
  37.         TimesShot[i] = 0;
  38.         TimesDetected[i] = 0;
  39.         DestroyPlayerObject(i, HitMarker[i]);
  40.     }
  41.     GameTextForAll("~n~~n~~n~~n~~n~~n~~n~~n~~w~Aimbot Detector~n~~g~ON", 3000, 5);
  42.     return 1;
  43. }
  44.  
  45. public OnFilterScriptExit()
  46. {
  47.     print("\n [abd] Aimbot Detection fs unloaded\n [abd] Version: 3.6.1\n [abd] Created by: Kyance");
  48.     foreach(Player, x)
  49.     {
  50.         DestroyPlayerObject(x, HitMarker[x]);
  51.     }
  52.     GameTextForAll("~n~~n~~n~~n~~n~~n~~n~~n~~w~Aimbot Detector~n~~r~OFF", 3000, 5);
  53.     return 1;
  54. }
  55.  
  56. #endif
  57.  
  58. //------------------------------ VARIABLES ---------------------------------------
  59.  
  60. new
  61.     bool: DetectedForAimbot[ MAX_PLAYERS char ],
  62.     bool: IsAFK[ MAX_PLAYERS char ],
  63.     TimesDetected[ MAX_PLAYERS ] = 0,
  64.     HitMarker[ MAX_PLAYERS ],
  65.     HitMarkerEnabled[ MAX_PLAYERS ],
  66.     CoolDown[ MAX_PLAYERS ],
  67.     ToggleCoolDown[ MAX_PLAYERS ],
  68.     TimesShot[ MAX_PLAYERS ],
  69.     HitMarkersCreated
  70. ;
  71.  
  72. //------------------------------ CALLBACKS ----------------------------------
  73.  
  74. public OnPlayerPause(playerid)
  75. {
  76.     IsAFK{ playerid } = true;
  77.     return 1;
  78. }
  79. public OnPlayerResume(playerid, time)
  80. {
  81.     IsAFK{ playerid } = false;
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerConnect(playerid)
  86. {
  87.     DetectedForAimbot{ playerid } = false, IsAFK{ playerid } = false;
  88.     HitMarkerEnabled[playerid] = 0;
  89.     CoolDown[playerid] = 1;
  90.     ToggleCoolDown[playerid] = 0;
  91.     TimesShot[playerid] = 0;
  92.     TimesDetected[playerid] = 0;
  93.     DestroyPlayerObject(playerid, HitMarker[playerid]);
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerDisconnect(playerid, reason)
  98. {
  99.     DetectedForAimbot{ playerid } = false;
  100.     HitMarkerEnabled[playerid] = 0;
  101.     CoolDown[playerid] = 0;
  102.     TimesShot[playerid] = 0;
  103.     DestroyPlayerObject(playerid, HitMarker[playerid]);
  104.     return 1;
  105. }
  106.  
  107. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  108. {
  109.     if(issuerid != INVALID_PLAYER_ID)
  110.     {
  111.         if(!CoolDown[issuerid] && ToggleCoolDown[issuerid])
  112.         {
  113.             CoolDown[issuerid] = 1;
  114.             SetTimerEx("ResetCoolDown", 2500, false, "i", issuerid);
  115.         }
  116.     }
  117.     return 1;
  118. }
  119. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  120. {
  121.     new Float:X, Float:Y, Float:Z;
  122.     GetPlayerPos(playerid, X, Y, Z);
  123.     TimesShot[playerid]++;
  124.     if(HitMarkerEnabled[playerid] && HitMarkersCreated < 150)
  125.     {
  126.         foreach(Player, i)
  127.         {
  128.             if(GetPlayerState(i) == PLAYER_STATE_SPECTATING)
  129.             {
  130.                 if(IsPlayerInRangeOfPoint(i, 60, X, Y, Z))
  131.                 {
  132.                     HitMarker[i] = CreatePlayerObject(i, 19282, fX, fY, fZ, 0, 0, 0);
  133.                     SetTimerEx("RemoveHitMarker", 2700, false, "ii", i, HitMarker[i]);
  134.                     HitMarkersCreated++;
  135.                 }
  136.             }
  137.         }
  138.     }
  139.     if(hittype == BULLET_HIT_TYPE_PLAYER && !IsPlayerNPC(hitid))
  140.     {
  141.         if(!IsAFK{ hitid })
  142.         {
  143.             if(!CoolDown[playerid] && TimesShot[playerid] >= 1)
  144.             {
  145.                 new surf = GetPlayerSurfingVehicleID(playerid);
  146.                 if(surf == INVALID_VEHICLE_ID)
  147.                 {
  148.                     new Float:fOriginX, Float:fOriginY, Float:fOriginZ, Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
  149.                     GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
  150.                     CheckForAimbot(playerid, fHitPosX, fHitPosY, fHitPosZ, hitid);
  151.                 }
  152.             }
  153.         }
  154.     }
  155.     return 1;
  156. }
  157.  
  158.  
  159. //------------------------------ STOCKs and TIMERs ----------------------------------
  160.  
  161. CheckForAimbot(playerid, Float:fX, Float:fY, Float:fZ, attacked = INVALID_PLAYER_ID)
  162. {
  163.     if(attacked != INVALID_PLAYER_ID)
  164.     {
  165.         if(!IsPlayerInRangeOfPoint(attacked, 3.0, fX, fY, fZ))
  166.         {
  167.             TimesDetected[playerid]++;
  168.             printf("ABD: %s(IP: %s) has received %d/8 aimbot warnings.", GetName(playerid), PlayerIP(playerid));
  169.             new string[110];
  170.             if(TimesDetected[playerid] == 3)
  171.             {
  172.                 format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot. /spec %d and /atest %d to test him.", GetName(playerid), playerid, playerid, playerid);
  173.                 SendClientMessageToAll(COLOR_NOTES2, string), string = "\0";
  174.                 DetectedForAimbot{ playerid } = true;
  175.             }
  176.             else if(TimesDetected[playerid] >= 8)
  177.             {
  178.                 format(string, sizeof(string), "KICK: %s(%d) has been kicked for receiving 8 aimbot warnings.", GetName(playerid), playerid);
  179.                 SendClientMessageToAll(COLOR_NOTES2, string), string = "\0", Kick(playerid);
  180.                 printf("ABD: %s(IP: %s) has been kicked for receiving 8 aimbot warnings.", GetName(playerid), PlayerIP(playerid), playerid);
  181.             }
  182.         }
  183.     }
  184.     return 1;
  185. }
  186.  
  187. stock GetName(playerid)
  188. {
  189.     new pnameid[24];
  190.     GetPlayerName(playerid,pnameid,sizeof(pnameid));
  191.     return pnameid;
  192. }
  193. stock PlayerIP(playerid)
  194. {
  195.     new str[16];
  196.     GetPlayerIp(playerid, str, sizeof(str));
  197.     return str;
  198. }
  199.  
  200. forward ResetCoolDown(playerid);
  201. public ResetCoolDown(playerid)
  202. {
  203.     CoolDown[playerid] = 0;
  204.     TimesShot[playerid] = 0;
  205.     SetTimerEx("ToggleCoolDownTimer", 3500, false, "i", playerid);
  206.     return 1;
  207. }
  208.  
  209. forward ToggleCoolDownTimer(playerid);
  210. public ToggleCoolDownTimer(playerid)
  211. {
  212.     ToggleCoolDown[playerid] = 1;
  213.     return 1;
  214. }
  215.  
  216. forward RemoveHitMarker(playerid, objectid);
  217. public RemoveHitMarker(playerid, objectid)
  218. {
  219.     DestroyPlayerObject(playerid, objectid);
  220.     HitMarkersCreated--;
  221.     return 1;
  222. }
  223.  
  224.  
  225. //------------------------------ COMMANDS ----------------------------------
  226.  
  227. CMD:atest(playerid, params[]) {
  228.     new id, string[90];
  229.     //if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "* You're not an admin!");
  230.     if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_NOTES, "* /atest [ID]");
  231.     if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "* Invalid ID!");
  232.  
  233.     if(!HitMarkerEnabled[id])
  234.     {
  235.         HitMarkerEnabled[id] = 1;
  236.         format(string, sizeof(string), "* You will now see 'hit-markers' on %s.", GetName(id));
  237.         SendClientMessage(playerid, COLOR_NOTES, string);
  238.     }
  239.     else
  240.     {
  241.         HitMarkerEnabled[id] = 0;
  242.         format(string, sizeof(string), "* You will no longer see 'hit-markers' on %s.", GetName(id));
  243.         SendClientMessage(playerid, COLOR_NOTES, string);
  244.     }
  245.     string = "\0";
  246.     return 1;
  247. }
  248. CMD:suspects(playerid, params[]) {
  249.     new count = 0, string1[48], string2[248];
  250.     foreach(Player, i)
  251.     {
  252.         if(DetectedForAimbot{ i })
  253.         {
  254.             count++;
  255.             format(string1, sizeof(string1), "%d suspects detected", count);
  256.             format(string2, sizeof(string2), "%s\n%s( ID: %d )", string2, GetName(i), i);
  257.         }
  258.     }
  259.     if(count) ShowPlayerDialog(playerid, DIALOG_SUSPECTLIST, DIALOG_STYLE_LIST, string1, string2, "Close", "");
  260.     else ShowPlayerDialog(playerid, DIALOG_SUSPECTLIST, DIALOG_STYLE_LIST, "0 suspects detected", "No aimboters have been detected.", "Close", "");
  261.     string1 = "\0", string2 = "\0";
  262.     return 1;
  263. }
  264.  
  265. CMD:clearsuspects(playerid, params[]) {
  266.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "* You're not an admin!");
  267.     foreach(Player, i)
  268.     {
  269.         DetectedForAimbot{ i } = false;
  270.         TimesDetected[i] = 0;
  271.     }
  272.     SendClientMessage(playerid, COLOR_NOTES, "* Suspect list successfully cleared!");
  273.     return 1;
  274. }
Advertisement
Add Comment
Please, Sign In to add comment