Jump to content

Vehicle engine starter


gujuk2

Recommended Posts

Posted

Hi there! I've been trying to make a script for vehicle engine starter.
My idea is, that player would have to hold down a key for 2 seconds and then the engine would start.

Is there anybody that can help me with this please? :)

Posted
function engine()
	local vehicle = getPedOccupiedVehicle(localPlayer)
	if isElement(vehicle) and getPedOccupiedVehicleSeat(localPlayer) == 0 then
		local state = getVehicleEngineState(vehicle)
		if not state then
			startTimer = 
			setTimer(
				function()
					if isElement(vehicle) and getPedOccupiedVehicleSeat(localPlayer) == 0 then
						setVehicleEngineState(vehicle, true)
					end
				end
			, 2000, 1)
		else
			setVehicleEngineState(vehicle, false)
		end
	end
end

function resetEngine()
	if isTimer(startTimer) then killTimer(startTimer) end
end

bindKey("2", "down", engine)
bindKey("2", "up", resetEngine)

 

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