# Configuration

***

## <mark style="color:blue;">Auto Pilot Script Configuration Guide</mark>

This guide provides detailed instructions for configuring the **Auto Pilot Script** for FiveM. The script allows players to enable autopilot for specific vehicles, providing a seamless and automated driving experience. Configuration options include framework detection, vehicle restrictions, notifications, and more.

### <mark style="color:blue;">Main Configuration</mark>

#### <mark style="color:green;">Config.Framework</mark>

* **Description:** This setting determines which framework the script will utilize. The options are `"esx"`, `"qb"`, or `"auto"`. When set to `"auto"`, the script automatically detects the active framework on the server. Use `"auto"` for flexibility or manually set the framework based on your server setup.

  Example:

  ```lua
  Config.Framework = "auto" -- auto, esx, or qb
  ```

#### <mark style="color:green;">Config.debug</mark>

* **Description:** Enables or disables debug mode. When `true`, the script will output detailed information to the console, which can be helpful for troubleshooting during development or testing. Keep it `false` for regular use to avoid unnecessary console messages.

  Example:

  ```lua
  Config.debug = false -- Enable or disable debug mode
  ```

#### <mark style="color:green;">Config.hideCmd</mark>

* **Description:** This setting allows you to define a custom command that players can use to hide the autopilot user interface. It can be helpful for players who prefer a cleaner HUD or only want to display the interface when needed.

  Example:

  ```lua
  Config.hideCmd = 'hideap' -- Command to hide the autopilot UI
  ```

### <mark style="color:blue;">Vehicle Access</mark>

#### <mark style="color:green;">Config.allCarsAllowed</mark>

* **Description:** This option controls whether all vehicles are allowed to use autopilot. Set this to `true` if you want to enable autopilot for every vehicle. If set to `false`, only the vehicles listed in `allowedCars` will be able to use autopilot.

  Example:

  ```lua
  Config.allCarsAllowed = false -- Set to true to allow all vehicles
  ```

#### <mark style="color:green;">Config.allowedCars</mark>

* **Description:** If `Config.allCarsAllowed` is set to `false`, this table defines which vehicles can use the autopilot system. You can list vehicle models by their spawn name, allowing autopilot only for specific cars.

  Example:

  ```lua
  Config.allowedCars = {'t20', 'adder', 'neon'} -- List of allowed vehicles for autopilot
  ```

### <mark style="color:blue;">Locales</mark>

#### <mark style="color:green;">Config.Locales</mark>

* **Description:** This section allows you to customize the messages displayed to players when autopilot is activated or deactivated. You can easily change the text to fit your server's language or tone.

  Example:

  ```lua
  Config.Locales = {
    autopilot_deactivated = 'Autopilot functions are now ~r~disabled~s~.',
    autopilot_activated = 'Autopilot functions are now ~g~enabled~s~.',
  }
  ```

### <mark style="color:blue;">Notifications</mark>

#### <mark style="color:green;">Config.Notify</mark>

* **Description:** This setting allows you to choose between the default notification system or implementing a custom notification function. Set to `"default"` for standard notifications or `"custom"` if you want to create your own.

  Example:

  ```lua
  Config.Notify = 'default' -- Choose between default or custom notifications
  ```

#### <mark style="color:green;">Config.NotifyFunction</mark>

* **Description:** If you choose `"custom"` for `Config.Notify`, this function allows you to define how the notifications are triggered. Insert your custom notification logic here to replace the default behavior.

  Example:

  ```lua
  Config.NotifyFunction = function(msg)
    -- Your custom notify trigger here
  end
  ```

### <mark style="color:blue;">Framework Detection</mark>

#### <mark style="color:green;">getFramework()</mark>

* **Description:** This function automatically detects and returns the active framework being used. It supports ESX, QBCore, or automatic detection. This ensures the script works seamlessly with the server's setup.

  Example:

  ```lua
  function getFramework()
    if Config.Framework == "esx" then
        return exports['es_extended']:getSharedObject(), "esx"
    elseif Config.Framework == "qb" then
        return exports["qb-core"]:GetCoreObject(), "qb"
    elseif Config.Framework == "auto" then
        if GetResourceState('qb-core') == 'started' then
            return exports["qb-core"]:GetCoreObject(), "qb"
        elseif GetResourceState('es_extended') == 'started' then
            return exports['es_extended']:getSharedObject(), "esx"
        end
    end
  end
  ```

***
