Advertisement
Guest User

radar

a guest
Oct 31st, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. --[[
  2. # Resource Name
  3. Grand Theft Auto V | Radar
  4. # Author
  5. Rage
  6. # Date created
  7. 25.04.2014
  8. # Last update
  9. 17.07.2014
  10. # Copyright (c)
  11. If you edit it, then please respect me and keep
  12. the credits.
  13. --]]
  14.  
  15. local screenW,screenH = guiGetScreenSize()
  16. local resW,resH = 1280,720
  17. local sW,sH = (screenW/resW), (screenH/resH)
  18.  
  19. local turn = true
  20. local alpha = 255
  21.  
  22. addEventHandler( "onClientResourceStart", resourceRoot,
  23. function()
  24. setPlayerHudComponentVisible ( "radar", false )
  25. --# Create Textures
  26. hudMaskFX = dxCreateShader("mask.fx")
  27. radarTexture = dxCreateTexture("img/radar_map.jpg")
  28. maskTexture = dxCreateTexture("img/radar_mask.png")
  29. checkTextures = ( hudMaskFX and radarTexture and maskTexture )
  30.  
  31. if not ( checkTextures ) then
  32. outputChatBox( "[GTA V Radar]: Could not create textures. Please use debugscript 3" )
  33. else
  34. dxSetShaderValue( hudMaskFX, "sPicTexture", radarTexture )
  35. dxSetShaderValue( hudMaskFX, "sMaskTexture", maskTexture )
  36. end
  37. end
  38. )
  39.  
  40. function drawRadar()
  41. if not ( checkTextures ) then return end
  42. dxSetShaderValue( hudMaskFX, "sMaskTexture", maskTexture )
  43.  
  44. local x,y = getElementPosition( localPlayer )
  45. local zoom = 13
  46. x = ( x ) / 6000
  47. y = ( y ) / -6000
  48. dxSetShaderValue( hudMaskFX, "gUVPosition", x,y )
  49. dxSetShaderValue( hudMaskFX, "gUVScale", 1/zoom, 1/zoom )
  50.  
  51. --# Get rotations
  52. local _, _, c_Rot = getElementRotation( getCamera());
  53. local _, _, p_Rot = getElementRotation( localPlayer )
  54. dxSetShaderValue( hudMaskFX, "gUVRotAngle", math.rad( -c_Rot ))
  55.  
  56. local playerHealth = math.floor( getElementHealth( localPlayer ))
  57. local playerArmor = math.floor( getPedArmor( localPlayer ))
  58. local playerOxygen = math.floor( getPedOxygenLevel( localPlayer ))
  59. if ( playerHealth <= 50) then
  60. HP_Colour = tocolor(200, 0, 0, 190)
  61. HP_Alpha = tocolor(200, 0, 0, 100)
  62. else
  63. HP_Colour = tocolor(102, 204, 102, 190)
  64. HP_Alpha = tocolor(102, 204, 102, 100)
  65. end
  66. if ( playerHealth >= 101 ) then
  67. maxHealth = 200
  68. else
  69. maxHealth = 100
  70. end
  71.  
  72. --# Alpha
  73. dxDrawRectangle(23.5*sW, 676.5*sH, 130.5*sW, 9.2*sH, HP_Alpha)
  74. dxDrawRectangle(156.6*sW, 676.5*sH, 65*sW, 9.2*sH, tocolor(0, 102, 255, 100))
  75. dxDrawRectangle(225*sW, 676.5*sH, 62.6*sW, 9.2*sH, tocolor(255, 255, 0, 100))
  76.  
  77. --# Bars
  78. dxDrawRectangle(23.5*sW, 676.5*sH, 130.5*sW/maxHealth*playerHealth, 9.2*sH, HP_Colour)
  79. dxDrawRectangle(156.6*sW, 676.5*sH, 65*sW/100*playerArmor, 9.2*sH, tocolor(0, 102, 255, 190))
  80. dxDrawRectangle(225*sW, 676.5*sH, 62.6*sW/1000*playerOxygen, 9.2*sH, tocolor(255, 255, 0, 190))
  81.  
  82. --# Minimap
  83. dxDrawImage(18*sW, 530*sH, 275*sW, 160*sH, "img/radar_cover.png", 0, 0, 0, tocolor(255, 255, 255, 255))
  84. dxDrawImage(23*sW, 536*sH, 265*sW, 135*sH, hudMaskFX, 0,0,0, tocolor(255,255,255,210))
  85. dxDrawImage(144*sW, 595*sH, 20*sW, 20*sH, "img/radar_player.png", -p_Rot+c_Rot, 0, 0, tocolor(255, 255, 255, 255))
  86.  
  87. --# Wanted
  88. local g_wl = getPlayerWantedLevel( localPlayer )
  89. if ( g_wl > 0 ) then
  90. if ( turn == true ) then
  91. alpha = alpha + 5
  92. if ( alpha > 180 ) then
  93. alpha = 180
  94. turn = false
  95. end
  96. elseif ( turn == false ) then
  97. alpha = alpha - 5
  98. if ( alpha < 0 ) then
  99. alpha = 0
  100. turn = true
  101. end
  102. end
  103. dxDrawRectangle(23*sW, 536*sH, 265*sW, 135*sH, tocolor(0, 102, 255, alpha))
  104. else return end
  105. end
  106. addEventHandler( "onClientRender", root, drawRadar)
  107.  
  108. addEventHandler( "onClientResourceStop", resourceRoot,
  109. function()
  110. setPlayerHudComponentVisible ( "radar", true )
  111. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement