Advertisement
Kyance

SAMP - AImbot Detection ( v3.6 - Made by Kyance )

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