A simple autopilot Lua class for fiveM planes
Just copy the autopilot.lua to your projects folder Add the following line to your __rescource.lua:client_scripts {'autopilot.lua',}
autopilot:activateAutopilot(pilot, plane, x, y, z, speed, autospeed, model)
pilot
is the Pilots Player Entity, which you can get with GetPlayerPed()
plane
is the Planes Entity, which you can get with GetVehiclePedIsIn(GetPlayerPed())
x
is the destinations x-coordinate
y
is the destinations y-coordinate
z
is the altitude
speed
is the planes airspeed
autospeed
is a boolean value(true
/false
), which is for enabling or disabling AutomaticThrustControl, which reduces the propability of being too slow
model
is the planes model name, which you can get with GetEntityModel(GetVehiclePedIsIn(GetPlayerPed()))
Disable:
autopilot:deactivateAutopilot(pilot)
pilot
is the Pilots Player Entity, which you can get with GetPlayerPed()
3. Add to your resource.lua file
1. open your project
2. open your __resource.lua
3. Add the following lines:
client_scripts {
"@autopilot/autopilot.lua",
}
client_scripts {
"@autopilot/autopilot.lua",
}
Example
Enable:
autopilot:activateAutopilot(GetPlayerPed(), GetVehiclePedIsIn(GetPlayerPed()), 2000, 1573, 2000, 250, true, GetEntityModel(GetVehiclePedIsIn(GetPlayerPed())))
Disable:
autopilot:deactivateAutopilot(GetPlayerPed())