Jump to content

Se puede usar imagenes para poner la vida, chaleco y oxigen?


#Raiden

Recommended Posts

Posted

Bueno, como dice el titulo quiero hacer un hud que me diga la vida, chaleco y oxigeno, pero no sé si se pueda adaptar con imagenes la vida y eso, Si se pueden me podrían decir como hacer eso?

Posted

Usando la aritmética, puedes calcular la vida y entonces calcular el nuevo ancho de la imagen para después dibujarla con éste nuevo ancho.

Posted

Me descargue un hud que trae esto , me puede servir?

addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
     
  
     
    drawHP(playerhp) 
end) 
  
  
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "imgs/hud_hp.png") 
end 

Posted
Me descargue un hud que trae esto , me puede servir?
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
     
  
     
    drawHP(playerhp) 
end) 
  
  
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "imgs/hud_hp.png") 
end 

Sí, aunque sólo funcionará si usas un 'max-health' de 100.

Posted

Use la misma que puse arriba, intente poniendole un evento pero me pone ese error y se le quito el evento no aparece la imagen

addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
     
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 
addEventHandler("onClientRender", root, drawHP) 

Posted
Use la misma que puse arriba, intente poniendole un evento pero me pone ese error y se le quito el evento no aparece la imagen
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
     
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 
addEventHandler("onClientRender", root, drawHP) 

¿Cuál evento deseas agregarle?

Posted
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
    
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 

Es lo que tiene no leerse bien el manual de lua

Posted
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
    
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 

Es lo que tiene no leerse bien el manual de lua

¿Qué es lua?, leer un manual no te enseña cuándo debes colocar funciones, (las cuáles funcionan como eventos en la libreria de MTA).

Posted

'hp' de la linea 9 no está definida. Remplazalo con getElementHealth(localPlayer).

'scx' tampoco lo está.

Posted
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
    
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*hp 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 

Es lo que tiene no leerse bien el manual de lua

¿Qué es lua?, leer un manual no te enseña cuándo debes colocar funciones, (las cuáles funcionan como eventos en la libreria de MTA).

Hombre aver, me referia al uso de la variable en la funcion, pero bueno, me disculpo

Posted

Ahora me pone este error, ERROR: hud.lua:500 attemp to index a number value

local scx, scy = guiGetScreenSize() 
  
  
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
     
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*getElementHealth(localPlayer). 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 
addEventHandler("onClientRender", root, drawHP) 

Posted
Ahora me pone este error, ERROR: hud.lua:500 attemp to index a number value
local scx, scy = guiGetScreenSize() 
  
  
addEventHandler("onClientRender", root, function() 
    local playerhp = getElementHealth(localPlayer) 
     
    drawHP(playerhp) 
end) 
  
  
function drawHP(hp) 
    local hp_w = 128/100*getElementHealth(localPlayer). 
    dxDrawImageSection(scx-75-15-hp_w-5, 15, hp_w, 5, 128, 15, hp_w, 5, "105.png") 
end 
addEventHandler("onClientRender", root, drawHP) 

Te has fijado en ese punto del final?

local hp_w = 128/100*getElementHealth(localPlayer). 

Te dice que intentas indexarlo como si fuera una tabla, por tanto, nil

  • Recently Browsing   0 members

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