Jump to content

[HELP] HUD render


iPanda

Recommended Posts

Hi guys. I have a problem with my code is thin. Not play. Please, help.

Here's the code:

local player = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local ox = x/1000 
local oy = y/1000 
local healh = math.ceil( getElementHealth( player )) 
  
scale = guiCreateStaticImage(0, 878, 1440, 27, "data/scale.png", false) 
number = guiCreateStaticImage(0, 864, 1440, 27, "data/number.png", false) 
guiSetVisible( scale, true ) 
guiSetVisible( number, true ) 
  
local HEALTH_line = function() 
    local on = guiSetVisible( line, true ) 
        line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false) 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

I have a problem: not showing beacons that determines the player's life (beacon must move along the X axis, but there is a problem - it does not work)

*I use the Google translator, so if you did not understand me, write, I try to give a more open description.

Link to comment
local player = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
scale = guiCreateStaticImage(0, 878, 1440, 27, "data/scale.png", false) 
number = guiCreateStaticImage(0, 864, 1440, 27, "data/number.png", false) 
guiSetVisible( scale, true ) 
guiSetVisible( number, true ) 
  
local HEALTH_line = function()6 
    local healh = math.ceil( getElementHealth( player )) 
    local ox = x/1000 
    line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false) 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Link to comment
Well , he has to update the health of the player, otherwise it would be 100% only.

How to update the player's health?

* I'm not really a long time to write lua, is not yet a lot of things to be understood.

In the code that I posted.

Now I checked your code. Unfortunately does not work.

* Do not show beacon. (Beacon- is a variable line)

What to do?

Link to comment

Maybe code by xXMADEXx doesn't work because after "function()" number 6. I think it's just misprint.

local player = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
scale = guiCreateStaticImage(0, 878, 1440, 27, "data/scale.png", false) 
number = guiCreateStaticImage(0, 864, 1440, 27, "data/number.png", false) 
guiSetVisible( scale, true ) 
guiSetVisible( number, true ) 
  
function HEALTH_line() 
    local healh = math.ceil( getElementHealth( player )) 
    local ox = x/1000 
    line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false) 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Link to comment
Maybe code by xXMADEXx doesn't work because after "function()" number 6. I think it's just misprint.
local player = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
scale = guiCreateStaticImage(0, 878, 1440, 27, "data/scale.png", false) 
number = guiCreateStaticImage(0, 864, 1440, 27, "data/number.png", false) 
guiSetVisible( scale, true ) 
guiSetVisible( number, true ) 
  
function HEALTH_line() 
    local healh = math.ceil( getElementHealth( player )) 
    local ox = x/1000 
    line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false) 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Ah, my bad. Didn't see the "6" before posting.
Link to comment
Maybe code by xXMADEXx doesn't work because after "function()" number 6. I think it's just misprint.
local player = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
scale = guiCreateStaticImage(0, 878, 1440, 27, "data/scale.png", false) 
number = guiCreateStaticImage(0, 864, 1440, 27, "data/number.png", false) 
guiSetVisible( scale, true ) 
guiSetVisible( number, true ) 
  
function HEALTH_line() 
    local healh = math.ceil( getElementHealth( player )) 
    local ox = x/1000 
    line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false) 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Ah, my bad. Didn't see the "6" before posting.

Yes, but I noticed it before and removed. But all does not work exactly.

* The principle of operation of the lighthouse:

There is a scale - a line lengthwise which must crawl beacon in the X axis, the higher the player's health, the higher the beacon, and when health is spent crawling beacon in the opposite direction. (On the right - rises to the left - is reduced)

Link to comment
local localPlayer = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
function HEALTH_line() 
    local health = math.ceil( getElementHealth( localPlayer )) 
    local ox = x/1000 
    if health then 
          dxDrawImage ( health*ox, 882, 2, 23, "data/line.png", angle, 0, -120 ) 
    end 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Still found one misprint in previous codes.    

local healh = math.ceil( getElementHealth( player ))

line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false)

Link to comment
local localPlayer = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
function HEALTH_line() 
    local health = math.ceil( getElementHealth( localPlayer )) 
    local ox = x/1000 
    if health then 
          dxDrawImage ( health*ox, 882, 2, 23, "data/line.png", angle, 0, -120 ) 
    end 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Still found one misprint in previous codes.    

local healh = math.ceil( getElementHealth( player ))

line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false)

Your code has flaws, I corrected them, but exactly - does not work. I do not know what to do .... .... :cry:

* I will use guiCreateStaticImage

Edited by Guest
Link to comment
local localPlayer = getLocalPlayer() 
local x, y = guiGetScreenSize() 
local oy = y/1000 
  
function HEALTH_line() 
    local health = math.ceil( getElementHealth( localPlayer )) 
    local ox = x/1000 
    if health then 
          dxDrawImage ( health*ox, 882, 2, 23, "data/line.png", angle, 0, -120 ) 
    end 
end 
addEventHandler("onClientRender", getRootElement(), HEALTH_line) 

Still found one misprint in previous codes.    

local healh = math.ceil( getElementHealth( player ))

line = guiCreateStaticImage(health*ox, 882, 2, 23, "data/line.png", false)

Where have you define "angle"?

Link to comment
You are constantly creating a GUI image every render, that's a really bad idea and it won't even work.

Please, could you write me an example of a function similar to the one that I want to do, that I understand and forever decided for themselves the problem

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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