Stylez Posted March 15, 2012 Share Posted March 15, 2012 Hey everybody. i am newbie in MTA scripting, but i badly wanna learn it and after few weeks of reading wiki. i tried to make my own script. which will delete the blown cars. i managed to make it so far (serverSide) function refresh (theVehicle) local vehicles = getElementsByType("Vehicle") if isVehicleBlown(theVehicle) then destroyElement(vehicles) end end addEventHandler("onVehicleExplode", getRootElement(), refresh) setTimer(refresh, 5000, 0) but when i run it. it shows errors in debug "Bad argument @ isVehicleBlown" sry, for my english :] Link to comment
TAPL Posted March 15, 2012 Share Posted March 15, 2012 function refresh () destroyElement(source) end addEventHandler("onVehicleExplode", root, refresh) Link to comment
Stylez Posted March 15, 2012 Author Share Posted March 15, 2012 thanks, but it works only without timer, when i add timer it says bad argument @ destroyElement Link to comment
Kenix Posted March 15, 2012 Share Posted March 15, 2012 (edited) Yes, because you not use argument in timer. Also bad idea add event handler in timer And i not understand why you need timer. Maybe you need if vehicle explode it destroyed in next seconds? function fExplode ( ) setTimer( destroyElement, 5000, 1, source ) end addEventHandler( 'onVehicleExplode', root, fExplode ) You mean it? Edited March 15, 2012 by Guest Link to comment
TAPL Posted March 15, 2012 Share Posted March 15, 2012 i think this what you want function refresh () setTimer(destroyElement, 5000, 1,source) end addEventHandler("onVehicleExplode", root, refresh) Link to comment
Stylez Posted March 15, 2012 Author Share Posted March 15, 2012 Yes, because you not use argument in timer.Also bad idea add event handler in timer And i not understand why you need timer. Maybe you need if vehicle explode it destroyed in next seconds? function fExplode ( ) setTimer( destroyElement, 5000, 1, source ) end addEventHandler( 'onVehicleExplode', root, fExplode ) You mean it? yes thats what i meant. thankyou. :] 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