> For the complete documentation index, see [llms.txt](https://jixelpatterns.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jixelpatterns.gitbook.io/docs/dependency/jim_bridge/vehicles.md).

# Vehicles

## vehicles.lua

This module provides utilities for reading, modifying, and interacting with vehicle properties and positioning.

###

### **searchCar(vehicle)**

Searches the 'Vehicles' table for a specific vehicle's details.

If the vehicle differs from the last searched, it retrieves its model and updates the carInfo table.

The table includes the vehicle's name, price, and class information.

**Example:**

```lua
local info = searchCar(vehicleEntity)
print(info.name, info.price, info.class.name, info.class.index)
```

***

### **getVehicleProperties(vehicle)**

Retrieves the properties of a given vehicle using the active framework.

**Example:**

```lua
local props = getVehicleProperties(vehicle)
if props then
    print(json.encode(props))
end
```

***

### **setVehicleProperties(vehicle, props)**

Sets the properties of a given vehicle if changes are detected.

It compares the current properties with the new ones and applies the update using the active framework.

**Example:**

```lua
setVehicleProperties(vehicle, props)
```

***

### **checkDifferences(vehicle, newProps)**

Checks for differences between the current and new vehicle properties.

Compares properties using JSON encoding for deep comparison and logs differences.

**Example:**

```lua
if checkDifferences(vehicleEntity, newProperties) then
    setVehicleProperties(vehicleEntity, newProperties)
end
```

***

### **pushVehicle(entity)**

This function ensures that the vehicle is controlled by the current player and is set as a mission entity.

It requests network control and sets the vehicle accordingly to synchronize changes across clients.

**Example:**

```lua
pushVehicle(vehicle)
```

***

### **getClosestVehicle(coords, src)**

Finds the closest vehicle to the specified coordinates.

The function uses different APIs based on whether a source is provided.

**Example:**

```lua
local closestVeh, distance = getClosestVehicle({ x = 100, y = 200, z = 30 }, source)
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jixelpatterns.gitbook.io/docs/dependency/jim_bridge/vehicles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
