> For the complete documentation index, see [llms.txt](https://docs.bhdscripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bhdscripts.com/scripts/bhd-garage/developer-options/exports/server-exports/vehicle-object.md).

# Vehicle Object

Vehicles are represented as objects when they are created. You can retrieve a vehicle object using:

```lua
local vehicle = exports.bhd_garage:GetVehicle(plate)
```

This object contains various properties and functions that allow for full control over the vehicle in the system.

### 🔧 Available Functions & Properties

#### **Vehicle Properties** (Stored in `vehicle`)

These variables contain essential data about the vehicle:

* **`vehicle.owner`** *(string)* – The identifier of the vehicle's owner.
* **`vehicle.plate`** *(string)* – The license plate of the vehicle.
* **`vehicle.props`** *(json string)* – The vehicle’s properties.
* **`vehicle.type`** *(string)* – The type of vehicle (e.g., car, boat, helicopter).
* **`vehicle.garage_id`** *(string)* – The ID of the garage where the vehicle is currently stored.
* **`vehicle.last_garage_id`** *(string)* – The ID of the last garage the vehicle was in.
* **`vehicle.impound_data`** *(json string or nil)* – Data related to vehicle impounding.
* **`vehicle.friends`** *(json string)* – List of friends who have access to the vehicle.
* **`vehicle.mileage`** *(number)* – The vehicle’s mileage in kilometers.
* **`vehicle.vinnumber`** *(string)* – The unique Vehicle Identification Number (VIN).
* **`vehicle.name`** *(string)* – The custom name given to the vehicle.
* **`vehicle.favourite`** *(table or nil)* – Stores whether the vehicle is marked as a favorite by players.
* **`vehicle.oldOwner`** *(string or nil)* – The previous owner of the vehicle before a transfer.
* **`vehicle.min_grade`** *(number or nil)* – The minimum job grade required to use the vehicle.
* **`vehicle.status`** *(string)* – The current status of the vehicle (`"onstreet"`, `"garage"`, `"impounded"`).
* **`vehicle.fakePlate`** *(string or nil)* – A fake plate assigned to the vehicle.
* **`vehicle.title`** *(string)* – The formatted display title of the vehicle.
* **`vehicle.jobVehicle`** *(boolean)* – Whether the vehicle belongs to a job rather than a player.
* **`vehicle.img`** *(string or nil)* – The URL of the vehicle's image (if available).

#### **Vehicle Functions**

## Set Favourite

```lua
vehicle.SetFavourite(favourite, identifier)
```

* **Description:** Marks or unmarks the vehicle as a favorite for a given player.
* **Arguments:**
  * `favourite` *(boolean)* – Whether the vehicle should be marked as favorite.
  * `identifier` *(string)* – The player identifier.
* **Returns:** None.

## Set Name

```lua
vehicle.SetName(name)
```

* **Description:** Assigns a custom name to the vehicle.
* **Arguments:**
  * `name` *(string)* – The new vehicle name.
* **Returns:** None.

## Take Out

```lua
vehicle.TakeOut(lastGarage)
```

* **Description:** Marks the vehicle as taken out from the garage.
* **Arguments:**
  * `lastGarage` *(string)* – The ID of the last garage the vehicle was stored in.
* **Returns:** None.

## Park

```lua
vehicle.Park(garage, props, mileage)
```

* **Description:** Stores the vehicle in a garage.
* **Arguments:**
  * `garage` *(string)* – The garage where the vehicle is stored.
  * `props` *(table)* – The updated vehicle properties.
  * `mileage` *(number)* – The current mileage of the vehicle.
* **Returns:** None.

## Transfer

```lua
vehicle.Transfer(newOwner, changeDatabase)
```

* **Description:** Transfers ownership of the vehicle to another player.
* **Arguments:**
  * `newOwner` *(string)* – The identifier of the new owner.
  * `changeDatabase` *(boolean)* – Whether to update the database.
* **Returns:** None.

## Is Owner

```lua
vehicle.IsOwner(source)
```

* **Description:** Checks if the given player is the owner of the vehicle.
* **Arguments:**
  * `source` *(number)* – The player's source ID.
* **Returns:** Boolean (`true` if the player is the owner, otherwise `false`).

## Get Sorted Data

```lua
vehicle.getSortedData(source)
```

* **Description:** Retrieves organized vehicle data for UI purposes.
* **Arguments:**
  * `source` *(number or nil)* – The player's source ID.
* **Returns:** A table containing relevant vehicle information.

## Get Scraped Data

```lua
vehicle.getScrapedData()
```

* **Description:** Retrieves all vehicle-related data.
* **Arguments:** None.
* **Returns:** Table with detailed vehicle information.

## Impound

{% code overflow="wrap" %}

```lua
vehicle.Impound(date, price, impoundLot, reason, confiscated, playerName, officerName, props)
```

{% endcode %}

* **Description:** Marks the vehicle as impounded.
* **Note:** Date is `os.time()` if you want to be able to take out the vehicle immediately. If you want to confiscate it for some time, set it to `os.time() + time_in_seconds`.
* **Arguments:**
  * `date` *(number)* – The timestamp of impoundment.
  * `price` *(number)* – The fee for retrieving the vehicle.
  * `impoundLot` *(string)* – The location where the vehicle is stored.
  * `reason?` *(string)* – The reason for impounding.
  * `confiscated?` *(boolean)* – Whether the vehicle is permanently confiscated.
  * `playerName?` *(string)* – The owner's name.
  * `officerName?` *(string or nil)* – The officer responsible for impounding.
  * `props?` *(table or nil)* – The updated vehicle properties.
* **Returns:** None.

## UnImpound

```lua
vehicle.UnImpound(intoGarage, newGarage)
```

* **Description:** Removes the vehicle from impound.
* **Arguments:**
  * `intoGarage` *(boolean)* – Whether to send the vehicle to a garage.
  * `newGarage?` *(string or nil)* – The garage where the vehicle should be sent.
* **Returns:** None.

## Change Plate

```lua
vehicle.ChangePlate(newPlate, entity)
```

* **Description:** Updates the vehicle's plate number.
* **Arguments:**
  * `newPlate` *(string)* – The new plate number.
  * `entity` *(entity ID or nil)* – The vehicle entity (if applicable).
* **Returns:** None.

## Delete Vehicle

```lua
vehicle.DeleteVehicle(dontDeleteSQL)
```

* **Description:** Removes the vehicle from the system.
* **Arguments:**
  * `dontDeleteSQL?` *(boolean or nil)* – Whether to keep the database entry.
* **Returns:** None.

***

📌 **Note:** The **Vehicle Object** is dynamically created when a vehicle is spawned or registered in the system. Ensure all functions are called on a valid vehicle instance.
