myonlake Posted October 15, 2011 Share Posted October 15, 2011 (edited) Hello, I am trying to do a script that prevents vehicles from exploding. I have done this like in my fuel script, it has two timers that check the same thing. But, in this one it doesn't work. I am sure I have missed a lot of things in this one, but, I am still tired so, could you help me find the way? I'm lost. local root = getResourceRootElement(getThisResource()) local rElement = getRootElement() -- Preventing Explosion, Timer 1 function preventExplosion1(thePlayer) local theElement = getElementType(source) local theHealth = getElementHealth(source) if theElement == "vehicle" then if theHealth <= 250 then setVehicleEngineState(source, false) setElementHealth(source, 260) else setTimer(preventExplosion2, 1000, 1) end end end addEventHandler("onResourceStart", root, preventExplosion1) -- Preventing Explosion, Timer 2 function preventExplosion2(thePlayer) local theElement = getElementType(source) local theHealth = getElementHealth(source) if theElement == "vehicle" then if theHealth <= 250 then setVehicleEngineState(source, false) setElementHealth(source, 260) else setTimer(preventExplosion1, 1000, 1) end end end Edited May 30, 2019 by myonlake Link to comment
Castillo Posted October 15, 2011 Share Posted October 15, 2011 function vehicleDamage(loss) local vehHealth = getElementHealth(source) if (vehHealth < 300) then setElementHealth(source, 300) setVehicleEngineState(source, false) end end addEventHandler("onVehicleDamage", root, vehicleDamage) Should work. 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