HeavyMetal Posted February 2, 2013 Share Posted February 2, 2013 i use a resource to save all cars on my server, and it saves destroyed cars too, what is a problem,so i almost fixed this problem by using a script that delete the vehicle when it explode, but now i noticed that if a car fall on the water it will reach 0 life and get destroyed without exploding, so it will not get deleted by the server and will get saved. anyone knows a way to delete all 0 life cars or something triggered by the vehicle falling on the water to delete itself? i couldnt find anything on resources or in the forums about this, so im posting. thanks Link to comment
Anderl Posted February 2, 2013 Share Posted February 2, 2013 onClientVehicleDrown getElementHealth Link to comment
Castillo Posted February 2, 2013 Share Posted February 2, 2013 I'm not sure if that event actually works, I tried to use it yesterday and it didn't work, same today with latest nightly. Link to comment
Baseplate Posted February 2, 2013 Share Posted February 2, 2013 setTimer( function( ) for _, aVehicle in next, getElementsByType 'vehicle' do if (isElementInWater( aVehicle )) or (getElementHealth(aVehicle) == 0)) then destroyElement(aVehicle) end end end, 5000, 0 ) Link to comment
HeavyMetal Posted February 3, 2013 Author Share Posted February 3, 2013 is not working but thanks anyway tried to modify but i cant make it work Link to comment
DNL291 Posted February 3, 2013 Share Posted February 3, 2013 Try this: setTimer( function() for _,vehicle in ipairs(getElementsByType("vehicle")) do if isElementInWater(vehicle) and getElementHealth(vehicle) == 0 then destroyElement(vehicle) end end end, 1300, 0 ) Link to comment
HeavyMetal Posted February 3, 2013 Author Share Posted February 3, 2013 (edited) thanks , it worked! Edited February 3, 2013 by Guest Link to comment
HeavyMetal Posted February 8, 2013 Author Share Posted February 8, 2013 i found a problem, dont know if i caused it but, i removed the getElementHealth part to delete all cars in the water even if it is not destroyed, and i found out that when i start the resource it is deleting all cars in the server. what is wrong? setTimer( function() for _,vehicle in ipairs(getElementsByType("vehicle")) do if isElementInWater(vehicle) then destroyElement(vehicle) end end end, 1300, 0 ) Link to comment
Castillo Posted February 8, 2013 Share Posted February 8, 2013 You created it server side? if so, I had that problem too, isElementInWater returns true even when not in water, I had to do it client side instead. 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