Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sx, sy = guiGetScreenSize()
- local centerX, centerY = sx / 2, sy / 2
- local dragX, dragY = false, false
- local hudState = true
- local isDraggingHP = false
- local isDraggingAR = false
- local isDraggingMO = false
- local isDraggingCL = false
- local windowOffsetX, windowOffsetY = 0, 0
- local windowOffsetX2, windowOffsetY2 = 0, 0
- local windowOffsetX3, windowOffsetY3 = 0, 0
- local windowOffsetX4, windowOffsetY4 = 0, 0
- local hpX, hpY = sx - 275, 25
- local arX, arY = sx - 275, 75
- local moX, moY = sx - 145, 125
- local clX, clY = sx - 145, 175
- local dxFont = dxCreateFont("files/font.ttf", 6*2, false)
- function showHUD ()
- hudState = true
- end
- function hideHUD ()
- hudState = false
- end
- addEventHandler('onClientRender', root,
- function()
- if hudState then
- if isCursorShowing() then
- cursorX, cursorY = getCursorPosition()
- cursorX, cursorY = cursorX * sx, cursorY * sy
- end
- if isDraggingHP then
- hpX, hpY = cursorX + windowOffsetX, cursorY + windowOffsetY
- end
- if isDraggingAR then
- arX, arY = cursorX + windowOffsetX2, cursorY + windowOffsetY2
- end
- if isDraggingMO then
- moX, moY = cursorX + windowOffsetX3, cursorY + windowOffsetY3
- end
- if isDraggingCL then
- clX, clY = cursorX + windowOffsetX4, cursorY + windowOffsetY4
- end
- local hp = math.ceil(getElementHealth(localPlayer))
- local armor = math.ceil(getPedArmor(localPlayer))
- local money = getPlayerMoney(localPlayer)
- local time = getRealTime()
- local hours = time.hour
- local minutes = time.minute
- if hours < 10 then
- hours = "0" .. hours
- end
- if minutes < 10 then
- minutes = "0" .. minutes
- end
- dxDrawRectangle(hpX, hpY, 235, 25, tocolor(0, 0, 0, 178.5))
- dxDrawRectangle(hpX, hpY+25, 235, 1, tocolor(222, 74, 74, 255))
- dxDrawRectangle(hpX + 25, hpY + 5, hp*2.05, 15, tocolor(222, 74, 74, 180))
- dxDrawImage(hpX + 5, hpY + 5, 16, 16, "icons/0.png")
- dxDrawRectangle(arX, arY, 235, 25, tocolor(0, 0, 0, 178.5))
- dxDrawRectangle(arX, arY+25, 235, 1, tocolor(222, 74, 74, 255))
- dxDrawRectangle(arX + 25, arY + 5, armor*2.05, 15, tocolor(74, 158, 222, 180))
- dxDrawImage(arX + 5, arY + 5, 16, 16, "icons/1.png")
- dxDrawRectangle(moX, moY, 105, 25, tocolor(0, 0, 0, 178.5))
- dxDrawRectangle(moX, moY+25, 105, 1, tocolor(222, 74, 74, 255))
- dxDrawText(money .. "#DE4A4AFt", moX+100, moY+2, moX+100, moY+2, tocolor(255, 255, 255, 255), 1, dxFont, "right", "top", false, false, false, true)
- dxDrawImage(moX + 5, moY + 5, 16, 16, "icons/2.png")
- dxDrawRectangle(clX, clY, 105, 25, tocolor(0, 0, 0, 178.5))
- dxDrawRectangle(clX, clY+25, 105, 1, tocolor(222, 74, 74, 255))
- dxDrawText(hours .. ":" .. minutes, clX+100, clY+2, clX+100, clY+2, tocolor(255, 255, 255, 255), 1, dxFont, "right", "top", false, false, false, false)
- dxDrawImage(clX + 5, clY + 5, 16, 16, "icons/3.png")
- end
- end
- )
- addEventHandler("onClientClick", getRootElement(),
- function(button, state, x, y, wx, wy, wz, element)
- if button == "left" and state == "down" and x and y then
- if x >= hpX and x < hpX + 235 and y >= hpY and y < hpY + 25 then
- windowOffsetX, windowOffsetY = (hpX) - x, (hpY) - y
- isDraggingHP = true
- elseif x >= arX and x < arX + 235 and y >= arY and y < arY + 25 then
- windowOffsetX2, windowOffsetY2 = (arX) - x, (arY) - y
- isDraggingAR = true
- elseif x >= moX and x < moX + 105 and y >= moY and y < moY + 25 then
- windowOffsetX3, windowOffsetY3 = (moX) - x, (moY) - y
- isDraggingMO = true
- elseif x >= clX and x < clX + 105 and y >= clY and y < clY + 25 then
- windowOffsetX4, windowOffsetY4 = (clX) - x, (clY) - y
- isDraggingCL = true
- end
- end
- if button == "left" and state == "up" and isDraggingHP then
- isDraggingHP = false
- elseif button == "left" and state == "up" and isDraggingAR then
- isDraggingAR = false
- elseif button == "left" and state == "up" and isDraggingMO then
- isDraggingMO = false
- elseif button == "left" and state == "up" and isDraggingCL then
- isDraggingCL = false
- end
- end
- )
- function toggleHUD (state)
- if state ~= hudState then
- hudState = state
- end
- end
- addEvent("toggleHUD", true)
- addEventHandler("toggleHUD", getRootElement(), toggleHUD)
- function togHUDCMD (cname,arg)
- toggleHUD (not hudState)
- end
- addCommandHandler ("toghud",togHUDCMD)
- --alap szerverre kell--
- local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }
- addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
- function ()
- for _, component in ipairs( components ) do
- setPlayerHudComponentVisible( component, false )
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement