Search the Community
Showing results for tags 'farmspawn'.
-
Hello Community, i would like to have some support here, the code works fine on this script which once the Vehicle damage is below "350", it gets Destroyed in a couple of seconds and then once the script calls this : setTimer( sec, 6000, 0 ) It doesn't spawn a single Vehicle as i wish to, it Spawns an infinate Vehicles on the same place. i just need help to make it spawn Only One. Here is the full code : function sec () local car = createVehicle ( 428, 2317.0588378906,2408.1867675781,10.8203125) setElementData(car,"sec",true) setVehicleDamageProof(car,true) end addEventHandler("onResourceStart", resourceRoot,sec) function checkDamage(player) for _,vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do if getElementData(source,"sec") then else return end if getElementHealth(source) > 350 then setVehicleDamageProof(source,false) setVehicleEngineState(source,true) else setVehicleDamageProof(source,true) setVehicleEngineState(source,false) for i,player in pairs(getVehicleOccupants(source)) do setControlState(souce,"enter_exit",true) --setTimer(respawnVehicle, 6000, 1, source) --------------------------------------------- x, y, z = getElementPosition(source) setTimer ( function() bag = createPickup( x-6, y, z, 3, 1550 ) setElementCollisionsEnabled( bag, false ) end, 4000, 1) -------------------------------------------- setTimer( destroyElement, 1000, 1, source) --setTimer( destroyElement, 50, 1, source) setTimer( sec, 6000, 0 ) end end end end addEventHandler("onVehicleDamage",getRootElement(),checkDamage)