Jump to content

Help


-.Paradox.-

Recommended Posts

Hello,i made this hud but i want to appear for all resolutions, thanks.

P.S: I'm using 1366x768 resolution.

  
addEventHandler("onClientResourceStart", resourceRoot, 
  
    function() 
     
    end 
) 
  
  
addEventHandler("onClientRender", root, 
  
    function() 
  
--Gets some elements 
    local pHealth = math.floor (getElementHealth(localPlayer)) 
    if pHealth > 200 then 
    pHealth = pHealth / 2 
    end 
    local armor = math.floor(getPedArmor ( getLocalPlayer() )) 
    if armor > 100 then 
    armor = armor / 2 
    end 
    local moneycount=getPlayerMoney(getLocalPlayer()) 
    local money= '$' ..moneycount 
  
--Draw the elements 
        dxDrawRectangle(1184, 54, 134, 36, tocolor(0, 0, 0, 255), true) 
        dxDrawRectangle(1185, 55, 132*(pHealth/200), 34, tocolor(255, 0, 0, 255), true) 
        dxDrawRectangle(1184, 94, 134, 37, tocolor(0, 0, 0, 255), true) 
        dxDrawRectangle(1185, 95, 132*(armor/100), 35, tocolor(0, 0, 255, 2555), true) 
        dxDrawText("Armor "..armor.."%", 1229, 105, 1287, 120, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
        dxDrawText("Health "..pHealth.."%", 1228, 62, 1287, 79, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
    dxDrawText(tostring (money), 1165, 28, 1350, 74, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
    dxDrawText(tostring (money), 1165, 26, 1350, 72, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
    dxDrawText(tostring (money), 1163, 28, 1348, 74, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
    dxDrawText(tostring (money), 1163, 26, 1348, 72, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
    dxDrawText(tostring (money), 1164, 27, 1349, 73, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
    end 
) 
  

Link to comment

I do it like this, however, there is probably a more advanced way to do it. But I've always done it like this and for the most part it works well. I believe I saw 50p reply to a thread with a image of how to do it "properly". :)

First I get the client's screen size using guiGetScreenSize. You then do math like this;

local screenX, screenY = guiGetScreenSize() 
  
function broDoYouEvenDraw() 
    dxDrawRectangle(screenX*(1184/1366), screenY*(54/768), screenX*(134/1366), screenY*(36/768), tocolor(0, 0, 0, 255), true) 
end 

Also, you might wanna re-consider using Ped/Player Events to check if a player was hit and how much armour/health was lost. Currently, depending on what your FPS Limit is set to - you're checking all of that 30-60 times per second.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...