Advertisement
txxxxxxxx

Untitled

Mar 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. local sx, sy = guiGetScreenSize()
  2. local centerX, centerY = sx / 2, sy / 2
  3. local dragX, dragY = false, false
  4.  
  5. local hudState = true
  6. local isDraggingHP = false
  7. local isDraggingAR = false
  8. local isDraggingMO = false
  9. local isDraggingCL = false
  10. local windowOffsetX, windowOffsetY = 0, 0
  11. local windowOffsetX2, windowOffsetY2 = 0, 0
  12. local windowOffsetX3, windowOffsetY3 = 0, 0
  13. local windowOffsetX4, windowOffsetY4 = 0, 0
  14.  
  15. local hpX, hpY = sx - 275, 25
  16. local arX, arY = sx - 275, 75
  17. local moX, moY = sx - 145, 125
  18. local clX, clY = sx - 145, 175
  19. local dxFont = dxCreateFont("files/font.ttf", 6*2, false)
  20.  
  21. function showHUD ()
  22. hudState = true
  23. end
  24.  
  25. function hideHUD ()
  26. hudState = false
  27. end
  28.  
  29. addEventHandler('onClientRender', root,
  30. function()
  31. if hudState then
  32. if isCursorShowing() then
  33. cursorX, cursorY = getCursorPosition()
  34. cursorX, cursorY = cursorX * sx, cursorY * sy
  35. end
  36.  
  37. if isDraggingHP then
  38. hpX, hpY = cursorX + windowOffsetX, cursorY + windowOffsetY
  39. end
  40.  
  41. if isDraggingAR then
  42. arX, arY = cursorX + windowOffsetX2, cursorY + windowOffsetY2
  43. end
  44.  
  45. if isDraggingMO then
  46. moX, moY = cursorX + windowOffsetX3, cursorY + windowOffsetY3
  47. end
  48.  
  49. if isDraggingCL then
  50. clX, clY = cursorX + windowOffsetX4, cursorY + windowOffsetY4
  51. end
  52.  
  53. local hp = math.ceil(getElementHealth(localPlayer))
  54. local armor = math.ceil(getPedArmor(localPlayer))
  55. local money = getPlayerMoney(localPlayer)
  56.  
  57. local time = getRealTime()
  58. local hours = time.hour
  59. local minutes = time.minute
  60.  
  61. if hours < 10 then
  62. hours = "0" .. hours
  63. end
  64.  
  65. if minutes < 10 then
  66. minutes = "0" .. minutes
  67. end
  68.  
  69. dxDrawRectangle(hpX, hpY, 235, 25, tocolor(0, 0, 0, 178.5))
  70. dxDrawRectangle(hpX, hpY+25, 235, 1, tocolor(222, 74, 74, 255))
  71. dxDrawRectangle(hpX + 25, hpY + 5, hp*2.05, 15, tocolor(222, 74, 74, 180))
  72. dxDrawImage(hpX + 5, hpY + 5, 16, 16, "icons/0.png")
  73.  
  74. dxDrawRectangle(arX, arY, 235, 25, tocolor(0, 0, 0, 178.5))
  75. dxDrawRectangle(arX, arY+25, 235, 1, tocolor(222, 74, 74, 255))
  76. dxDrawRectangle(arX + 25, arY + 5, armor*2.05, 15, tocolor(74, 158, 222, 180))
  77. dxDrawImage(arX + 5, arY + 5, 16, 16, "icons/1.png")
  78.  
  79. dxDrawRectangle(moX, moY, 105, 25, tocolor(0, 0, 0, 178.5))
  80. dxDrawRectangle(moX, moY+25, 105, 1, tocolor(222, 74, 74, 255))
  81. dxDrawText(money .. "#DE4A4AFt", moX+100, moY+2, moX+100, moY+2, tocolor(255, 255, 255, 255), 1, dxFont, "right", "top", false, false, false, true)
  82. dxDrawImage(moX + 5, moY + 5, 16, 16, "icons/2.png")
  83.  
  84. dxDrawRectangle(clX, clY, 105, 25, tocolor(0, 0, 0, 178.5))
  85. dxDrawRectangle(clX, clY+25, 105, 1, tocolor(222, 74, 74, 255))
  86. dxDrawText(hours .. ":" .. minutes, clX+100, clY+2, clX+100, clY+2, tocolor(255, 255, 255, 255), 1, dxFont, "right", "top", false, false, false, false)
  87. dxDrawImage(clX + 5, clY + 5, 16, 16, "icons/3.png")
  88. end
  89. end
  90. )
  91.  
  92. addEventHandler("onClientClick", getRootElement(),
  93. function(button, state, x, y, wx, wy, wz, element)
  94. if button == "left" and state == "down" and x and y then
  95. if x >= hpX and x < hpX + 235 and y >= hpY and y < hpY + 25 then
  96. windowOffsetX, windowOffsetY = (hpX) - x, (hpY) - y
  97. isDraggingHP = true
  98. elseif x >= arX and x < arX + 235 and y >= arY and y < arY + 25 then
  99. windowOffsetX2, windowOffsetY2 = (arX) - x, (arY) - y
  100. isDraggingAR = true
  101. elseif x >= moX and x < moX + 105 and y >= moY and y < moY + 25 then
  102. windowOffsetX3, windowOffsetY3 = (moX) - x, (moY) - y
  103. isDraggingMO = true
  104. elseif x >= clX and x < clX + 105 and y >= clY and y < clY + 25 then
  105. windowOffsetX4, windowOffsetY4 = (clX) - x, (clY) - y
  106. isDraggingCL = true
  107. end
  108. end
  109.  
  110. if button == "left" and state == "up" and isDraggingHP then
  111. isDraggingHP = false
  112. elseif button == "left" and state == "up" and isDraggingAR then
  113. isDraggingAR = false
  114. elseif button == "left" and state == "up" and isDraggingMO then
  115. isDraggingMO = false
  116. elseif button == "left" and state == "up" and isDraggingCL then
  117. isDraggingCL = false
  118. end
  119. end
  120. )
  121.  
  122. function toggleHUD (state)
  123. if state ~= hudState then
  124. hudState = state
  125. end
  126. end
  127. addEvent("toggleHUD", true)
  128. addEventHandler("toggleHUD", getRootElement(), toggleHUD)
  129.  
  130. function togHUDCMD (cname,arg)
  131. toggleHUD (not hudState)
  132. end
  133. addCommandHandler ("toghud",togHUDCMD)
  134.  
  135. --alap szerverre kell--
  136. local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }
  137.  
  138. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
  139. function ()
  140. for _, component in ipairs( components ) do
  141. setPlayerHudComponentVisible( component, false )
  142. end
  143. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement