Jump to content

[Ayuda]hud


Recommended Posts

Hola a todos lo que quiero hacer es simplemente un dxdrawtext el cual mostrara la salud , pero que del 100% al 76% sea un color , luego 75% al 50% otro color y asi hasta terminar me ayudo tomas pero no funciono por ahora solo tengo esto:

  
addEventHandler("onClientRender", root, 
function() 
    local heal = getElementHealth(getLocalPlayer()) 
      if heal == 100 then 
      r, g, b = 5, 116, 9, 255 
      dxDrawText("Health:"..math.ceil (heal).."%", 1253, 527, 1340, 551, tocolor(r, g, b), 3.00, "default-bold", "center", "center", false, false, false, true, false)  
     end 
   end 
) 
  

gracias adelantado :D

Link to comment

Pido disculpas con anticipación por posibles errores, estoy un poco fuera de forma.

function getRGColorFromPercentage(percentage) 
    if not percentage or percentage and type(percentage) ~= "number" or percentage > 100 or percentage < 0 then outputDebugString( "Invalid argument @ 'getRGColorFromPercentage'", 2 ) return false end 
    if percentage > 50 then 
    local temp = 100 - percentage 
        return temp*5.1, 255 
    elseif percentage == 50 then 
    return 255, 255 
    else 
    return 255, percentage*5.1 
    end 
end 
  
addEventHandler("onClientRender", root, 
function() 
    local heal = math.min( getElementHealth(getLocalPlayer()), 100 ) 
    local r, g = getRGColorFromPercentage(heal) 
      dxDrawText("Health:"..math.ceil (heal).."%", 1253, 527, 1340, 551, tocolor(r, g, 0), 3.00, "default-bold", "center", "center", false, false, false, true, false) 
   end 
) 
  

Lo único que hice fue añadir y utilizar la función 'getRGColorFromPercentage', en la wiki hay mas información.

Link to comment
  • Recently Browsing   0 members

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