Hey, someone maybe have idea why the engine here isnt starting again in the helicopters? Of course in cars its working perfectly, but not in helicopters.
local MotorOn = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = cache.ped
local vehicle = GetVehiclePedIsIn(ped, false)
local inCar = IsPedInAnyVehicle(ped, false)
if inCar and vehicle ~= nil and vehicle ~= 0 then
if IsControlJustReleased(0, 75) then
if not MotorOn and GetVehicleEngineState(vehicle) then
MotorOn = true
end
if MotorOn then
SetVehicleEngineOn(vehicle, true, true, false)
end
else
if GetVehicleEngineState(vehicle) then
MotorOn = true
else
MotorOn = false
end
end
end
end
end)
I even add something like this, but it doesnt help
if MotorOn then
while MotorOn do
print(GetIsVehicleEngineRunning(vehicle))
if not GetIsVehicleEngineRunning(vehicle) then
SetVehicleEngineOn(vehicle, true, false, false)
end
Citizen.Wait(0)
end
end
you will get false as a BOOL when trying to use the IsPedInAnyVehicle(ped, false) native in a aircraft. Try using the IsPedInAnyHeli() native and make a new variable that checks if the ped is in a heli, for example:
local inHeli = IsPedInAnyHeli(ped)
if inHeli then
SetVehicleEngineOn(vehicle, true, true, false)
MotorOn = true
else
MotorOn = false
end
keep in mind that this code is just an example