Xabi Posted March 13, 2015 Share Posted March 13, 2015 Hi all, I've got few errors in my script and I need a little bit of help, thanks: function checkVehicleDestroyed(loss) local vehHealth = getElementHealth(source) if vehHealth < 260 then setElementHealth(source, 150) setVehicleEngineState(source, false) setElementData(source, "vehicles.vEngine", false) setTimer(function() blowVehicle(source) addEventHandler("onVehicleExplode", source, sendVehicleToRespawn) end, 10000, 1) end end function makeVehicleDamageProof(thePlayer, seat) if seat == 0 then setVehicleDamageProof(source, true) end end addEventHandler("onVehicleDamage", root, checkVehicleDestroyed) addEventHandler("onVehicleExit", root, makeVehicleDamageProof) So having that code, when I exit the vehicle it will never explode because of nil parameters (it just sets its health to 150 and stops the engine, but the timer gives a nil parameter warning with the source). Thanks for the help. Link to comment
TAPL Posted March 13, 2015 Share Posted March 13, 2015 function checkVehicleDestroyed(loss) local vehHealth = getElementHealth(source) if vehHealth < 260 then setElementHealth(source, 150) setVehicleEngineState(source, false) setElementData(source, "vehicles.vEngine", false) setTimer(function(source) -- add it here blowVehicle(source) addEventHandler("onVehicleExplode", source, sendVehicleToRespawn) end, 10000, 1, source) -- pass the source into the timer end end function makeVehicleDamageProof(thePlayer, seat) if seat == 0 then setVehicleDamageProof(source, true) end end addEventHandler("onVehicleDamage", root, checkVehicleDestroyed) addEventHandler("onVehicleExit", root, makeVehicleDamageProof) 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