Jump to content

[HELP] Update


1LoL1

Recommended Posts

Hello, i created script but when anyone attacked me and taked Health of me i see always old Health.

So my question is how i can update health in label?

so i must use:

setTimer

setTimer(function()

?

function health () 
local health2 = math.floor(getElementHealth(localPlayer)) 
local screenWidth, screenHeight = guiGetScreenSize() 
local health = guiCreateLabel(screenWidth - 170, screenHeight - 15, screenWidth , 20, "", false) 
guiSetText(health, ""..health2.."") 
end 
addEventHandler("onClientResourceStart", getRootElement(), health) 

Link to comment
But I think even when I jump out of something so it takes away my HP and still shows 100% and I jumped and I have 95%.

lol

function playerDamage (attacker)  
    if (attacker and getElementType(attacker) == "player" and attacker ~= localPlayer) then   
        -- guiSetText 
    else 
        -- guiSetText 
    end  
end 
addEventHandler ( "onClientPlayerDamage",getLocalPlayer(), playerDamage ) 

Link to comment
But I think even when I jump out of something so it takes away my HP and still shows 100% and I jumped and I have 95%.

lol

function playerDamage (attacker)  
    if (attacker and getElementType(attacker) == "player" and attacker ~= localPlayer) then   
        -- guiSetText 
    else 
        -- guiSetText 
    end  
end 
addEventHandler ( "onClientPlayerDamage",getLocalPlayer(), playerDamage ) 

I don't mean attacker.. but i want only update health in label..

Link to comment
simply you can use setTimer or onClientRender event .

Thanks i used onClientRender work but label is created 50x

function health () 
local health2 = math.floor(getElementHealth(localPlayer)) 
local screenWidth, screenHeight = guiGetScreenSize() 
local health = guiCreateLabel(screenWidth - 170, screenHeight - 15, screenWidth , 20, "", false) 
guiSetText(health, ""..health2.."") 
guiSetFont(health, "default-bold-small") 
end 
addEventHandler("onClientRender", getRootElement(), health) 

Link to comment

Thanks i used onClientRender work but label is created 50x

function health () 
local screenWidth, screenHeight = guiGetScreenSize() 
health = guiCreateLabel(screenWidth - 170, screenHeight - 15, screenWidth , 20, "", false) 
guiSetFont(health, "default-bold-small") 
end 
addEventHandler("onClientResourceStart", getRootElement(), health) 
  
function ste() 
local health2 = math.floor(getElementHealth(localPlayer)) 
guiSetText(health, ""..health2.."") 
end  
addEventHandler("onClientRender", getRootElement(), ste) 

Link to comment

Thanks i used onClientRender work but label is created 50x

function health () 
local screenWidth, screenHeight = guiGetScreenSize() 
health = guiCreateLabel(screenWidth - 170, screenHeight - 15, screenWidth , 20, "", false) 
guiSetFont(health, "default-bold-small") 
end 
addEventHandler("onClientResourceStart", getRootElement(), health) 
  
function ste() 
local health2 = math.floor(getElementHealth(localPlayer)) 
guiSetText(health, ""..health2.."") 
end  
addEventHandler("onClientRender", getRootElement(), ste) 

Thanks works.

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...