Jump to content

Hud


Recommended Posts

Anubhav has been scripting for my server and told me edit the hud he made for it but hes at school and I cannot figure out what is wrong with it

tables = { 
    health="", 
  
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        screenW, screenH = guiGetScreenSize()     
    end 
) 
  
function convertNumber ( number )   
    local formatted = number   
    while true do       
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
        if ( k==0 ) then       
            break    
        end   
    end   
    return formatted 
end 
  
function getPedMaxHealth(ped) 
    -- Output an error and stop executing the function if the argument is not valid 
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") 
  
    -- Grab his player health stat. 
    local stat = getPedStat(ped, 24) 
  
    -- Do a linear interpolation to get how many health a ped can have. 
    -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. 
    local maxhealth = 100 + (stat - 569) / 4.31 
  
    -- Return the max health. Make sure it can't be below 1 
    return math.max(1, maxhealth) 
end 
  
addEventHandler("onClientRender", root, 
    function() 
        setPlayerHudComponentVisible( "money", false ) 
        setPlayerHudComponentVisible( "armour", false ) 
        setPlayerHudComponentVisible( "clock", false ) 
        setPlayerHudComponentVisible( "health", false ) 
        setPlayerHudComponentVisible( "ammo", false ) 
        setPlayerHudComponentVisible( "weapon", false ) 
        local hp =  
tostring(math.floor(getElementHealth( localPlayer ))).."%" 
        local money = tostring(convertNumber( getPlayerMoney( localPlayer ))) 
        local h, m = getTime() 
        local ammo = tostring(getPedTotalAmmo(localPlayer) - getPedAmmoInClip(localPlayer).."-"..getPedAmmoInClip(localPlayer)) 
        dxDrawText("HEALTH: "..hp, 280, (screenH - 42) / 1.09, (280) + 423, ( (screenH - 42) / 1.09) + 42, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) 
        dxDrawText("HEALTH: "..hp, 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) 
        dxDrawText("MONEY: $"..money, 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) 
        dxDrawText("MONEY: $"..money, 280, (screenH - 42) / 1.14, (280) + 257, ( (screenH - 42) / 1.14) + 42, tocolor(0, 100, 0, 154), 1.00, "pricedown", "center", "top", true, true, true, true, false) 
        dxDrawText("TIME: "..h..":"..m, 277, 828, 416, 860, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) 
        dxDrawText("TIME: "..h..":"..m, 276, (screenH - 32) / 1.2, (276) + 139, ( (screenH - 32) / 1.2) + 32, tocolor(56, 56, 56, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false 
    end 
) 
  

Link to comment

ever heard of /debugscript 3?

try this

tables = { 
    health="", 
  
} 
  
function convertNumber ( number )   
    local formatted = number   
    while true do       
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
        if ( k==0 ) then       
            break   
        end   
    end   
    return formatted 
end 
  
function getPedMaxHealth(ped) 
    -- Output an error and stop executing the function if the argument is not valid 
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") 
  
    -- Grab his player health stat. 
    local stat = getPedStat(ped, 24) 
  
    -- Do a linear interpolation to get how many health a ped can have. 
    -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. 
    local maxhealth = 100 + (stat - 569) / 4.31 
  
    -- Return the max health. Make sure it can't be below 1 
    return math.max(1, maxhealth) 
end 
  
addEventHandler("onClientRender", root, 
    function() 
        setPlayerHudComponentVisible( "money", false ) 
        setPlayerHudComponentVisible( "armour", false ) 
        setPlayerHudComponentVisible( "clock", false ) 
        setPlayerHudComponentVisible( "health", false ) 
        setPlayerHudComponentVisible( "ammo", false ) 
        setPlayerHudComponentVisible( "weapon", false ) 
        local hp = getElementHealth (localPlayer) 
        local money = convertNumber(getPlayerMoney(localPlayer)) 
        local h, m = getTime() 
        local ammo = getPedTotalAmmo(localPlayer)-getPedAmmoInClip(localPlayer).."-"..getPedAmmoInClip(localPlayer) 
        local screenW, screenH = guiGetScreenSize() 
         
        dxDrawText("HEALTH: "..math.floor(tostring(hp)).."%", 280, (screenH - 42) / 1.09, (280) + 423, ( (screenH - 42) / 1.09) + 42, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) 
        dxDrawText("HEALTH: "..math.floor(tostring(hp)).."%", 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) 
        dxDrawText("MONEY: $"..money, 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) 
        dxDrawText("MONEY: $"..money, 280, (screenH - 42) / 1.14, (280) + 257, ( (screenH - 42) / 1.14) + 42, tocolor(0, 100, 0, 154), 1.00, "pricedown", "center", "top", true, true, true, true, false) 
        dxDrawText("TIME: "..h..":"..m, 277, 828, 416, 860, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) 
        dxDrawText("TIME: "..h..":"..m, 276, (screenH - 32) / 1.2, (276) + 139, ( (screenH - 32) / 1.2) + 32, tocolor(56, 56, 56, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false 
    end 
) 

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...