Advertisement
Smokahontas

MTA

Aug 19th, 2022 (edited)
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- Created by Smokahontas.
  2. bindKey("mouse2", "down", function()
  3.     local fov = 90
  4.     local enemies = getElementsByType("player")
  5.     for _,enemy in ipairs(enemies) do
  6.         if enemy ~= localPlayer and getElementData(enemy, "player:logedin") then
  7.             local x, y = getScreenFromWorldPosition(enemy.position)
  8.             if x and y then
  9.                 if isLineOfSightClear(localPlayer.position, enemy.position, true, true, true, false, false) then
  10.                     local fovDistance = 6*(screenSize.x/1920)
  11.                     local distanceX = math.abs(screenSize.x/2 - x)
  12.                     local distanceY = math.abs(screenSize.y/2 - y)
  13.                     if distanceX < fovDistance and distanceY < fovDistance then
  14.                         local angle = math.deg(math.atan2(distanceY, distanceX))
  15.                         if angle < fov then
  16.                             setCameraMatrix(localPlayer.position, enemy.position)
  17.                             break
  18.                         end
  19.                     end
  20.                 end
  21.             end
  22.         end
  23.     end
  24. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement