boro Posted November 24, 2014 Posted November 24, 2014 Hi all i have problem vith my script i want show progressbar for ped i have set extra healt it work good but if i want check ped health with exported function getElementExtraHealth then it show this warning why ? ERROR:healthbar/1.lua:12: attempt to perform arithmetic on local "health" (a nill value) idk why it show nill value because i have set extrahealth for ped and it work please help this is code dxDrawRectangle( X - 30, Y - 20, 60, 10, tocolor( 0, 0, 0, 120) ) local health = exports["extra_health"]:getElementExtraHealth(v) local lineLength = 56 * ( health / 10000 ) -- line 12 dxDrawRectangle( X - 28, Y - 18, lineLength, 6, tocolor( 255, 0, 0, 100 ) )
Anubhav Posted November 24, 2014 Posted November 24, 2014 dxDrawRectangle( X - 30, Y - 20, 60, 10, tocolor( 0, 0, 0, 120) ) local health = exports["extra_health"]:getElementExtraHealth(v) local lineLength = 56 * ( health / 10000 ) -- line 12 dxDrawRectangle( X - 28, Y - 18, lineLength, 6, tocolor( 255, 0, 0, 100 ) ) outputChatBox(tostring(health)) what does this output?
Dealman Posted November 25, 2014 Posted November 25, 2014 what does this output? Judging by the error he posted - it returns nil. @boro: Where and how is the variable v defined?
boro Posted November 25, 2014 Author Posted November 25, 2014 i have v defined check it for _, v in ipairs ( getElementsByType ( "ped" ) ) do if ( getElementModel ( v ) == 281 ) then local x, y, z = getElementPosition( v ) if isElementOnScreen( v ) then local X, Y = getScreenFromWorldPosition( x, y, z ) if X then dxDrawRectangle( X - 30, Y - 20, 60, 10, tocolor( 0, 0, 0, 120) ) local health = exports["extra_health"]:getElementExtraHealth(v) local lineLength = 56 * ( health / 100 ) dxDrawRectangle( X - 28, Y - 18, lineLength, 6, tocolor( 255, 0, 0, 100 ) )
boro Posted November 25, 2014 Author Posted November 25, 2014 dxDrawRectangle( X - 30, Y - 20, 60, 10, tocolor( 0, 0, 0, 120) ) local health = exports["extra_health"]:getElementExtraHealth(v) local lineLength = 56 * ( health / 10000 ) -- line 12 dxDrawRectangle( X - 28, Y - 18, lineLength, 6, tocolor( 255, 0, 0, 100 ) ) outputChatBox(tostring(health)) what does this output? chatbox say nill
Anubhav Posted November 25, 2014 Posted November 25, 2014 That means you din't set extra health to it?
Dealman Posted November 25, 2014 Posted November 25, 2014 Try this, what does it output? local health = exports["extra_health"]:getElementExtraHealth(v) outputChatBox("Value: ["..tostring(v).."]") Edit: Are you absolutely sure the resource "extra_health" is running? It has to be running for it to work.
boro Posted November 25, 2014 Author Posted November 25, 2014 It show this Value: [userdata: 000000A9] And yes i have set extrahealth to 10000 and work it good
boro Posted November 25, 2014 Author Posted November 25, 2014 oh resolved i rename resource name and now it work good But Ty all.
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