# Exports

### Client-side Exports

**Export to check if player has a vehicle key**

```lua
exports.ic3d_vehiclekeys:hasKey(identifier)
```

Examples:

* `exports.ic3d_vehiclekeys:hasKey('ABC123')` - Check by plate string
* `exports.ic3d_vehiclekeys:hasKey(vehicle)` - Check by vehicle entity
* `exports.ic3d_vehiclekeys:hasKey()` - Check for closest vehicle

***

**Export to get player key information**

```lua
exports.ic3d_vehiclekeys:GetPlayerKey(vehicle)
```

Returns: `hasKey, vehicleEntity, inCar, playerPed` Examples:

* `local hasKey, entity, inCar, ped = exports.ic3d_vehiclekeys:GetPlayerKey()` - Get info for closest vehicle
* `local hasKey, entity, inCar, ped = exports.ic3d_vehiclekeys:GetPlayerKey(vehicleEntity)` - Get info for specific vehicle

***

**Export to add a key (Useful for Dealerships, Garages and Jobs)**

```lua
exports.ic3d_vehiclekeys:ClientInventoryKeys('add', plate)
```

**Export to remove a key (Useful for Garages and Jobs)**

```lua
exports.ic3d_vehiclekeys:ClientInventoryKeys('remove', plate)
```

***

### Server-side Exports

**Export to manage inventory keys server-side**

```lua
exports.ic3d_vehiclekeys:InventoryKeys(action, data)
```

Examples:

* `exports.ic3d_vehiclekeys:InventoryKeys('add', {player = playerId, plate = 'ABC123'})` - Add key to player
* `exports.ic3d_vehiclekeys:InventoryKeys('remove', {player = playerId, plate = 'ABC123'})` - Remove key from player

Returns `true` on success, `false` on failure.

***

### Usage Notes

* All plate parameters should be strings (e.g., 'ABC123')
* The `hasKey` export accepts either a plate string, vehicle entity number, or no parameter for closest vehicle
* The `GetPlayerKey` export is useful for getting detailed information about the player's relationship to a vehicle
* Server-side `InventoryKeys` requires a data table with `player` (source ID) and `plate` fields
* Client-side `ClientInventoryKeys` automatically uses the current player and triggers the server-side function

***

If your script doesn't have the plate defined, fetch it like this example bellow

```lua
function giveKeys(vehicle)
    local plate = GetVehicleNumberPlateText(vehicle)
    exports.ic3d_vehiclekeys:ClientInventoryKeys('add', plate)
end

```
