# Exports

## Developer Exports

Imperium Smart Keys provides a robust set of exports to allow other scripts to interact with the key system. Use these to integrate with your garage, dealership, or job systems.

***

### 🛠️ Server-side Exports

#### `AddKey`

Gives a key for a specific vehicle to a player.

```lua
exports['is-smartkeys']:AddKey(targetSource, plate)
```

* **targetSource**: (number) Player server ID.
* **plate**: (string) Vehicle plate.
* **Returns**: (boolean) Success status.

#### `RemoveKey`

Removes a specific vehicle key from a player.

```lua
exports['is-smartkeys']:RemoveKey(targetSource, plate)
```

* **targetSource**: (number) Player server ID.
* **plate**: (string) Vehicle plate.
* **Returns**: (boolean) Success status.

#### `HasVehicleKey`

Checks if a player possesses a key for the given plate.

```lua
local hasKey, isOwner = exports['is-smartkeys']:HasVehicleKey(source, plate)
```

* **source**: (number) Player server ID.
* **plate**: (string) Vehicle plate.
* **Returns**: (boolean) `hasKey`, (boolean) `isOwner`.

#### `SetVehicleLockState`

Manually sets the lock status of a vehicle globally.

```lua
exports['is-smartkeys']:SetVehicleLockState(plate, locked)
```

* **plate**: (string) Vehicle plate.
* **locked**: (boolean) `true` for locked, `false` for unlocked.

#### `IsVehicleLocked`

Checks the current lock status of a vehicle.

```lua
local isLocked = exports['is-smartkeys']:IsVehicleLocked(plate)
```

* **plate**: (string) Vehicle plate.
* **Returns**: (boolean) Current lock state.

***

### 🖥️ Client-side Exports

#### `ToggleVehicleLock`

Triggers the lock/unlock sequence for the nearest or current vehicle.

```lua
exports['is-smartkeys']:ToggleVehicleLock()
```

#### `LockVehicle` / `UnlockVehicle`

Directly locks or unlocks the nearest or current vehicle.

```lua
exports['is-smartkeys']:LockVehicle()
exports['is-smartkeys']:UnlockVehicle()
```

#### `ToggleEngine`

Toggles the engine of the current vehicle.

```lua
exports['is-smartkeys']:ToggleEngine()
```

#### `HasKeyForVehicle`

Checks if the local player has a key for a specific plate (Async).

```lua
exports['is-smartkeys']:HasKeyForVehicle(plate, function(hasKey, isOwner)
    if hasKey then
        -- Do something
    end
end)
```

#### `StartHotwire`

Manually triggers the hotwire minigame for the current vehicle.

```lua
exports['is-smartkeys']:StartHotwire()
```

#### `IsVehicleHotwired`

Checks if a specific vehicle is currently hotwired (Async).

```lua
exports['is-smartkeys']:IsVehicleHotwired(plate, function(isHotwired)
    -- returns true/false
end)
```

***

> For plate arguments, the script automatically normalizes strings (removes spaces), so you don't need to worry about formatting inconsistencies.


---

# Agent Instructions: 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:

```
GET https://imperiumscripts.gitbook.io/imperium-scripts/scripts/imperium-smart-keys/exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
