Chris!i! Posted October 2, 2016 Share Posted October 2, 2016 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
!#NssoR_) Posted October 2, 2016 Share Posted October 2, 2016 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
Chris!i! Posted October 2, 2016 Author Share Posted October 2, 2016 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
!#NssoR_) Posted October 2, 2016 Share Posted October 2, 2016 (edited) Yeah its like what u want ! Edited October 2, 2016 by NssoR Link to comment
iPrestege Posted October 2, 2016 Share Posted October 2, 2016 I don't know what are you trying to do but making a timer every 5 seconds to get all the cars is a wrong thing Just use 'onVehicleDamage' . Link to comment
Chris!i! Posted October 2, 2016 Author Share Posted October 2, 2016 It didnt work NssoR And prestege, it's only for 1 car ID 491. I want it to get 5 hp every 5 seconds, 5 hp = 50 in mta scripting. I dont want the vehicle to be dmg proof. Link to comment
!#NssoR_) Posted October 2, 2016 Share Posted October 2, 2016 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
Chris!i! Posted October 2, 2016 Author Share Posted October 2, 2016 Thanks it worked. 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