Jump to content

guiCreateLabel and getElementHealth


xbenny2506x

Recommended Posts

Posted

HI :)

I have a problem with the guiCreateLabel and getElementHealth.

I want that the player see his health. So i have make this script

...
 
local client = getLocalPlayer()
 
local healthtext = guiCreateLabel(0.35,0.40,0.94,0.2, getElementHealth ( client ), true)
guiSetFont ( healthtext, "sa-header" )
guiLabelSetColor ( healthtextt, 255, 234, 0 )
 
...
 
addEventHandler("onClientPlayerJoin", getRootElement(), fullhealth)

But i see nothing!

Can me someone say, how i can make it that the player see his health?

Posted (edited)

getElementHealth() returns an integer, not a string. --correction, it returns a float. (a number with decimal places)

Use tostring().

Don't forget you'll have to update the label with guiSetText() regularly too, which also takes a string.

Edited by Guest
Posted

THX now my script work!

But a i have a little problem with the health number.

Sometimes is see 98.599998474121 or other so long health numbers.

How can i make it that is see only numbers so long without the " . "????

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