1LoL1 Posted November 7, 2015 Share Posted November 7, 2015 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
Walid Posted November 7, 2015 Share Posted November 7, 2015 it will work only onClientResourceStart ^ , you need to use an other event example "onClientPlayerDamage" Link to comment
1LoL1 Posted November 7, 2015 Author Share Posted November 7, 2015 it will work only onClientResourceStart ^ , you need to use an other event example "onClientPlayerDamage" 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%. Link to comment
Walid Posted November 7, 2015 Share Posted November 7, 2015 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
1LoL1 Posted November 7, 2015 Author Share Posted November 7, 2015 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
Walid Posted November 7, 2015 Share Posted November 7, 2015 simply you can use setTimer or onClientRender event . Link to comment
1LoL1 Posted November 7, 2015 Author Share Posted November 7, 2015 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
Walid Posted November 7, 2015 Share Posted November 7, 2015 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
1LoL1 Posted November 7, 2015 Author Share Posted November 7, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now