Jump to content

Health


iSmokee

Recommended Posts

aca te dejo un ejemplo

function RGColor_interpol(percent) 
    local r,g,b = 255,255,0 
    percent = math.floor(math.min(math.max(percent,0),100)) 
    local RGVAR = ((255*2)*percent*.01)-255 
    if RGVAR == 0 then r,g,b =255,255,0 end 
    if RGVAR < 0 then  
        g =255+RGVAR 
    end 
    if RGVAR > 0 then  
        r = 255-RGVAR 
    end 
    return r,g,b,255 
end 
  
addEventHandler("onClientRender", root,  
function drawhealth() 
local health = getElementHealth( getLocalPlayer() ) 
local r, g, b = RGColor_interpol((health)) 
local barra = 175* ( health / 100 ) 
 dxDrawRectangle(400,100, 175, 35,tocolor( 0, 0, 0, 100 ), false)  
 dxDrawRectangle(400,100, barra, 35,tocolor(r, g, b, 200 ), false) 
end 
) 

Link to comment
aca te dejo un ejemplo
function RGColor_interpol(percent) 
    local r,g,b = 255,255,0 
    percent = math.floor(math.min(math.max(percent,0),100)) 
    local RGVAR = ((255*2)*percent*.01)-255 
    if RGVAR == 0 then r,g,b =255,255,0 end 
    if RGVAR < 0 then  
        g =255+RGVAR 
    end 
    if RGVAR > 0 then  
        r = 255-RGVAR 
    end 
    return r,g,b,255 
end 
  
addEventHandler("onClientRender", root,  
function drawhealth() 
local health = getElementHealth( getLocalPlayer() ) 
local r, g, b = RGColor_interpol((health)) 
local barra = 175* ( health / 100 ) 
 dxDrawRectangle(400,100, 175, 35,tocolor( 0, 0, 0, 100 ), false)  
 dxDrawRectangle(400,100, barra, 35,tocolor(r, g, b, 200 ), false) 
end 
) 

Gracias Alex :)

Link to comment
  • Recently Browsing   0 members

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