#Silvery' Posted July 30, 2014 Share Posted July 30, 2014 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 Link to comment
Alexs Posted July 30, 2014 Share Posted July 30, 2014 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
#Silvery' Posted July 30, 2014 Author Share Posted July 30, 2014 Gracias Alex , ahora me pondre a jugar con la funcion que me distes hasta que vea como funciona Link to comment
Recommended Posts