Jump to content

Automatic Vehicle Fix


Recommended Posts

Posted

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:

Posted

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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).

Posted

btw: setting cars immune to damages could be better i think..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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