Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | None | 0 0
  1. mojeW,mojeH = 1920, 1080
  2. sW,sH = guiGetScreenSize()
  3. w, h = (sW/mojeW), (sH/mojeH)
  4. skalaX = (sW/mojeW)
  5. skalaY = (sH/mojeH)
  6. FontSize = (skalaX)
  7.  
  8.  
  9.      
  10. local weaponId = getPedWeapon(localPlayer)
  11. local weaponName = getWeaponNameFromID(weaponId)
  12. local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }
  13.  
  14. local bar = {
  15.     y_hp = 40,
  16.     y_armor = 70,
  17.     y_tlen = 100
  18. }
  19.  
  20. local bg = {
  21.     y_hp = 35,
  22.     y_armor = 65,
  23.     y_tlen = 95,
  24.     bg_dlug = 100
  25. }
  26.  
  27. function draw()
  28.  
  29.     outputChatBox(""..weaponName.."")
  30.  
  31.     local players = getElementsByType ( "player" )
  32.     local money = getPlayerMoney(localPlayer)    
  33.     local time = getRealTime()
  34.     local hours = time.hour
  35.     local minutes = time.minute
  36.     local seconds = time.second
  37.    
  38.     -- bg
  39.     dxDrawRectangle(1662*w, 0*h, 241*w, bg.bg_dlug*h, tocolor(1, 0, 0, 198), false)
  40.     dxDrawRectangle(1662*w, -5*h, 241*w, 12*h, tocolor(38, 118, 16, 170), false)
  41.  
  42.     -- liczenie czasu
  43.     if (hours < 10) then
  44.         hours = "0"..hours
  45.     end
  46.     if (minutes < 10) then
  47.         minutes = "0"..minutes
  48.     end
  49.  
  50.     -- tlen
  51.     for k,v in ipairs ( players ) do
  52.         if isPedInWater ( v ) then
  53.             bg.bg_dlug = 126
  54.             dxDrawRectangle(1641+50*w, bg.y_tlen*h, 182*w, 23*h, tocolor(1, 1, 0, 255), false)
  55.             dxDrawProgressBar( 1646+50*w, bar.y_tlen*h, 172*w, 13*h, math.floor(getPedOxygenLevel(localPlayer)), tocolor( 16, 128, 188, 255), tocolor( 12, 85, 124, 200) )
  56.         else
  57.             bg.bg_dlug = 105
  58.         end
  59.     end
  60.  
  61.     -- hp
  62.     dxDrawRectangle(1641+50*w, bg.y_hp*h, 182*w, 23*h, tocolor(1, 1, 0, 255), false)
  63.     dxDrawProgressBar( 1646+50*w, bar.y_hp*h, 172*w, 13*h, math.floor(getElementHealth(localPlayer)), tocolor( 165, 16, 16, 255), tocolor( 119, 12, 12, 200) )
  64.  
  65.     -- armor
  66.     dxDrawRectangle(1641+50*w, bg.y_armor*h, 182*w, 23*h, tocolor(1, 1, 0, 255), false)
  67.     dxDrawProgressBar( 1646+50*w, bar.y_armor*h, 172*w, 13*h, math.floor(getPlayerArmor(localPlayer)), tocolor( 150, 150, 150, 255), tocolor( 40, 40, 40, 200) )
  68.  
  69.     -- hajs i godzina
  70.     dxDrawText(""..money.."$", 1696*w, 19*h, 1762*w, 35*h, tocolor(12, 181, 12, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
  71.     dxDrawText(""..hours..":"..minutes.."", 1839*w, 19*h, 1905*w, 35*h, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
  72.  
  73. end
  74. addEventHandler("onClientRender", root, draw)
  75. -- bindKey("F7", "up", function(he, md)
  76.  
  77. --     local data = getElementData(localPlayer, "gracz:hud") or false
  78.  
  79. --     if data then
  80.  
  81. --         removeEventHandler("onClientRender",root,draw)
  82. --         setElementData(localPlayer, "gracz:hud", false)
  83.  
  84. --     else
  85.  
  86. --         setElementData(localPlayer, "gracz:hud", true)
  87. --         addEventHandler("onClientRender", root, draw)
  88.  
  89. --     end
  90. -- end)
  91.  
  92.  
  93.  
  94. local unlerp = function(from,to,lerp) return (lerp-from)/(to-from) end
  95.  
  96. function dxDrawProgressBar( startX, startY, width, height, progress, color, backColor )
  97.         local progress = math.max( 0, (math.min( 100, progress) ) )
  98.         local wBar = width*.2
  99.         for i = 0, 4 do
  100.                 --back
  101.                 local startPos = (wBar*i + (width*.0001)*i) + startX
  102.                 dxDrawRectangle( startPos, startY, wBar, height, backColor )
  103.                 --progress
  104.                 local eInterval = (i*20)
  105.                 local localProgress = math.min( 1, unlerp( eInterval, eInterval + 20, progress ) )
  106.                         if localProgress > 0 then
  107.                                 dxDrawRectangle( startPos, startY, wBar*localProgress, height, color )
  108.                         end
  109.         end
  110. end
  111.  
  112. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
  113. function ()
  114.     for _, component in ipairs( components ) do
  115.         setPlayerHudComponentVisible( component, false )
  116.     end
  117. end)
  118.  
  119. local anims, builtins = {}, {"Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce", "SineCurve", "CosineCurve"}
  120.  
  121. function table.find(t, v)
  122.     for k, a in ipairs(t) do
  123.         if a == v then
  124.             return k
  125.         end
  126.     end
  127.     return false
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement