MummyKillerSLO Posted May 22, 2010 Share Posted May 22, 2010 Hello! I am new at MTA Scripting and I want to ask you, why vehicles don't fix using my code: function AutoFix() vehicles = getElementsByType ( "vehicle" ) for vehicleKey,vehicleValue in ipairs(vehicles) do fixVehicle ( vehicleValue ) setElementHealth ( vehicleValue, 1000.0 ) end end setTimer(AutoFix,1000,1) I am using just MTA editor to make maps, so I need just this command. Any help will be great. Link to comment
dzek (varez) Posted May 22, 2010 Share Posted May 22, 2010 1. use lua tags, not code 2. setTimer(AutoFix,1000,1) -- 3rd argument is time to repeat (check wiki page!) setTimer(AutoFix,1000,0) -- this one is correct Link to comment
50p Posted May 22, 2010 Share Posted May 22, 2010 Hello!I am new at MTA Scripting and I want to ask you, why vehicles don't fix using my code: function AutoFix() vehicles = getElementsByType ( "vehicle" ) for vehicleKey,vehicleValue in ipairs(vehicles) do fixVehicle ( vehicleValue ) setElementHealth ( vehicleValue, 1000.0 ) end end setTimer(AutoFix,1000,1) I am using just MTA editor to make maps, so I need just this command. Any help will be great. This timer will call AutoFix function only once and if this code is not attached to any event, it will be called once after resource starts. I'd suggest to add a command: function AutoFix () -- your code in AutoFix is fine end addCommandHandler( "fixall", AutoFix ) If you want the timer to call your AutoFix function unlimited amount of times every second then use 0 for the 3dr parameter (which is 1 in your code). Link to comment
MummyKillerSLO Posted May 22, 2010 Author Share Posted May 22, 2010 Thank you guys! It's working! Link to comment
dzek (varez) Posted May 23, 2010 Share Posted May 23, 2010 btw: setting cars immune to damages could be better i think.. 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