Advertisement
YashasSamaga

[SAMP]Bust-Aim:Anti-Aimbot

Apr 15th, 2015
1,834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 25.51 KB | None | 0 0
  1. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //BUST AIM
  3. //
  4. //BustAim is an feature rich include which tries to detect players with aimbots.It by itself cannot be for sure if the player
  5. //is using aimbot.It is designed to trigger warnings and provide administrators with vital information about the suspect.
  6. //BustAim tries its level best to detect players who are using aimbots.This include while detecting players for aimbots
  7. //sometimes also detects some miscellaneous hacks.
  8. //
  9. //License:Public Domain
  10. //
  11. //Credits:
  12. //Yashas
  13. //RedShirt & niCe & JernejL for camera/aiming functions
  14. //ipsLeon & Kyance for their aimbot detectors
  15. //Pottus for constructive criticism
  16. //Slice for the information regarding Maximum Weapon Firing Range
  17. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  18. //Callbacks:
  19. //  OnPlayerSuspectedForAimbot(playerid,hitid,weaponid,warnings)
  20. //
  21. //Stocks:
  22. //  native BustAim::GetPlayerWeaponProfile(playerid,weaponid,&allshots,&hitshots,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns,&backward_shot_warns);
  23. //  native BustAim::ResetPlayerWeaponProfile(playerid,weaponid);
  24. //  native BustAim::GetPlayerProfile(playerid,&shotsfired,&shotshit,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns,&backward_shot_warns);
  25. //  native BustAim::ResetPlayerProfile(playerid);
  26. //  native BustAim::SetPlayerFlags(playerid,flags);
  27. //  native BustAim::GetPlayerFlags(playerid,&flags);
  28. //  native BustAim::ResetPlayerFlags(playerid);
  29. //  native BustAim::GetTeleportStats(playerid,Float:arr[],sz = sizeof(arr));
  30. //  native BustAim::GetAimStats(playerid,Float:arr[],sz = sizeof(arr))
  31. //  native BustAim::GetRangeStats(playerid,Float:arr[],sz = sizeof(arr))
  32. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. #if defined _INCLUDE_BUSTAIM_
  34.     #endinput
  35. #endif
  36. #define _INCLUDE_BUSTAIM_
  37. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  38. #define BustAim:: BS_
  39.  
  40. #if !defined BUSTAIM_MAX_PL_PERCENTAGE
  41.     #define BUSTAIM_MAX_PL_PERCENTAGE 2.5
  42. #endif
  43. #if !defined BUSTAIM_MAX_PING
  44.     #define BUSTAIM_MAX_PING 400
  45. #endif
  46. #if !defined BUSTAIM_SKIP_WEAPON_IDS
  47.     #define BUSTAIM_SKIP_WEAPON_IDS 38
  48. #endif
  49. #if !defined BUSTAIM_MAX_CONTINOUS_SHOTS
  50.     #define BUSTAIM_MAX_CONTINOUS_SHOTS 10
  51. #endif
  52. #if !defined BUSTAIM_OUT_OF_RANGE_PROBES
  53.     #define BUSTAIM_OUT_OF_RANGE_PROBES 4
  54. #endif
  55. #if !defined BUSTAIM_PROAIM_TELEPORT_PROBES
  56.     #define BUSTAIM_PROAIM_TELEPORT_PROBES 3
  57. #endif
  58. #if !defined BUSTAIM_BACKWARD_SHOTS_PROBES
  59.     #define BUSTAIM_BACKWARD_SHOTS_PROBES 2
  60. #endif
  61. #if !defined BUSTAIM_RANDOM_AIM_PROBES
  62.     #define BUSTAIM_RANDOM_AIM_PROBES 5
  63. #endif
  64. #if !defined MIN_DIST_FOR_TELEPORT_CHECKS
  65.     #define MIN_DIST_FOR_TELEPORT_CHECKS 5
  66. #endif
  67. #if !defined MIN_DIST_FOR_AIM_CHECKS
  68.     #define MIN_DIST_FOR_AIM_CHECKS 5
  69. #endif
  70. #if !defined MAX_B2V_DEVIATION
  71.     #define MAX_B2V_DEVIATION 10
  72. #endif
  73. #if !defined BUSTAIM_PLAYER_SPHERE_RADIUS
  74.     #define BUSTAIM_PLAYER_SPHERE_RADIUS 3
  75. #endif
  76. #if !defined BUSTAIM_DEFAULT_PLAYER_FLAGS
  77.     #define BUSTAIM_DEFAULT_PLAYER_FLAGS (CHECK_FOR_OUT_OF_RANGE_SHOTS  |   CHECK_FOR_PROAIM_TELEPORT   |   CHECK_FOR_RANDOM_AIM_SHOTS  |   CHECK_FOR_BACKWARD_SHOTS |  CHECK_FOR_CONTINOUS_SHOTS)
  78. #endif
  79. #if !defined BUSTAIM_WSTATS_SHOTS
  80.     #define BUSTAIM_WSTATS_SHOTS 3
  81. #endif
  82.  
  83. //DO NOT CHANGE THIS
  84. #define BS_TOTAL_SHOOTING_WEAPONS 17 //includes RPG,HS,FT
  85. #if BS_TOTAL_SHOOTING_WEAPONS != 17
  86.     #error BS_TOTAL_SHOOTING_WEAPONS should always be set to 17
  87. #endif
  88.  
  89. #define BS_GetNormalWeaponRange(weaponid) BustAim_g_WeaponRangeOriginal[weaponid-22]
  90. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  91. forward OnPlayerSuspectedForAimbot(playerid,hitid,weaponid,warnings);
  92. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  93. enum (<<=1)
  94. {
  95.     WARNING_OUT_OF_RANGE_SHOT=1,
  96.     WARNING_PROAIM_TELEPORT,
  97.     WARNING_RANDOM_AIM,
  98.     WARNING_BACKWARD_SHOT,
  99.     WARNING_CONTINOUS_SHOTS
  100. }
  101. enum (<<=1)
  102. {
  103.     PREVIOUS_SHOT_DID_DAMAGE=1,
  104. }
  105. enum (<<=1)
  106. {
  107.     CHECK_FOR_OUT_OF_RANGE_SHOTS=1,
  108.     CHECK_FOR_PROAIM_TELEPORT,
  109.     CHECK_FOR_RANDOM_AIM_SHOTS,
  110.     CHECK_FOR_BACKWARD_SHOTS,
  111.     CHECK_FOR_CONTINOUS_SHOTS,
  112.     IGNORE_PLAYER
  113. }
  114. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  115. //Modified Slice's Max Weapon Ranges from Weapon Config Include (Added 10 units extra for every weapon to make allowance for lagging players)
  116. static const Float:BustAim_g_WeaponRange[] =
  117. {
  118.     45.0, // 22 - Colt 45
  119.     45.0, // 23 - Silenced
  120.     45.0, // 24 - Deagle
  121.     50.0, // 25 - Shotgun
  122.     45.0, // 26 - Sawed-off
  123.     50.0, // 27 - Spas
  124.     45.0, // 28 - UZI
  125.     55.0, // 29 - MP5
  126.     100.0, // 30 - AK47
  127.     120.0, // 31 - M4
  128.     45.0, // 32 - Tec9
  129.     110.0, // 33 - Cuntgun
  130.     320.0, // 34 - Sniper
  131.     0.0, // 35 - Rocket launcher
  132.     0.0, // 36 - Heatseeker
  133.     0.0, // 37 - Flamethrower
  134.     85.0  // 38 - Minigun
  135. };
  136. //Original Slice's Max Weapon Ranges'
  137. new const Float:BustAim_g_WeaponRangeOriginal[] =
  138. {
  139.     35.0, // 22 - Colt 45
  140.     35.0, // 23 - Silenced
  141.     35.0, // 24 - Deagle
  142.     40.0, // 25 - Shotgun
  143.     35.0, // 26 - Sawed-off
  144.     40.0, // 27 - Spas
  145.     35.0, // 28 - UZI
  146.     45.0, // 29 - MP5
  147.     70.0, // 30 - AK47
  148.     90.0, // 31 - M4
  149.     35.0, // 32 - Tec9
  150.     100.0, // 33 - Cuntgun
  151.     320.0, // 34 - Sniper
  152.     0.0, // 35 - Rocket launcher
  153.     0.0, // 36 - Heatseeker
  154.     0.0, // 37 - Flamethrower
  155.     75.0  // 38 - Minigun
  156. };
  157. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  158. static BustAim_g_PlayerSettings[MAX_PLAYERS char];
  159. static BustAim_g_PlayerPrevWeapon[MAX_PLAYERS char];
  160.  
  161. static BustAim_g_IntrnlPlayerSettings[MAX_PLAYERS char];
  162.  
  163. static BustAim_g_ContinousShots[MAX_PLAYERS char];
  164. static BustAim_g_RandomAimShots[MAX_PLAYERS char];
  165. static BustAim_g_TeleportShots[MAX_PLAYERS char];
  166. static BustAim_g_OutOfRangeShots[MAX_PLAYERS char];
  167. static BustAim_g_BackwardShot[MAX_PLAYERS char];
  168.  
  169. #if !defined BUSTAIM_DISABLE_PROFILING
  170. static BustAim_g_TotalRandomAimWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  171. static BustAim_g_TotalTeleportWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  172. static BustAim_g_TotalBackwardWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  173. static BustAim_g_TotalOutOfRangeWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  174. static BustAim_g_MaxContinousShots[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  175. static BustAim_g_ShotsFired[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  176. static BustAim_g_ShotsHit[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  177. #endif
  178.  
  179. #if !defined BUSTAIM_DISABLE_WSTATS
  180. static Float:BustAim_g_TeleportWarningStats[MAX_PLAYERS][BUSTAIM_WSTATS_SHOTS];
  181. static Float:BustAim_g_AimWarningStats[MAX_PLAYERS][BUSTAIM_WSTATS_SHOTS];
  182. static Float:BustAim_g_RangeWarningStats[MAX_PLAYERS][BUSTAIM_WSTATS_SHOTS];
  183. static Float:BustAim_g_DCTTL_temp;
  184. #endif
  185.  
  186. #if !defined BUSTAIM_IS_PAUSED_FUNCTION
  187. static BustAim_g_LastUpdateTick[MAX_PLAYERS];
  188. #endif
  189. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  190. static Float:internal_BS_DCTTL(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
  191. {
  192.     static Float:TGTDistance,Float:tmpX, Float:tmpY, Float:tmpZ;
  193.     TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
  194.  
  195.     tmpX = FrX * TGTDistance + CamX;
  196.     tmpY = FrY * TGTDistance + CamY;
  197.     tmpZ = FrZ * TGTDistance + CamZ;
  198.  
  199.     return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
  200. }
  201. static Float:internal_BS_GPATP(Float:x2, Float:y2, Float:X, Float:Y)
  202. {
  203.     static Float:DX, Float:DY,Float:angle;
  204.  
  205.     DX = floatabs(floatsub(x2,X));
  206.     DY = floatabs(floatsub(y2,Y));
  207.  
  208.     if (DY == 0.0 || DX == 0.0)
  209.     {
  210.         if(DY == 0 && DX > 0) angle = 0.0;
  211.         else if(DY == 0 && DX < 0) angle = 180.0;
  212.         else if(DY > 0 && DX == 0) angle = 90.0;
  213.         else if(DY < 0 && DX == 0) angle = 270.0;
  214.         else if(DY == 0 && DX == 0) angle = 0.0;
  215.     }
  216.     else
  217.     {
  218.         angle = atan(DX/DY);
  219.  
  220.         if(X > x2 && Y <= y2) angle += 90.0;
  221.         else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
  222.         else if(X < x2 && Y >= y2) angle -= 90.0;
  223.         else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
  224.     }
  225.     return floatadd(angle, 90.0);
  226. }
  227. static internal_BS_GXYIFOP(&Float:x, &Float:y, Float:angle, Float:distance)
  228. {
  229.     x += (distance * floatsin(-angle, degrees));
  230.     y += (distance * floatcos(-angle, degrees));
  231. }
  232. static internal_BS_IsCameraAimingAt(weaponid,Float:x, Float:y, Float:z,Float:vector_x,Float:vector_y,Float:vector_z,Float:camera_x,Float:camera_y,Float:camera_z,Float:radius)
  233. {
  234.     static Float:vertical, Float:horizontal;
  235.     switch (weaponid)
  236.     {
  237.         case 34,35,36:
  238.         {
  239.             if (internal_BS_DCTTL(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
  240.             return false;
  241.         }
  242.         case 30,31: {vertical = 4.0; horizontal = -1.6;}
  243.         case 33: {vertical = 2.7; horizontal = -1.0;}
  244.         default: {vertical = 6.0; horizontal = -2.2;}
  245.     }
  246.     new Float:angle = internal_BS_GPATP(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
  247.     new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
  248.  
  249.     internal_BS_GXYIFOP(resize_x, resize_y, internal_BS_GPATP(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));
  250.     #if !defined BUSTAIM_DISABLE_WSTATS
  251.         if ((BustAim_g_DCTTL_temp = internal_BS_DCTTL(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z)) < radius) return true;
  252.     #else
  253.         if (internal_BS_DCTTL(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
  254.     #endif
  255.     return false;
  256. }
  257. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  258. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  259. {
  260.     static Float:pX,Float:pY,Float:pZ,Float:hX,Float:hY,Float:hZ,Float:cX,Float:cY,Float:cZ;
  261.  
  262.     #if !defined BUSTAIM_DISABLE_PROFILING
  263.         BustAim_g_ShotsFired[playerid][weaponid-22]++;
  264.     #endif
  265.  
  266.     if(hittype == BULLET_HIT_TYPE_PLAYER)
  267.     {
  268.         #if !defined BUSTAIM_DISABLE_PROFILING
  269.             BustAim_g_ShotsHit[playerid][weaponid-22]++;
  270.         #endif
  271.         if(BustAim_g_PlayerSettings{playerid} & IGNORE_PLAYER)
  272.             #if defined BustAim_OnPlayerWeaponShot
  273.                 return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  274.             #else
  275.                 return 1;
  276.             #endif
  277.  
  278.         if(BustAim_g_PlayerPrevWeapon{playerid} != weaponid)
  279.         {
  280.             BustAim_g_ContinousShots{playerid} =
  281.             BustAim_g_RandomAimShots{playerid} =
  282.             BustAim_g_TeleportShots{playerid} =
  283.             BustAim_g_OutOfRangeShots{playerid} =
  284.             BustAim_g_BackwardShot{playerid} = 0;
  285.  
  286.             BustAim_g_PlayerPrevWeapon{playerid} = weaponid;
  287.         }
  288.  
  289.         //if(IsPlayerNPC(hitid))
  290.         //      #if defined BustAim_OnPlayerWeaponShot
  291.         //      return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  292.         //#else
  293.         //  return 1;
  294.         //#endif
  295.  
  296.         #if defined BUSTAIM_IS_PAUSED_FUNCTION
  297.             if(BUSTAIM_IS_PAUSED_FUNCTION(hitid))
  298.             #if defined BustAim_OnPlayerWeaponShot
  299.                     return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  300.             #else
  301.                 return 1;
  302.             #endif
  303.         #else
  304.             if((GetTickCount() - BustAim_g_LastUpdateTick[hitid]) > 1000)
  305.             #if defined BustAim_OnPlayerWeaponShot
  306.                     return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  307.             #else
  308.                 return 1;
  309.             #endif
  310.         #endif
  311.  
  312.         if(NetStats_PacketLossPercent(playerid) > BUSTAIM_MAX_PL_PERCENTAGE ||  NetStats_PacketLossPercent(hitid) > BUSTAIM_MAX_PL_PERCENTAGE)
  313.             #if defined BustAim_OnPlayerWeaponShot
  314.                 return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  315.             #else
  316.                 return 1;
  317.             #endif
  318.  
  319.         if(GetPlayerPing(playerid) > BUSTAIM_MAX_PING ||  GetPlayerPing(hitid) > BUSTAIM_MAX_PING)
  320.             #if defined BustAim_OnPlayerWeaponShot
  321.                 return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  322.             #else
  323.                 return 1;
  324.             #endif
  325.  
  326.         if(IsPlayerInAnyVehicle(playerid) || IsPlayerInAnyVehicle(hitid))
  327.             #if defined BustAim_OnPlayerWeaponShot
  328.                 return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  329.             #else
  330.                 return 1;
  331.             #endif
  332.  
  333.         if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID || GetPlayerSurfingVehicleID(hitid) != INVALID_VEHICLE_ID)
  334.             #if defined BustAim_OnPlayerWeaponShot
  335.                 return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  336.             #else
  337.                 return 1;
  338.             #endif
  339.                
  340.         switch(weaponid)
  341.         {
  342.             case BUSTAIM_SKIP_WEAPON_IDS:
  343.             {
  344.                 #if defined BustAim_OnPlayerWeaponShot
  345.                     return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  346.                 #else
  347.                     return 1;
  348.                 #endif
  349.             }
  350.         }
  351.         new warning = 0;
  352.        
  353.         GetPlayerVelocity(hitid,pX,pY,pZ);
  354.        
  355.         if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_CONTINOUS_SHOTS)
  356.             if((pX*pX + pY*pY + pZ*pZ) > 0.01)
  357.                 if(!(++BustAim_g_ContinousShots{playerid} % BUSTAIM_MAX_CONTINOUS_SHOTS))
  358.                     warning |= WARNING_CONTINOUS_SHOTS;
  359.        
  360.         GetPlayerPos(hitid,hX,hY,hZ);
  361.         GetPlayerLastShotVectors(playerid,pX,pY,pZ,cX,cY,cZ);
  362.  
  363.         new Float:S2V_dist = VectorSize(pX-hX,pY-hY,pZ-hZ); //Shooter to Victim Distance
  364.        
  365.         if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_OUT_OF_RANGE_SHOTS)
  366.         {
  367.             if(S2V_dist > BustAim_g_WeaponRange[weaponid-22])
  368.             {
  369.                 #if !defined BUSTAIM_DISABLE_WSTATS
  370.                     BustAim_g_RangeWarningStats[playerid][BustAim_g_OutOfRangeShots{playerid}%BUSTAIM_WSTATS_SHOTS] = S2V_dist;
  371.                 #endif
  372.                 if(BustAim_g_IntrnlPlayerSettings{playerid} & PREVIOUS_SHOT_DID_DAMAGE) //Was [] before instead of {} - Bug found by Su37Erich
  373.                 {
  374.                     if(++BustAim_g_OutOfRangeShots{playerid} > BUSTAIM_OUT_OF_RANGE_PROBES)
  375.                     {
  376.                         BustAim_g_OutOfRangeShots{playerid} = 0;
  377.                         #if !defined BUSTAIM_DISABLE_PROFILING
  378.                             BustAim_g_TotalOutOfRangeWarns[playerid][weaponid-22]++;
  379.                         #endif
  380.                         warning |= WARNING_OUT_OF_RANGE_SHOT;
  381.                     }
  382.                     BustAim_g_IntrnlPlayerSettings{playerid} &= ~PREVIOUS_SHOT_DID_DAMAGE;
  383.                 }
  384.             }
  385.         }
  386.        
  387.         if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_PROAIM_TELEPORT)
  388.             if(S2V_dist > MIN_DIST_FOR_TELEPORT_CHECKS)
  389.                 if(VectorSize(cX-hX,cY-hY,cZ-hZ) > MAX_B2V_DEVIATION)
  390.                 {
  391.                     #if !defined BUSTAIM_DISABLE_WSTATS
  392.                         BustAim_g_TeleportWarningStats[playerid][BustAim_g_TeleportShots{playerid}%BUSTAIM_WSTATS_SHOTS] = VectorSize(cX-hX,cY-hY,cZ-hZ);
  393.                     #endif
  394.                     if(++BustAim_g_TeleportShots{playerid} > BUSTAIM_PROAIM_TELEPORT_PROBES)
  395.                     {
  396.                         BustAim_g_TeleportShots{playerid} = 0;
  397.                         #if !defined BUSTAIM_DISABLE_PROFILING
  398.                             BustAim_g_TotalTeleportWarns[playerid][weaponid-22]++;
  399.                         #endif
  400.                         warning |= WARNING_PROAIM_TELEPORT;
  401.                     }
  402.                 }
  403.                
  404.         GetPlayerCameraFrontVector(playerid,pX,pY,pZ);
  405.         GetPlayerCameraPos(playerid,cX,cY,cZ);
  406.  
  407.         if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_BACKWARD_SHOTS)
  408.             if(VectorSize(pX + cX  - hX,pY + cY - hY,pZ + cZ - hZ) > VectorSize(cX-hX,cY-hY,cZ-hZ))
  409.                 if(++BustAim_g_BackwardShot{playerid} > BUSTAIM_BACKWARD_SHOTS_PROBES)
  410.                 {
  411.                     BustAim_g_BackwardShot{playerid} = 0;
  412.                     #if !defined BUSTAIM_DISABLE_PROFILING
  413.                         BustAim_g_TotalBackwardWarns[playerid][weaponid-22]++;
  414.                     #endif
  415.                     warning |= WARNING_BACKWARD_SHOT;
  416.                 }
  417.  
  418.         if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_RANDOM_AIM_SHOTS)
  419.             if(S2V_dist > MIN_DIST_FOR_AIM_CHECKS)
  420.                 if(!internal_BS_IsCameraAimingAt(weaponid,hX,hY,hZ,pX,pY,pZ,cX,cY,cZ,BUSTAIM_PLAYER_SPHERE_RADIUS))
  421.                 {
  422.                     #if !defined BUSTAIM_DISABLE_WSTATS
  423.                         BustAim_g_AimWarningStats[playerid][BustAim_g_RandomAimShots{playerid}%BUSTAIM_WSTATS_SHOTS] = BustAim_g_DCTTL_temp;
  424.                     #endif
  425.                     if(++BustAim_g_RandomAimShots{playerid} > BUSTAIM_RANDOM_AIM_PROBES)
  426.                     {
  427.                         BustAim_g_RandomAimShots{playerid} = 0;
  428.                         #if !defined BUSTAIM_DISABLE_PROFILING
  429.                             BustAim_g_TotalRandomAimWarns[playerid][weaponid-22]++;
  430.                         #endif
  431.                         warning |= WARNING_RANDOM_AIM;
  432.                     }
  433.                 }
  434.                
  435.         if(warning)
  436.             #if defined OnPlayerSuspectedForAimbot
  437.                if(OnPlayerSuspectedForAimbot(playerid,hitid,weaponid,warning)) BustAim_g_PlayerSettings{playerid} |= IGNORE_PLAYER;
  438.             #endif
  439.     }
  440.     else
  441.     {
  442.         #if !defined BUSTAIM_DISABLE_PROFILING
  443.             if(BustAim_g_ContinousShots{playerid} > BustAim_g_MaxContinousShots[playerid][weaponid-22])
  444.                 BustAim_g_MaxContinousShots[playerid][weaponid-22] = BustAim_g_ContinousShots{playerid};
  445.         #endif
  446.         BustAim_g_ContinousShots{playerid} =
  447.         BustAim_g_RandomAimShots{playerid} =
  448.         BustAim_g_TeleportShots{playerid} =
  449.         BustAim_g_OutOfRangeShots{playerid} =
  450.         BustAim_g_BackwardShot{playerid} = 0;
  451.     }
  452.     #if defined BustAim_OnPlayerWeaponShot
  453.         return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  454.     #else
  455.         return 1;
  456.     #endif
  457. }
  458. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
  459. {
  460.     BustAim_g_IntrnlPlayerSettings{playerid} |= PREVIOUS_SHOT_DID_DAMAGE;
  461.     #if defined BustAim_OnPlayerGiveDamage
  462.         return BustAim_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
  463.     #else
  464.         return 1;
  465.     #endif
  466. }
  467. #if defined _ALS_OnPlayerWeaponShot
  468. #undef OnPlayerWeaponShot
  469. #else
  470. #define _ALS_OnPlayerWeaponShot
  471. #endif
  472.  
  473. #define OnPlayerWeaponShot BustAim_OnPlayerWeaponShot
  474.  
  475. #if defined BustAim_OnPlayerWeaponShot
  476.     forward BustAim_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  477. #endif
  478.  
  479. #if defined _ALS_OnPlayerGiveDamage
  480. #undef OnPlayerGiveDamage
  481. #else
  482. #define _ALS_OnPlayerGiveDamage
  483. #endif
  484.  
  485. #define OnPlayerGiveDamage BustAim_OnPlayerGiveDamage
  486.  
  487. #if defined BustAim_OnPlayerGiveDamage
  488.     forward BustAim_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
  489. #endif
  490. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  491. #if defined BUSTAIM_DISABLE_WSTATS
  492. stock BustAim::GetTeleportStats(playerid,Float:arr[],sz = sizeof(arr))
  493. {
  494.     #pragma unused playerid
  495.     #pragma unused arr
  496.     #pragma unused sz
  497.     print("[BUST-AIM] GetTeleportStats must not be used when WSTATS is disabled.");
  498. }
  499. stock BustAim::GetRandomAimStats(playerid,Float:arr[],sz = sizeof(arr))
  500. {
  501.     #pragma unused playerid
  502.     #pragma unused arr
  503.     #pragma unused sz
  504.     print("[BUST-AIM] GetAimStats must not be used when WSTATS is disabled.");
  505. }
  506. stock BustAim::GetRangeStats(playerid,Float:arr[],sz = sizeof(arr))
  507. {
  508.     #pragma unused playerid
  509.     #pragma unused arr
  510.     #pragma unused sz
  511.     print("[BUST-AIM] GetRangeStats must not be used when WSTATS is disabled.");
  512. }
  513. #else
  514. stock BustAim::GetTeleportStats(playerid,Float:arr[],sz = sizeof(arr))
  515. {
  516.     memcpy(_:arr,_:BustAim_g_TeleportWarningStats[playerid],0,sz*4,sz);
  517. }
  518. stock BustAim::GetRandomAimStats(playerid,Float:arr[],sz = sizeof(arr))
  519. {
  520.     memcpy(_:arr,_:BustAim_g_AimWarningStats[playerid],0,sz*4,sz);
  521. }
  522. stock BustAim::GetRangeStats(playerid,Float:arr[],sz = sizeof(arr))
  523. {
  524.     memcpy(_:arr,_:BustAim_g_RangeWarningStats[playerid],0,sz*4,sz);
  525. }
  526. #endif
  527.  
  528. #if defined BUSTAIM_DISABLE_PROFILING
  529. stock BustAim::GetPlayerWeaponProfile(playerid,weaponid,&allshots,&hitshots,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns,&backward_shot_warns)
  530. {
  531.     #pragma unused playerid
  532.     #pragma unused weaponid
  533.     print("[BUST-AIM] GetPlayerWeaponProfile must not be used when profiling is disabled.");
  534. }
  535. stock BustAim::ResetPlayerWeaponProfile(playerid,weaponid)
  536. {
  537.     #pragma unused playerid
  538.     #pragma unused weaponid
  539.     print("[BUST-AIM] ResetWeaponProfile must not be used when profiling is disabled");
  540. }
  541. stock BustAim::GetPlayerProfile(playerid,&shotsfired,&shotshit,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns,&backward_shot_warns)
  542. {
  543.     #pragma unused playerid
  544.     print("[BUST-AIM] GetPlayerProfile must not be used when profiling is disabled.");
  545. }
  546. stock BustAim::ResetPlayerProfile(playerid)
  547. {
  548.     #pragma unused playerid
  549.     print("[BUST-AIM] ResetPlayerProfile must not be used when profiling is disabled.");
  550. }
  551. #else
  552. stock BustAim::GetPlayerWeaponProfile(playerid,weaponid,&allshots,&hitshots,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns,&backward_shot_warns)
  553. {
  554.     if(22 <= weaponid <= 39)
  555.     {
  556.         weaponid -= 22;
  557.         allshots = BustAim_g_ShotsFired[playerid][weaponid];
  558.         hitshots = BustAim_g_ShotsHit[playerid][weaponid];
  559.         max_cont_shots = BustAim_g_MaxContinousShots[playerid][weaponid];
  560.         out_of_range_warns = BustAim_g_TotalOutOfRangeWarns[playerid][weaponid];
  561.         random_aim_warns = BustAim_g_TotalRandomAimWarns[playerid][weaponid];
  562.         proaim_tele_warns = BustAim_g_TotalTeleportWarns[playerid][weaponid];
  563.         backward_shot_warns = BustAim_g_TotalBackwardWarns[playerid][weaponid];
  564.         return 0;
  565.     }
  566.     return 1;
  567. }
  568. stock BustAim::ResetPlayerWeaponProfile(playerid,weaponid)
  569. {
  570.     if(22 <= weaponid <= 39)
  571.     {
  572.         weaponid -= 22;
  573.         BustAim_g_ShotsFired[playerid][weaponid] =
  574.         BustAim_g_ShotsHit[playerid][weaponid] =
  575.         BustAim_g_MaxContinousShots[playerid][weaponid] =
  576.         BustAim_g_TotalOutOfRangeWarns[playerid][weaponid] =
  577.         BustAim_g_TotalRandomAimWarns[playerid][weaponid] =
  578.         BustAim_g_TotalTeleportWarns[playerid][weaponid] =
  579.         BustAim_g_TotalBackwardWarns[playerid][weaponid] = 0;
  580.         return 0;
  581.     }
  582.     return 1;
  583. }
  584. stock BustAim::GetPlayerProfile(playerid,&shotsfired,&shotshit,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns,&backward_shot_warns)
  585. {
  586.     for(new i = 0;i < BS_TOTAL_SHOOTING_WEAPONS;i++)
  587.     {
  588.         shotsfired += BustAim_g_ShotsFired[playerid][i];
  589.         shotshit += BustAim_g_ShotsHit[playerid][i];
  590.         out_of_range_warns += BustAim_g_TotalOutOfRangeWarns[playerid][i];
  591.         random_aim_warns += BustAim_g_TotalRandomAimWarns[playerid][i];
  592.         proaim_tele_warns+= BustAim_g_TotalTeleportWarns[playerid][i];
  593.         backward_shot_warns += BustAim_g_TotalBackwardWarns[playerid][i];
  594.         if(BustAim_g_MaxContinousShots[playerid][i] > max_cont_shots)
  595.             max_cont_shots = BustAim_g_MaxContinousShots[playerid][i];
  596.     }
  597.     return 1;
  598. }
  599. stock BustAim::ResetPlayerProfile(playerid)
  600. {
  601.     Fill68(BustAim_g_TotalRandomAimWarns[playerid]);
  602.     Fill68(BustAim_g_TotalTeleportWarns[playerid]);
  603.     Fill68(BustAim_g_TotalBackwardWarns[playerid]);
  604.     Fill68(BustAim_g_TotalOutOfRangeWarns[playerid]);
  605.     Fill68(BustAim_g_ShotsFired[playerid]);
  606.     Fill68(BustAim_g_ShotsHit[playerid]);
  607.     Fill68(BustAim_g_MaxContinousShots[playerid]);
  608.     return 0;
  609. }
  610. #endif
  611. stock BustAim::SetPlayerFlags(playerid,flags)
  612. {
  613.     BustAim_g_PlayerSettings{playerid} = flags;
  614. }
  615. stock BustAim::GetPlayerFlags(playerid,&flags)
  616. {
  617.     flags = BustAim_g_PlayerSettings{playerid};
  618. }
  619. stock BustAim::ResetPlayerFlags(playerid)
  620. {
  621.     BustAim_g_PlayerSettings{playerid} = BUSTAIM_DEFAULT_PLAYER_FLAGS;
  622. }
  623. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  624. static stock Fill68(loc[])
  625. {
  626.     new val = 0;
  627.     #emit LOAD.S.alt loc
  628.     #emit LOAD.S.pri val
  629.     #emit FILL 68
  630. }
  631. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  632. public OnPlayerConnect(playerid)
  633. {
  634.     BustAim_g_PlayerSettings{playerid} = BUSTAIM_DEFAULT_PLAYER_FLAGS;
  635.     BustAim_g_IntrnlPlayerSettings{playerid} =
  636.     BustAim_g_ContinousShots{playerid} =
  637.     BustAim_g_RandomAimShots{playerid} =
  638.     BustAim_g_TeleportShots{playerid} =
  639.     BustAim_g_OutOfRangeShots{playerid} =
  640.     BustAim_g_BackwardShot{playerid} = 0;
  641.     #if !defined BUSTAIM_DISABLE_PROFILING
  642.         Fill68(BustAim_g_TotalRandomAimWarns[playerid]);
  643.         Fill68(BustAim_g_TotalTeleportWarns[playerid]);
  644.         Fill68(BustAim_g_TotalBackwardWarns[playerid]);
  645.         Fill68(BustAim_g_TotalOutOfRangeWarns[playerid]);
  646.         Fill68(BustAim_g_ShotsFired[playerid]);
  647.         Fill68(BustAim_g_ShotsHit[playerid]);
  648.         Fill68(BustAim_g_MaxContinousShots[playerid]);
  649.     #endif
  650.  
  651.     #if defined BustAim_OnPlayerConnect
  652.         return BustAim_OnPlayerConnect(playerid);
  653.     #else
  654.         return 1;
  655.     #endif
  656. }
  657. #if defined _ALS_OnPlayerConnect
  658. #undef OnPlayerConnect
  659. #else
  660. #define _ALS_OnPlayerConnect
  661. #endif
  662.  
  663. #define OnPlayerConnect BustAim_OnPlayerConnect
  664.  
  665. #if defined BustAim_OnPlayerConnect
  666.     forward BustAim_OnPlayerConnect(playerid);
  667. #endif
  668.  
  669. #if !defined BUSTAIM_IS_PAUSED_FUNCTION
  670.     public OnPlayerUpdate(playerid)
  671.     {
  672.         BustAim_g_LastUpdateTick[playerid] = GetTickCount();
  673.  
  674.         #if defined BustAim_OnPlayerUpdate
  675.             return BustAim_OnPlayerUpdate(playerid);
  676.         #else
  677.             return 1;
  678.         #endif
  679.     }
  680.     #if defined _ALS_OnPlayerUpdate
  681.     #undef OnPlayerUpdate
  682.     #else
  683.     #define _ALS_OnPlayerUpdate
  684.     #endif
  685.  
  686.     #define OnPlayerUpdate BustAim_OnPlayerUpdate
  687.  
  688.     #if defined BustAim_OnPlayerUpdate
  689.         forward BustAim_OnPlayerUpdate(playerid);
  690.     #endif
  691. #endif
  692. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement