Jump to content

Automatic Vehicle Fix


Recommended Posts

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. :fadein:

Link to comment
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. :fadein:

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...