> For the complete documentation index, see [llms.txt](https://crystal-studios.gitbook.io/crystal-studios-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crystal-studios.gitbook.io/crystal-studios-docs/vehicle-keys/exports.md).

# Exports

You can use these exports to integrate the key system with your custom garages, car dealers, robberies, or job scripts.

***

### 📱 Client-Side Exports

These exports can be called from any client-side script.

#### ➕ Add Keys

Gives vehicle keys to the local player.

```lua
-- Syntax: exports['cr-carkeys']:AddKeys(plate, isTemp)
-- Example: 
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local plate = GetVehicleNumberPlateText(vehicle)

exports['cr-carkeys']:AddKeys(plate, false)
```

* `plate` *(string)*: The license plate of the vehicle.
* `isTemp` *(boolean)*: Set to `true` if the keys are temporary (e.g., rental), otherwise `false`.

#### ➖ Remove Keys

Removes vehicle keys from the local player.

```lua
-- Syntax: exports['cr-carkeys']:RemoveKeys(plate)
-- Example:
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local plate = GetVehicleNumberPlateText(vehicle)

exports['cr-carkeys']:RemoveKeys(plate)
```

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

#### 🚫 Is Vehicle Blacklisted

Checks if a specific vehicle entity is blacklisted (e.g., local emergency vehicles or trains).

```lua
-- Syntax: exports['cr-carkeys']:IsVehicleBlacklisted(vehicle)
-- Example:
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local isBlacklisted = exports['cr-carkeys']:IsVehicleBlacklisted(vehicle)

if isBlacklisted then
    print("This vehicle cannot be locked/unlocked or hotwired!")
end
```

* `vehicle` *(entity)*: The vehicle entity handle.
* Returns: `boolean` (`true` or `false`).

***

### 🖥️ Server-Side Exports

These exports can be called from any server-side script.

#### ➕ Add Keys (Server)

Gives vehicle keys to a specific player via their server ID.

```lua
-- Syntax: exports['cr-carkeys']:AddKeys(src, plate, isTemp)
-- Example (e.g., after buying a car from a dealer):
local plate = "ABC 123" -- Vehicle Plate String

exports['cr-carkeys']:AddKeys(source, plate, false)
```

* `source` *(integer)*: The Server ID (source) of the player.
* `plate` *(string)*: The license plate of the vehicle.
* `isTemp` *(boolean)*: Set to `true` if keys are temporary.

#### ➖ Remove Keys (Server)

Removes vehicle keys from a specific player via their server ID.

```lua
-- Syntax: exports['cr-carkeys']:RemoveKeys(src, plate)
-- Example (e.g., when a vehicle gets impounded):
local plate = "ABC 123" -- Vehicle Plate String

exports['cr-carkeys']:RemoveKeys(source, plate)
```

* `source` *(integer)*: The Server ID (source) of the player.
* `plate` *(string)*: The license plate of the vehicle.

#### 🔑 Has Key

Checks if a specific player has keys to a specific license plate.

```lua
-- Syntax: exports['cr-carkeys']:HasKey(src, plate)
-- Example:
local plate = "ABC 123" -- Vehicle Plate String
local hasKey = exports['cr-carkeys']:HasKey(source, plate)

if hasKey then
    print("Do something if player has the key")
end
```

* `source` *(integer)*: The Server ID (source) of the player.
* `plate` *(string)*: The license plate of the vehicle.
* Returns: `boolean` (`true` or `false`).

#### 🗂️ Get All Keys

Retrieves an array of all vehicle plates that the player currently holds keys for in their inventory.

```lua
-- Syntax: exports['cr-carkeys']:GetAllKeys(src)
-- Example:
local playerKeys = exports['cr-carkeys']:GetAllKeys(source)

-- playerKeys will return a table: {"ABC 123", "XYZ 789"}
for _, plate in pairs(playerKeys) do
    print("Player owns key for plate: " .. plate)
end
```

* `source` *(integer)*: The Server ID (source) of the player.
* Returns: `table` (array of plate strings).

#### 🚫 Is Vehicle Blacklisted (Server)

Server-side check to see if a vehicle entity is blacklisted.

```lua
-- Syntax: exports['cr-carkeys']:IsVehicleBlacklisted(vehicle)
-- Returns: boolean
```


---

# 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://crystal-studios.gitbook.io/crystal-studios-docs/vehicle-keys/exports.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.
