> For the complete documentation index, see [llms.txt](https://docs.menanak47.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.menanak47.com/multi-framework/ak47_vehiclekeys/exports/client.md).

# Client

This page documents all client-side exports available in AK47 Vehicle Keys.

### `GiveKey`

Gives a physical vehicle key to the local player for a specified license plate.

```lua
exports['ak47_vehiclekeys']:GiveKey(plate, temp)
```

#### Parameters

* **`plate`** (`string`): The vehicle license plate.
* **`temp`** (`boolean` | optional): Whether this key is temporary.

#### Example

```lua
local plate = 'ABC 123'
exports['ak47_vehiclekeys']:GiveKey(plate)
```

***

### `RemoveKey`

Removes the physical vehicle key from the local player for a specified license plate.

```lua
exports['ak47_vehiclekeys']:RemoveKey(plate, temp)
```

#### Parameters

* **`plate`** (`string`): The vehicle license plate.
* **`temp`** (`boolean` | optional): Whether the key being removed is temporary.

#### Example

```lua
local plate = 'ABC 123'
exports['ak47_vehiclekeys']:RemoveKey(plate)
```

***

### `HasKey`

Checks if the local player has a key (physical or virtual) for a specific vehicle plate.

```lua
local hasKey = exports['ak47_vehiclekeys']:HasKey(plate)
```

#### Parameters

* **`plate`** (`string`): The vehicle license plate to check.

#### Returns

* **`boolean`**: Returns `true` if the local player has access/keys to the vehicle, `false` otherwise.

#### Example

```lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
    local plate = GetVehicleNumberPlateText(vehicle)
    if exports['ak47_vehiclekeys']:HasKey(plate) then
        print('Player has access to this vehicle!')
    else
        print('Player does not have keys.')
    end
end
```

***

### `GiveVirtualKey`

Grants a virtual (keyless) key for the given plate to the local player.

```lua
exports['ak47_vehiclekeys']:GiveVirtualKey(plate)
```

#### Parameters

* **`plate`** (`string`): The vehicle license plate.

#### Example

```lua
local plate = 'RENTAL01'
exports['ak47_vehiclekeys']:GiveVirtualKey(plate)
```

***

### `RemoveVirtualKey`

Removes a virtual key from the local player for the given plate.

```lua
exports['ak47_vehiclekeys']:RemoveVirtualKey(plate)
```

#### Parameters

* **`plate`** (`string`): The vehicle license plate.

#### Example

```lua
local plate = 'RENTAL01'
exports['ak47_vehiclekeys']:RemoveVirtualKey(plate)
```

***

### `ToggleLock`

Toggles the lock state of a specific vehicle entity (or the closest vehicle if no entity is passed).

```lua
local success = exports['ak47_vehiclekeys']:ToggleLock(vehicle)
```

#### Parameters

* **`vehicle`** (`number` | optional): Vehicle entity handle. If `nil` or omitted, checks the closest vehicle in range.

#### Returns

* **`boolean`**: Returns `true` if the action was processed, `false` otherwise.

#### Example

```lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
    exports['ak47_vehiclekeys']:ToggleLock(vehicle)
end
```

***

### `LockVehicle`

Locks a specified vehicle entity. Closes doors, plays light flash & sound, sets network sync state, and turns off engine if `Config.EngineOffWithLockVehicle` is enabled.

```lua
local success = exports['ak47_vehiclekeys']:LockVehicle(vehicle)
```

#### Parameters

* **`vehicle`** (`number`): Vehicle entity handle.

#### Returns

* **`boolean`**: Returns `true` if vehicle was locked successfully, `false` if already locked or invalid.

#### Example

```lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
    exports['ak47_vehiclekeys']:LockVehicle(vehicle)
end
```

***

### `UnlockVehicle`

Unlocks a specified vehicle entity. Plays light flash and sound, sets network sync state, and displays notification.

```lua
local success = exports['ak47_vehiclekeys']:UnlockVehicle(vehicle)
```

#### Parameters

* **`vehicle`** (`number`): Vehicle entity handle.

#### Returns

* **`boolean`**: Returns `true` if vehicle was unlocked successfully, `false` if already unlocked or invalid.

#### Example

```lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
    exports['ak47_vehiclekeys']:UnlockVehicle(vehicle)
end
```
