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