Jump to content

Setting car max health


Chris!i!

Recommended Posts

function HEALTH ( )
   for _,v in pairs(getElementsByType("vehicle")) do
    if getElementModel(v) == 491 then
      setElementHealth ( v, getElementHealth(v) + 50 )
    
      
      end
   end
end

setTimer(HEALTH, 5000, 0)

 

So vehicle's health is going higher then the maximum i tried 2 ways to fix but failed, any helps.

Link to comment
function HEALTH ( )
	for _,v in pairs(getElementsByType("vehicle")) do
		if getElementModel(v) == 491 then
			if ( getElementHealth(v) < 1000 ) then -- if the health of this vehicle less than 1000 will give it + 50
				setElementHealth ( v, getElementHealth(v) + 50 )
			end
		end
	end
end

setTimer(HEALTH, 5000, 0)

 

Link to comment
29 minutes ago, NssoR said:

function HEALTH ( )
	for _,v in pairs(getElementsByType("vehicle")) do
		if getElementModel(v) == 491 then
			if ( getElementHealth(v) < 1000 ) then -- if the health of this vehicle less than 1000 will give it + 50
				setElementHealth ( v, getElementHealth(v) + 50 )
			end
		end
	end
end

setTimer(HEALTH, 5000, 0)

 

That's completely wrong, it wont work, + tested it.

What i want is that i don't want the vehicle to get more than 1000 HEALTH

Link to comment
function HEALTH ( )
	for _,v in pairs(getElementsByType("vehicle")) do
		if getElementModel(v) == 491 then
			if ( getElementHealth(v) < 1000 ) then 
				setElementHealth ( v, getElementHealth(v) + 50 )
				if ( getElementHealth(v) > 1000 ) then 
					setElementHealth ( v, 1000 )
				end
			end
		end
	end
end

setTimer(HEALTH, 5000, 0)

 

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