Jump to content

extra_health problem


boro

Recommended Posts

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

Link to comment
  
                        
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?

Link to comment

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

Link to comment
  
                        
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

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