Advertisement
Altamurenza

Bully SE: Lock-on Overhaul

May 12th, 2021
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. -- LOCK-ON OVERHAUL ( SOURCE CODE )
  2. -- AUTHOR   : ALTAMURENZA
  3.  
  4. --[[
  5.     - NOTE -
  6.    
  7.     YOU CAN'T CHANGE OBJECT BECAUSE ITS VALUE ALWAYS BE -1 OR PED
  8.    
  9.     * AIM PERSPECTIVE (Type) *
  10.     0 - FREE AIM
  11.     1 - CLOSEST DISTANCE ( RECOMMENDED )
  12.     2 - LOWEST HEALTH
  13.     3 - FARTHEST DISTANCE
  14.     4 - HIGHEST HEALTH
  15.    
  16.     * MAXIMUM RANGE (Range) *
  17.     IT'S RECOMMENDED ABOUT 5 TO 10
  18. ]]
  19.  
  20. shared.Aim = {
  21.     Object = -1, Type = 1, Range = 8 -- look at the note above
  22. }; local sqrt, floor = math.sqrt, math.floor
  23.  
  24.  
  25. function main()
  26.     while not SystemIsReady() or AreaIsLoading() do
  27.         Wait(0)
  28.     end
  29.    
  30.     CreateThread("mainSwitch")
  31.    
  32.     while true do
  33.         local X, Y, Z = PlayerGetPosXYZ()
  34.        
  35.         if shared.Aim.Type ~= 0 and shared.Aim.Type < 5 then
  36.             if IsButtonPressed(10, 0) then
  37.                 shared.Aim.Object = -1
  38.                
  39.                 local SIZE, MAXN = {}, 0
  40.                 for i, Ped in {PedFindInAreaXYZ(0, 0, 0, 999999)} do
  41.                     if PedIsValid(Ped) and Ped ~= gPlayer and PedGetHealth(Ped) > 0 then
  42.                         local PX, PY, PZ = PedGetPosXYZ(Ped)
  43.                        
  44.                         local Distance = sqrt((X - PX)*(X - PX) + (Y - PY)*(Y - PY) + (Z - PZ)*(Z - PZ))
  45.                         if Distance < shared.Aim.Range then
  46.                             local Value = floor(shared.Aim.Type == 1 and Distance or PedGetHealth(Ped))
  47.                            
  48.                             SIZE[SIZE[Value] and Value - 1 or Value], MAXN = Ped, Value > MAXN and Value or MAXN
  49.                         end
  50.                     end
  51.                 end
  52.                
  53.                 local Count = shared.Aim.Type > 2 and MAXN or 0
  54.                 while shared.Aim.Type < 3 and not SIZE[Count] do
  55.                     Count = Count + 1
  56.                     if Count > MAXN then
  57.                         break
  58.                     end
  59.                 end
  60.                
  61.                 shared.Aim.Object = PedIsValid(SIZE[Count]) and SIZE[Count] or -1
  62.                
  63.                 if shared.Aim.Object ~= -1 then
  64.                     PedLockTarget(gPlayer, shared.Aim.Object, 3)
  65.                 end
  66.             else
  67.                 if IsButtonBeingReleased(10, 0) then
  68.                     shared.Aim.Object = -1; PedLockTarget(gPlayer, -1)
  69.                 end
  70.             end
  71.         else
  72.             shared.Aim.Object = -1
  73.         end
  74.        
  75.         Wait(0)
  76.     end
  77. end; function mainSwitch()
  78.     while true do
  79.         if IsButtonPressed(10, 0) and IsButtonBeingPressed(3, 0) then
  80.             shared.Aim.Type = shared.Aim.Type + 1 < 5 and shared.Aim.Type + 1 or 0
  81.            
  82.             if shared.Aim.Type == 0 then
  83.                 PedLockTarget(gPlayer, -1)
  84.             end
  85.            
  86.             TextPrintString(shared.Aim.Type == 0  and "FREE AIM" or
  87.                 (shared.Aim.Type == 1 and "AIM - CLOSEST DISTANCE" or
  88.                 (shared.Aim.Type == 2 and "AIM - LOWEST HEALTH" or
  89.                 (shared.Aim.Type == 3 and "AIM - FARTHEST DISTANCE" or
  90.                 (shared.Aim.Type == 4 and "AIM - HIGHEST HEALTH" or
  91.                 "NILL"))))
  92.             , 1, 2)
  93.         end
  94.        
  95.         Wait(0)
  96.     end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement