Advertisement
XaskeL

MTA Fix Circle Radar for CCD, userful function circle radar

Jun 18th, 2019
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. -- Author: XaskeL
  2. -- Fix for circle radar. From RCCDPlanet.
  3.  
  4. local function findRotation(x1,y1,x2,y2)
  5.     local t = -math.deg(math.atan2(x2-x1,y2-y1))
  6.     if t < 0 then t = t + 360 end
  7.     return t
  8. end
  9.  
  10. local function getDistanceRotation(x, y, dist, angle)
  11.     local a = math.rad(90 - angle)
  12.     local dx = math.cos(a) * dist
  13.     local dy = math.sin(a) * dist
  14.     return x+dx, y+dy
  15. end
  16.  
  17. function repairCoordinates(blipPosX, blipPosY, blip)
  18.     local radius = 130
  19.     local newX,newY = blipPosX, blipPosY
  20.     local angle = -findRotation(0, 0, blipPosX, blipPosY)
  21.     local px,py = getDistanceRotation(radar.center.x, radar.center.y, radius, angle)
  22.     local distx = getDistanceBetweenPoints2D(blipPosX, blipPosY, 0, 0)
  23.     if distx > radius then
  24.         newX = px - radar.center.x
  25.         newY = py - radar.center.y
  26.     end
  27.     return newX,newY
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement