XaskeL

MTA Fix Circle Radar for CCD, userful function circle radar

Jun 18th, 2019
793
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×