Guest User

Untitled

a guest
Feb 29th, 2020
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local enableBlips = true
  2. local renderNorthBlip = true
  3. local alwaysRenderMap = false
  4.  
  5. local worldW, worldH = 3000,3000
  6. local blip = 8
  7. local rt = dxCreateRenderTarget(290*2,175*2, true)
  8. local sx, sy = guiGetScreenSize()
  9. local xFactor, yFactor = sx/1366,sy/768
  10. local yFactor = xFactor
  11.  
  12. function findRotation(x1,y1,x2,y2)
  13. local t = -math.deg(math.atan2(x2-x1,y2-y1))
  14. if t < 0 then t = t + 360 end;
  15. return t;
  16. end
  17.  
  18. function getPointFromDistanceRotation(x, y, dist, angle)
  19. local a = math.rad(90 - angle);
  20. local dx = math.cos(a) * dist;
  21. local dy = math.sin(a) * dist;
  22. return x+dx, y+dy;
  23. end
  24.  
  25. addEvent("dajRadarDaleko", true)
  26. addEventHandler("dajRadarDaleko", getRootElement(), function()
  27. rt = dxCreateRenderTarget(290*getElementData(localPlayer, "daleko_radar"),175*getElementData(localPlayer, "daleko_radar"), true)
  28. ile = getElementData(localPlayer, "daleko_radar")
  29. blip = 12 / getElementData(localPlayer, "daleko_radar")
  30. end)
  31.  
  32. function RADAR()
  33. local mW, mH = dxGetMaterialSize(rt)
  34. local x, y = getElementPosition(localPlayer)
  35. local X, Y = mW/2 -(x/(6000/worldW)), mH/2 +(y/(6000/worldH))
  36. local camX,camY,camZ = getElementRotation(getCamera())
  37. dxSetRenderTarget(rt, true)
  38. if alwaysRenderMap or getElementInterior(localPlayer) == 0 then
  39. dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, "gfx/world.png", camZ, (x/(6000/worldW)), -(y/(6000/worldH)), tocolor(255, 255, 255, 255))
  40. --
  41. dxSetRenderTarget()
  42. dxDrawImage((18-25)*xFactor, sy-((216-40))*yFactor, (293+31)*xFactor, (177)*yFactor, "gfx/radarbg.png", 0, 0, 0, tocolor(0, 0, 0, 200))
  43. dxDrawImage((30+5-25)*xFactor, sy-((200+5-40))*yFactor, (270+20)*xFactor, (155)*yFactor, rt, 0, 0, 0, tocolor(255, 255, 255, 255))
  44. dxDrawImage((30+5-25)*xFactor, sy-((200+5-40))*yFactor, (270+20)*xFactor, (155)*yFactor, rt, 0, 0, 0, tocolor(255, 255, 255, 255))
  45. --# Blips
  46. local rx, ry, rz = getElementRotation(localPlayer)
  47. local lB = (33-23)*xFactor
  48. local rB = (8+290+2)*xFactor
  49. local tB = sy-(208-43)*yFactor
  50. local bB = tB + (155-2)*yFactor
  51. local cX, cY = (rB+lB)/2, (tB+bB)/2 +(30)*yFactor
  52. local toLeft, toTop, toRight, toBottom = cX-lB, cY-tB, rB-cX, bB-cY
  53. for k, v in ipairs(getElementsByType("blip")) do
  54. local bx, by = getElementPosition(v)
  55. local actualDist = getDistanceBetweenPoints2D(x, y, bx, by)
  56. local maxDist = getBlipVisibleDistance(v)
  57. if actualDist <= maxDist and getElementDimension(v)==getElementDimension(localPlayer) and getElementInterior(v)==getElementInterior(localPlayer) then
  58. if not getElementData(localPlayer, "daleko_radar") then
  59. ile = 2
  60. else
  61. ile = getElementData(localPlayer, "daleko_radar")
  62. end
  63. local dist = actualDist/(6000*ile/((worldW+worldH)/2))
  64. local rot = findRotation(bx, by, x, y)-camZ
  65. local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.min(dist, math.sqrt(toTop^2 + toRight^2)), rot)
  66. local bpx = math.max(lB, math.min(rB, bpx))
  67. local bpy = math.max(tB, math.min(bB, bpy))
  68. local bid = getElementData(v, "customIcon") or getBlipIcon(v)
  69. local _, _, _, bcA = getBlipColor(v)
  70. local bcR, bcG, bcB = 255, 255, 255
  71. if getBlipIcon(v) == 0 then
  72. bcR, bcG, bcB = getBlipColor(v)
  73. end
  74. local bS = getBlipSize(v)
  75. dxDrawImage(bpx -(blip*bS)*xFactor/2, bpy -(blip*bS)*yFactor/2, (blip*bS)*xFactor, (blip*bS)*yFactor, "gfx/blip/"..bid..".png", 0, 0, 0, tocolor(bcR, bcG, bcB, bcA))
  76. end
  77. if renderNorthBlip then
  78. local rot = -camZ+180
  79. local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.sqrt(toTop^2 + toRight^2), rot)
  80. local bpx = math.max(lB, math.min(rB, bpx))
  81. local bpy = math.max(tB, math.min(bB, bpy))
  82. local dist = getDistanceBetweenPoints2D(cX, cY, bpx, bpy)
  83. local bpx, bpy = getPointFromDistanceRotation(cX, cY, dist, rot)
  84. if bpx and bpy then
  85. local bpx = math.max(lB, math.min(rB, bpx))
  86. local bpy = math.max(tB, math.min(bB, bpy))
  87. dxDrawImage(bpx -(blip*2)/2,bpy -(blip*2)/2,blip*2,blip*2,"gfx/blip/4.png",0,0,0)
  88. end
  89. end
  90. dxDrawImage((cX -(blip*2)*xFactor/2)+2,cY -(blip*2)*yFactor/2,(blip*2)*xFactor-2,(blip*2)*yFactor, "gfx/player.png", camZ-rz, 0, 0)
  91. end
  92. end
  93. addEventHandler("onClientRender", root, RADAR)
  94.  
  95. function Visible()
  96. if isVisible then
  97. addEventHandler("onClientRender", root, RADAR)
  98. else
  99. removeEventHandler("onClientRender", root, RADAR)
  100. end
  101. isVisible = not isVisible
  102. end
  103. bindKey ("F11", "down", Visible)
RAW Paste Data