Vehicle Air Control

Update 17-12-2018

I will no longer be maintaining/supporting this resource. The GitHub repo has been archived. Fork it if you want to update it yourself.

Very simple script that disables steering/leaning of your vehicle when you are in the air.

Requested here: [REQUEST] Vehicle air controls

Download:
VehicleAirControl.zip (939 Bytes)

Code, in case you want to add this to your own scripts:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local veh = GetVehiclePedIsIn(PlayerPedId(), false)
        if DoesEntityExist(veh) and not IsEntityDead(veh) then
            local model = GetEntityModel(veh)
            -- If it's not a boat, plane or helicopter, and the vehilce is off the ground with ALL wheels, then block steering/leaning left/right/up/down.
            if not IsThisModelABoat(model) and not IsThisModelAHeli(model) and not IsThisModelAPlane(model) and IsEntityInAir(veh) then
                DisableControlAction(0, 59) -- leaning left/right
                DisableControlAction(0, 60) -- leaning up/down
            end
        end
    end
end)

You can do whatever you want with this. I don’t care if you release this with another script. As it’s literally just 14 lines of code.

Note there are some possible bugs which I haven’t tested and I don’t feel like fixing for this simple script, feel free to do it yourself and post the updated version in the replies below. Some of the things that may cause issues (untested):

  • Using opressors?
  • Using the ruiner 2000?
  • Using other amphibious vehicles?
8 Likes

The only thing I would recommend is adding a provision for motorcycles.

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local veh = GetVehiclePedIsIn(PlayerPedId(), false)
        if DoesEntityExist(veh) and not IsEntityDead(veh) then
            local model = GetEntityModel(veh)
            -- If it's not a boat, plane or helicopter, and the vehilce is off the ground with ALL wheels, then block steering/leaning left/right/up/down.
            if not IsThisModelABoat(model) and not IsThisModelAHeli(model) and not IsThisModelAPlane(model) and not IsThisModelABike(model) and not IsThisModelABicycle(model) and IsEntityInAir(veh) then
                DisableControlAction(0, 59) -- leaning left/right
                DisableControlAction(0, 60) -- leaning up/down
            end
        end
    end
end)
3 Likes

I can still control with A and D and the number pad

1 Like

What?.. For me it stopped both the controller and the keyboard from using left/right/up/down controls or it must have been some testing that got messed up.

Works for me.

(20 Characters)

Cool, adding a blacklist for the ruiner2000, oppressor etc so they aren’t affected looks easy enough. If vehicle is not blacklisted then run code, else end.

is there a way of making this so that you can’t roll a car back onto its wheels when its rolled over i hoped this would do it but nope

3 Likes

@RowDog use this damage script. It prevents rolling your vehicle back on it’s wheels even if only on your side.

I have added a blacklist for this. Vehicles in the Blacklist will bypass the No Vehicle Air Control. You can still control Boats, Planes, Motos, Bikes, Helis in the air. But also added the blacklist so you can fly the deluxo & ruiner2 in the air.

local blacklistedModels = {
	"deluxo",
	"ruiner2",
}

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local veh = GetVehiclePedIsIn(PlayerPedId(), false)
        if DoesEntityExist(veh) and not IsEntityDead(veh) then
            local model = GetEntityModel(veh)
            -- If it's not a boat, plane or helicopter, and the vehilce is off the ground with ALL wheels, then block steering/leaning left/right/up/down.
            if not IsThisModelBlacklisted(veh) and not IsThisModelABoat(model) and not IsThisModelAHeli(model) and not IsThisModelAPlane(model) and not IsThisModelABike(model) and not IsThisModelABicycle(model) and IsEntityInAir(veh) then
                DisableControlAction(0, 59) -- leaning left/right
                DisableControlAction(0, 60) -- leaning up/down
            end
        end
    end
end)

function IsThisModelBlacklisted(veh)
	local model = GetEntityModel(veh)

	for i = 1, #blacklistedModels do
		if model == GetHashKey(blacklistedModels[i]) then
			return true
		end
	end
	return false
end
1 Like

Update 17-12-2018

I will no longer be maintaining/supporting this resource. The GitHub repo has been archived. Fork it if you want to update it yourself.