opnaiC Posted August 26, 2016 Share Posted August 26, 2016 function respawnTimer ( source ) for _, veh in ipairs (getElementsByType("vehicle", resourceRoot)) do if getVehicleOccupant (veh) then ourVehicle = getPedOccupiedVehicle (source) end end end setTimer (respawnTimer, 500, 0) function respawnOnExplode ( ) for _, veh in ipairs (getElementsByType("vehicle", resourceRoot)) do if veh == ourVehicle then respawnVehicle (veh) end end end addEventHandler ("onVehicleExplode", root, respawnOnExplode) The vehicle that the player occupied should respawn on explode. Link to comment
Ab-47 Posted August 26, 2016 Share Posted August 26, 2016 veh would be selecting all vehicles existing which would probably return the function because some elements may not be exploding, sync issues. Try respawnVehicle(source) instead of "veh" Link to comment
LabiVila Posted August 26, 2016 Share Posted August 26, 2016 Also, you don't need an infinite loop to run above. It's pointless doing such, since it'll only use quite some CPU and not do much. You can set the timer once inside the 'onVehicleExplode', would be better Link to comment
EstrategiaGTA Posted August 26, 2016 Share Posted August 26, 2016 Use this: addEventHandler("onVehicleExplode", root, function () local time_ = 5 --in seconds. setTimer(respawnVehicle, time_*1000, 1, source) end ) 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