Advertisement
Whitetigerswt

Autoaim detection v4

Dec 27th, 2011
7,609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.85 KB | None | 0 0
  1. /*
  2.     Autoaim detection script - NOT joypad.
  3.  
  4.         - By Whitetiger
  5.  
  6.         - Credits: Lorenc_, TheGamer!, [U]214
  7.  */
  8.  
  9. #include <a_samp>
  10.  
  11. #define DEBUG 0
  12.  
  13. new bool:autoaim[MAX_PLAYERS]                = {false, ...};
  14. new checkautoaim[MAX_PLAYERS]                = {9999, ...};
  15. new pressingaimtick[MAX_PLAYERS]             = {-1, ...};
  16. new bool:keyfire[MAX_PLAYERS]                = {false, ...};
  17. new bool:ispressingaimkey[MAX_PLAYERS]       = {false, ...};
  18. new bool:CheckNextAim[MAX_PLAYERS]           = {false, ...};
  19.  
  20. public OnFilterScriptInit() {
  21.     for(new i=0; i < MAX_PLAYERS; ++i) {
  22.         if(IsPlayerConnected(i)) {
  23.             OnPlayerConnect(i);
  24.         }
  25.     }
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerConnect(playerid) {
  30.     checkautoaim[playerid]     = 9999;
  31.     pressingaimtick[playerid]  = -1;
  32.     autoaim[playerid]          = false;
  33.     keyfire[playerid]          = false;
  34.     ispressingaimkey[playerid] = false;
  35.     CheckNextAim[playerid]     = false;
  36.  
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerUpdate(playerid) {
  41.     new var = GetPlayerTargetPlayer(playerid);
  42.     if(var != INVALID_PLAYER_ID) {
  43.         CheckNextAim[playerid] = true;
  44.     }
  45.     #if DEBUG == 1
  46.     new str[129];
  47.     format(str, sizeof(str), "%d", GetPlayerTargetPlayer(playerid));
  48.     SendClientMessage(playerid, -1, str);
  49.     #endif
  50.     if(checkautoaim[playerid] <= 10) {
  51.         if(var != INVALID_PLAYER_ID) {
  52.             checkautoaim[playerid] = 9999;
  53.         }
  54.         checkautoaim[playerid]++;
  55.         if(checkautoaim[playerid] == 11) {
  56.  
  57.             #if DEBUG == 1
  58.             new pname[MAX_PLAYER_NAME];
  59.             GetPlayerName(playerid, pname, sizeof(pname));
  60.             format(str, sizeof(str), "*** AUTOAIM WARNING - %s ***", pname);
  61.             SendClientMessageToAll(-1, str);
  62.             #endif
  63.             autoaim[playerid] = true;
  64.  
  65.             CallRemoteFunction("OnPlayerDetectedAutoaim", "d", playerid);
  66.         }
  67.     }
  68.     return 1;
  69. }
  70.  
  71.  
  72.  
  73. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) {
  74.  
  75.     new Float:X, Float:Y, Float:Z;
  76.     GetPlayerPos(damagedid, X, Y, Z);
  77.     new str[128];
  78.     format(str, sizeof(str), "%d == false %d < %d && %d != -1 && %d == 53 && %d == %d && %d == 1 && %d && %d == false", CheckNextAim[playerid], pressingaimtick[playerid], GetTickCount(), pressingaimtick[playerid], GetPlayerCameraMode(playerid), GetPlayerTargetPlayer(playerid), INVALID_PLAYER_ID, IsPlayerInRangeOfPoint(playerid, 50, X, Y, Z), notallowed(weaponid), keyfire[playerid]);
  79.     #if DEBUG == 1
  80.     SendClientMessage(playerid, -1, str);
  81.     #endif
  82.     printf(" Autoaim Detection information: %s", str);
  83.     if(CheckNextAim[playerid] == false && pressingaimtick[playerid] < GetTickCount() && pressingaimtick[playerid] != -1 && GetPlayerCameraMode(playerid) == 53 && GetPlayerTargetPlayer(playerid) == INVALID_PLAYER_ID && IsPlayerInRangeOfPoint(playerid, 50, X, Y, Z) == 1 && notallowed(weaponid) && keyfire[playerid] == false && !IsPlayerInAnyVehicle(damagedid)) {
  84.         checkautoaim[playerid] = 0;
  85.     }
  86. }
  87.  
  88. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  89. {
  90.     if(!(oldkeys & KEY_FIRE) && (newkeys & KEY_FIRE) && !(newkeys & KEY_HANDBRAKE)) {
  91.         keyfire[playerid] = true;
  92.     } else if(!(newkeys & KEY_FIRE)) keyfire[playerid] = false;
  93.     if(!ispressingaimkey[playerid]) CheckNextAim[playerid] = false;
  94.     ispressingaimkey[playerid] = !!(newkeys & KEY_HANDBRAKE);
  95.     if(ispressingaimkey[playerid] && !(oldkeys & KEY_HANDBRAKE)) {
  96.         pressingaimtick[playerid] = GetTickCount()+500;
  97.     }
  98.     return 1;
  99. }
  100.  
  101.  
  102. stock notallowed(weaponid) {
  103.     switch(weaponid) {
  104.  
  105.         case 25..27, 16..18, 34..37, 39..40, 43..200: return 0;
  106.         // Blocks shotguns, sniper rifle, RPG, heat seaker satchel charges etc - besides shotguns these are unaffected by autoaim
  107.         // the reason shotguns are removed from checking is because i've found them to be unreliable.
  108.         default:return 1;
  109.     }
  110.     return 1;
  111. }
  112.  
  113.  
  114. stock IsPlayerUsingAutoaim(playerid) return autoaim[playerid];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement