Configuration

Configuration

Server Configuration

Server owners can configure general behavior in the config.lua file. These settings apply server-wide.

Configuration File Structure

Location: config.lua

Config = {}
 
Config.Command = 'autopilot'
Config.DistanceCheckInterval = 500
Config.KeyCheckInterval = 0
Config.EnableNotifications = true
Config.BlockedVehicleClasses = { ... }

General Settings

Config.Command

Config.Command = 'autopilot'

Description: The chat command used to open/close the autopilot UI panel.

Type: string

Default: 'autopilot'

Players type /autopilot in chat (or bind it to a key) to toggle the panel.


Performance Settings

Config.DistanceCheckInterval

Config.DistanceCheckInterval = 500

Description: How often (in milliseconds) the script checks the distance to the destination.

Type: number

Default: 500

Higher values reduce CPU usage but make arrival detection less precise.


Config.KeyCheckInterval

Config.KeyCheckInterval = 0

Description: How often (in milliseconds) the script checks for brake/handbrake key presses.

Type: number

Default: 0 (every frame)

⚠️

Setting this above 0 will add delay to cancel responsiveness. The default of 0 is recommended.


Notification Settings

Config.EnableNotifications

Config.EnableNotifications = true

Description: Whether to show ox_lib notification messages when autopilot starts, stops, or encounters errors.

Type: boolean

Default: true

ValueBehavior
trueNotifications shown for all autopilot events
falseNo notifications, silent operation

Vehicle Restrictions

Config.BlockedVehicleClasses

Config.BlockedVehicleClasses = {
    -- 8,   -- Motorcycles
    13,  -- Cycles (bicycles)
    14,  -- Boats
    15,  -- Helicopters
    16,  -- Planes
    21,  -- Trains
}

Description: Vehicle classes that cannot use autopilot. Players in these vehicles will see an error when trying to start.

Type: table (array of vehicle class IDs)

Default: Blocks bicycles, boats, helicopters, planes, and trains

Class IDVehicle Type
0Compacts
1Sedans
2SUVs
3Coupes
4Muscle
5Sports Classics
6Sports
7Super
8Motorcycles
9Off-road
10Industrial
11Utility
12Vans
13Cycles
14Boats
15Helicopters
16Planes
17Service
18Emergency
19Military
20Commercial
21Trains
22Open Wheel

Motorcycles (class 8) are commented out by default. Uncomment the line if you experience issues with autopilot on motorcycles.


Player Settings (In-Game UI)

Driving style, max speed, and stopping distance are no longer configured in config.lua. Each player controls these settings through the in-game autopilot UI panel, and their preferences are automatically saved between sessions.

When a player opens the autopilot panel (/autopilot), they can adjust the following settings:

Driving Style

Players choose between three driving styles via a dropdown in the UI:

StyleBehavior
NormalObeys traffic laws, stops at red lights
RushedFast driving, avoids vehicles and pedestrians
AggressiveIgnores traffic rules, avoids only vehicles and peds

Max Speed

Players set their maximum driving speed using a slider ranging from 20 to 160 km/h (12 to 99 mph).

Stopping Distance

Players configure how close (in meters) the vehicle stops to the waypoint using a slider ranging from 2m to 20m.

How Settings Are Saved

Player settings are persisted using FiveM's Key-Value Pair (KVP) system under the key legends_autopilot:settings. Settings are saved automatically whenever a player changes them in the UI and are restored when the player reconnects. No server-side storage or database is required.

Default values for new players:

SettingDefault
Max Speed~162 km/h (45.0 m/s)
Driving StyleRushed
Stopping Distance5m

Need Help?

Join our Discord for support: discord.gg/lgnds (opens in a new tab)


Legends Store - Premium FiveM Scripts