# Configuration

#### Configuration

The configuration for **b2\_vehicleEssentials** is managed through the `config.lua` file. Below are detailed explanations and examples for each configuration option.

**Dynamic Traffic Management**

The traffic density dynamically adjusts based on the number of players online.

* **Enable Dynamic Traffic Management**:

  ```lua
  Config.DynamicTrafficManagement = true
  ```
* **Traffic Density Settings**:

  ```lua
  Config.MaxTrafficDensity = 0.5 -- Base density when no players are online
  Config.MinTrafficDensity = 0.1 -- Minimum density when maximum players are online
  Config.MaxPlayers = 32 -- Maximum number of players expected on the server
  ```

**Automatic Seatbelts**

Automatically applies seatbelts when the player enters a vehicle.

* **Enable Automatic Seatbelts**:

  ```lua
  Config.AutoSeatbeltOnEntry = true
  ```

**Manual Seatbelts**

Toggle seatbelts manually using a customizable keybind.

* **Manual Seatbelt Keybind**:

  ```lua
  Config.SeatbeltKey = 303 -- U key (changeable)
  ```

**Speed Limiter**

Configure global and zone-specific speed limits.

* **Global Speed Limit**:

  ```lua
  Config.GlobalSpeedLimit = 120.0 -- Speed in km/h
  ```
* **Zone-Specific Speed Limits**:

  ```lua
  Config.SpeedZones = {
      { coords = vector3(215.0, -810.0, 30.0), radius = 50.0, speed = 50.0 },
      { coords = vector3(-500.0, -200.0, 35.0), radius = 100.0, speed = 80.0 }
  }
  ```

**Traffic, Pedestrians, and Parked Vehicles**

Adjust the amount of traffic, pedestrians, and parked vehicles.

* **Traffic Amount**:

  ```lua
  Config.TrafficAmount = 100
  ```
* **Pedestrian Amount**:

  ```lua
  Config.PedestrianAmount = 100
  ```
* **Parked Vehicle Amount**:

  ```lua
  Config.ParkedAmount = 100
  ```

**Enable/Disable Services**

Enable or disable dispatch services, boats, trains, and garbage trucks.

* **Dispatch Services**:

  ```lua
  Config.DispatchServices = {
      PoliceAutomobile = true,
      PoliceHelicopter = true,
      FireDepartment = true,
      SwatAutomobile = true,
      AmbulanceDepartment = true,
      PoliceRiders = true,
      PoliceVehicleRequest = true,
      PoliceRoadBlock = true,
      PoliceAutomobileWaitPulledOver = true,
      PoliceAutomobileWaitCruising = true,
      Gangs = true,
      SwatHelicopter = true,
      PoliceBoat = true,
      ArmyVehicle = true,
      BikerBackup = true
  }
  ```
* **Boats**:

  ```lua
  Config.EnableBoats = true
  ```
* **Trains**:

  ```lua
  Config.EnableTrains = true
  ```
* **Garbage Trucks**:

  ```lua
  Config.EnableGarbageTrucks = true
  ```

**Disable Vehicle Weapons**

Prevent vehicles from giving weapons to players.

* **Disable Vehicle Weapons**:

  ```lua
  Config.DisableVehicleWeapons = true
  ```

**NPC Driving Style**

Configure various driving behaviors for NPCs.

* **Driving Style Configuration**:

  ```lua
  Config.MentalState = {
      DrivingStyle = 786603 -- Default style; can be changed
  }
  ```
* **Driving Style Options**:
  * `786603`: Normal driving (default behavior)
  * `1074528293`: Normal driving but avoiding obstacles more aggressively
  * `2883621`: Fast and aggressive driving
  * `6`: Very cautious driving
  * `1076`: Sometimes stop before junctions, drive normally otherwise
  * `7`: Ignore all traffic lights and drive normally
  * `16777216`: Follow traffic laws strictly
  * `536871299`: Very careful, stops a lot
  * `536871044`: Reverse with care
  * `536871045`: Reverse very carefully
  * `536870912`: Very slow driving, usually used for non-road vehicles
  * `536871356`: Use paths only (no roads)
  * `16777215`: A combination of cautious and aggressive

**Realistic Vehicle Damage System**

Configure the realistic vehicle damage system.

* **Damage System Configuration**:

  ```lua
  Config.DamageSystem = {
      enabled = true, -- Toggle entire damage system
      deformationMultiplier = 2.0, -- Further increased deformation damage
      collisionDamageExponent = 1.5, -- Further increased collision damage
      engineDamageExponent = 2.0, -- Further increased engine damage
      cascadingFailureSpeedFactor = 15.0, -- Further increased cascading failure speed
      degradingFailureSpeedFactor = 3.0, -- Further increased degrading failure speed
      degradingFailureThreshold = 500.0, -- Threshold for degrading failure
      cascadingFailureThreshold = 250.0, -- Threshold for cascading failure
      engineSafeGuard = 50.0, -- Safeguard value for engine
      compatibilityMode = false,
      engineExplosion = {
          enabled = true,
          threshold = 100.0 -- Threshold for engine explosion
      },
      wheelFallOff = {
          enabled = true,
          bodyHealthThreshold = 900.0, -- Threshold for body health below which wheels may fall off
          probability = 0.25 -- Probability that a wheel will fall off when the threshold is met
      },
      flatTire = {
          enabled = true,
          probability = 0.0001 -- Probability of random flat tires
      },
      collisionDamage = {
          enabled = true,
          multiplier = 2.0 -- Further increased collision damage multiplier
      },
      deformationDamage = {
          enabled = true,
          multiplier = 2.0 -- Further increased deformation damage multiplier
      },
      engineDamage = {
          enabled = true,
          multiplier = 2.0 -- Further increased engine damage multiplier
      },
      bodyDamage = {
          enabled = true,
          multiplier = 2.0 -- Further increased body damage multiplier
      },
      petrolTankDamage = {
          enabled = true,
          multiplier = 2.0 -- Further increased petrol tank damage multiplier
      },
  }
  ```
