Jump to content

Health


iSmokee

Recommended Posts

Posted

Hola, Como podría hacer en un dxDrawRectangle que me diga la vida que tendría y cuando me quitan vida se me valla borrando el dxDrawRectangle y se me cambie de color alguien me podría dar un ejemplo gracias se que se usa getElementHealth pero lo que no se es como hacer para que funcione en un health. Gracias

Posted

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 
) 

Posted
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 :)

  • Recently Browsing   0 members

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