#Raiden Posted August 17, 2015 Posted August 17, 2015 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?
Tomas Posted August 17, 2015 Posted August 17, 2015 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.
aka Blue Posted August 17, 2015 Posted August 17, 2015 Estaba mirando yo por la comunidad y derrepente me salió éste script y ví que tenía el HUD con imágenes como tú dijiste. Míralo a ver. https://community.multitheftauto.com/in ... w&id=11880
Pipee20k Posted August 17, 2015 Posted August 17, 2015 Ese hud esta compilado, no podrá mirar nada e.e Quizás dxDrawImageSection te funcione
#Raiden Posted August 17, 2015 Author Posted August 17, 2015 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
Tomas Posted August 17, 2015 Posted August 17, 2015 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.
#Raiden Posted August 17, 2015 Author Posted August 17, 2015 Cuando lo pongo me dice 'hp' (a nil value)
Tomas Posted August 18, 2015 Posted August 18, 2015 Cuando lo pongo me dice 'hp' (a nil value) Postea la función.
#Raiden Posted August 18, 2015 Author Posted August 18, 2015 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)
Tomas Posted August 18, 2015 Posted August 18, 2015 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?
#Raiden Posted August 18, 2015 Author Posted August 18, 2015 onClientRender, supongo para que se pueda ver la imagen o estoy mal?
#Raiden Posted August 18, 2015 Author Posted August 18, 2015 Pero me pone el error de hp a nil value y si lo quito no aparece nada.
aka Blue Posted August 18, 2015 Posted August 18, 2015 Normal que te ponga nil value, ¿qué es hp para la función?
UserToDelete Posted August 18, 2015 Posted August 18, 2015 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
Tomas Posted August 18, 2015 Posted August 18, 2015 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).
Sasu Posted August 18, 2015 Posted August 18, 2015 'hp' de la linea 9 no está definida. Remplazalo con getElementHealth(localPlayer). 'scx' tampoco lo está.
UserToDelete Posted August 18, 2015 Posted August 18, 2015 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
#Raiden Posted August 18, 2015 Author Posted August 18, 2015 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)
UserToDelete Posted August 18, 2015 Posted August 18, 2015 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
#Raiden Posted August 19, 2015 Author Posted August 19, 2015 Eso ya lo habia hecho, de todas formas no aparece la imagen
Recommended Posts