> For the complete documentation index, see [llms.txt](https://secret-code.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://secret-code.gitbook.io/docs/creators/secret-garage/exports.md).

# Exports

## Client-Side Exports

Client exports are intended for operations involving vehicles that currently exist on the player's client.

### GetFuel

Returns the current fuel level of a vehicle.

```lua
local fuel = exports['Secret-Garage']:GetFuel(vehicle)
```

#### Parameters

| Parameter | Type   | Description    |
| --------- | ------ | -------------- |
| `vehicle` | entity | Vehicle entity |

#### Returns

```lua
number
```

Returns `0.0` if the vehicle is invalid.

***

### SetFuel

Sets the fuel level of a vehicle using the configured Secret Garage fuel integration.

```lua
local success = exports['Secret-Garage']:SetFuel(vehicle, 75.0)
```

#### Parameters

| Parameter | Type   | Description    |
| --------- | ------ | -------------- |
| `vehicle` | entity | Vehicle entity |
| `fuel`    | number | Fuel level     |

#### Returns

```lua
boolean
```

***

### GiveVehicleKey

Gives the local player access to the specified vehicle through the configured vehicle keys integration.

```lua
local success = exports['Secret-Garage']:GiveVehicleKey(vehicle, plate)
```

You can optionally request the vehicle engine to start after granting access:

```lua
local success = exports['Secret-Garage']:GiveVehicleKey(vehicle, plate, true)
```

#### Parameters

| Parameter     | Type    | Description                                      |
| ------------- | ------- | ------------------------------------------------ |
| `vehicle`     | entity  | Vehicle entity                                   |
| `plate`       | string  | Vehicle plate                                    |
| `startEngine` | boolean | Optional. Start the engine after granting access |

If the plate is omitted or empty, Secret Garage will attempt to obtain it from the vehicle entity.

#### Aliases

The following exports perform the same action:

```lua
exports['Secret-Garage']:GiveKey(...)
exports['Secret-Garage']:GiveVehicleKey(...)
exports['Secret-Garage']:GiveVehicleKeys(...)
```

> This is a **client-side/local key operation**. For persistent shared vehicle access, use the server-side key exports.

***

### RemoveVehicleKey

Removes local vehicle access using the configured keys integration.

```lua
local success = exports['Secret-Garage']:RemoveVehicleKey(vehicle, plate)
```

#### Aliases

```lua
exports['Secret-Garage']:RemoveKey(...)
exports['Secret-Garage']:RemoveVehicleKey(...)
exports['Secret-Garage']:RemoveVehicleKeys(...)
```

***

### HasVehicleKey

Checks whether the local player has access to a vehicle.

```lua
local hasKey = exports['Secret-Garage']:HasVehicleKey(vehicle, plate)
```

An optional third parameter can force a fresh key check instead of relying only on cached information.

```lua
local hasKey = exports['Secret-Garage']:HasVehicleKey(vehicle, plate, true)
```

#### Returns

```lua
boolean
```

#### Aliases

```lua
exports['Secret-Garage']:HasKey(...)
exports['Secret-Garage']:HasVehicleKey(...)
exports['Secret-Garage']:HasVehicleKeys(...)
```

***

### GetVehicleProperties

Returns the vehicle properties using `ox_lib`, including the current fuel level and normalized plate.

```lua
local properties = exports['Secret-Garage']:GetVehicleProperties(vehicle)

if properties then
    print(properties.plate)
    print(properties.fuelLevel)
end
```

#### Returns

```lua
table | nil
```

***

### SetVehicleProperties

Applies vehicle properties using `ox_lib`.

```lua
local success = exports['Secret-Garage']:SetVehicleProperties(vehicle, properties)
```

Fuel values contained in:

```lua
properties.fuelLevel
```

or:

```lua
properties.fuel
```

will also be applied through the configured fuel integration.

#### Returns

```lua
boolean
```

***

### NormalizePlate

Normalizes a vehicle plate using the same format Secret Garage uses internally.

```lua
local plate = exports['Secret-Garage']:NormalizePlate(GetVehicleNumberPlateText(vehicle))
```

This is recommended when comparing plates between Secret Garage and another resource.

***

### GetGarage

Returns the client-side information of a loaded garage.

```lua
local garage = exports['Secret-Garage']:GetGarage(garageId)
```

#### Parameters

| Parameter  | Type   | Description               |
| ---------- | ------ | ------------------------- |
| `garageId` | number | Secret Garage database ID |

#### Returns

```lua
table | nil
```

A copied garage table is returned so external resources do not directly modify Secret Garage's internal state.

***

### OpenGarage

Requests Secret Garage to open a specific garage.

```lua
local success = exports['Secret-Garage']:OpenGarage(garageId)
```

#### Example

```lua
RegisterCommand('mygarage', function()
    exports['Secret-Garage']:OpenGarage(1)
end)
```

#### Returns

```lua
boolean
```

> Returning `true` means the garage open request was successfully passed to Secret Garage. Normal garage access rules still apply.

***

## UI Integration Exports

Secret Garage also provides client exports that allow other resources to coordinate their UI with Secret Garage.

These are particularly useful for HUDs, menus, inventories, phones, or other interfaces that do not necessarily use NUI focus.

### OnUiOpen

Tells Secret Garage that an external UI has been opened.

```lua
exports['Secret-Garage']:OnUiOpen('my-resource-menu')
```

Secret Garage can use this state to hide floating world UI and prevent visual overlap.

***

### OnUiClose

Notifies Secret Garage that the external UI has been closed.

```lua
exports['Secret-Garage']:OnUiClose('my-resource-menu')
```

***

### SetExternalUiOpen

Manually controls the state of an external UI.

```lua
exports['Secret-Garage']:SetExternalUiOpen('my-resource-menu', true)
```

Close it with:

```lua
exports['Secret-Garage']:SetExternalUiOpen('my-resource-menu', false)
```

***

### IsUiOpen

Checks whether a Secret Garage internal UI context is currently open.

```lua
local isOpen = exports['Secret-Garage']:IsUiOpen()
```

You can also check a specific context:

```lua
local isOpen = exports['Secret-Garage']:IsUiOpen('garage')
```

***

### CanOpenUi

Checks whether a Secret Garage UI can be opened without conflicting with another Secret Garage internal interface.

```lua
local canOpen, blockingUi = exports['Secret-Garage']:CanOpenUi('garage')

if not canOpen then
    print(('Blocked by: %s'):format(blockingUi))
end
```

#### Returns

```lua
boolean, string | nil
```

***

### IsWorldUiSuppressed

Returns whether Secret Garage's world UI should currently be hidden.

```lua
local suppressed = exports['Secret-Garage']:IsWorldUiSuppressed()
```

This can return `true` when:

* A Secret Garage UI is open
* A registered external UI is open
* The pause menu is active
* Another focused NUI is active

***

### GetUiState

Returns the complete Secret Garage UI coordinator state.

```lua
local state = exports['Secret-Garage']:GetUiState()
```

Example result:

```lua
{
    internal = {},
    external = {
        'my-resource-menu'
    },
    pause = false,
    nuiFocused = false,
    worldUiSuppressed = true
}
```

***

## Server-Side Exports

Server exports should be used for persistent vehicle ownership, shared keys, garage information, and database-backed vehicle operations.

***

### GiveVehicleKey

Grants persistent shared access to an owned vehicle.

```lua
local success, result = exports['Secret-Garage']:GiveVehicleKey(
    plate,
    target,
    options
)
```

#### Basic Example

```lua
local success, result = exports['Secret-Garage']:GiveVehicleKey(
    'ABC123',
    playerId
)
```

#### With Options

```lua
local success, result = exports['Secret-Garage']:GiveVehicleKey(
    'ABC123',
    playerId,
    {
        canDrive = true,
        canStore = true,
        notify = true
    }
)
```

#### Options

| Option     | Type    | Description                                     |
| ---------- | ------- | ----------------------------------------------- |
| `canDrive` | boolean | Allows the player to drive the vehicle          |
| `canStore` | boolean | Allows the player to store the vehicle          |
| `notify`   | boolean | Sends the Secret Garage notification            |
| `name`     | string  | Optional fallback name when using an identifier |

#### Target Formats

The target can be a server ID:

```lua
exports['Secret-Garage']:GiveVehicleKey('ABC123', source)
```

An identifier:

```lua
exports['Secret-Garage']:GiveVehicleKey('ABC123', 'license:xxxxxxxx')
```

Or a table:

```lua
exports['Secret-Garage']:GiveVehicleKey('ABC123', {
    source = source,
    identifier = 'license:xxxxxxxx',
    name = 'Player Name'
})
```

Secret Garage also supports this convenience signature:

```lua
exports['Secret-Garage']:GiveVehicleKey(source, 'ABC123')
```

#### Returns

On success:

```lua
true, keyData
```

On failure:

```lua
false, errorCode
```

Possible error codes include:

```
invalid_plate
vehicle_not_found
invalid_target
database_error
```

#### Aliases

```lua
exports['Secret-Garage']:GiveKey(...)
exports['Secret-Garage']:GiveVehicleKey(...)
exports['Secret-Garage']:GiveVehicleKeys(...)
exports['Secret-Garage']:GrantSharedKey(...)
```

***

### RemoveVehicleKey

Revokes persistent shared access to an owned vehicle.

```lua
local success, result = exports['Secret-Garage']:RemoveVehicleKey(
    'ABC123',
    playerId
)
```

With options:

```lua
local success = exports['Secret-Garage']:RemoveVehicleKey(
    'ABC123',
    playerId,
    {
        notify = true
    }
)
```

#### Aliases

```lua
exports['Secret-Garage']:RemoveKey(...)
exports['Secret-Garage']:RemoveVehicleKey(...)
exports['Secret-Garage']:RemoveVehicleKeys(...)
exports['Secret-Garage']:RevokeSharedKey(...)
```

***

### HasVehicleKey

Checks whether a player currently has Secret Garage access to a vehicle.

```lua
local hasKey = exports['Secret-Garage']:HasVehicleKey(source, plate)
```

#### Example

```lua
local hasKey = exports['Secret-Garage']:HasVehicleKey(source, 'ABC123')

if hasKey then
    print('Player has vehicle access')
end
```

#### Aliases

```lua
exports['Secret-Garage']:HasKey(...)
exports['Secret-Garage']:HasVehicleKey(...)
exports['Secret-Garage']:HasVehicleKeys(...)
```

***

### GetVehicle

Returns an owned vehicle directly by its plate.

```lua
local vehicle = exports['Secret-Garage']:GetVehicle('ABC123')
```

#### Example Return

```lua
{
    owner = 'license:xxxxxxxx',
    plate = 'ABC123',
    properties = {},
    stored = true,
    garage = 'mission-row-lspd',
    vehicleType = 'land',
    secretData = {}
}
```

#### Returns

```lua
table | nil
```

#### Alias

```lua
exports['Secret-Garage']:GetVehicleByPlate(plate)
```

***

### IsVehicleOwned

Checks whether a plate exists in the configured owned-vehicle database.

```lua
local owned = exports['Secret-Garage']:IsVehicleOwned('ABC123')
```

#### Returns

```lua
boolean
```

Example:

```lua
if exports['Secret-Garage']:IsVehicleOwned(plate) then
    print('This vehicle is registered')
end
```

***

### GetGarage

Returns a garage directly from Secret Garage's server-side registry.

```lua
local garage = exports['Secret-Garage']:GetGarage(garageId)
```

#### Returns

```lua
table | nil
```

The returned object is a copy of the internal garage data.

***

### NormalizePlate

Server-side version of the plate normalization utility.

```lua
local plate = exports['Secret-Garage']:NormalizePlate(' ABC123 ')
```

This is recommended before performing plate comparisons with external scripts.

***

## Creator Integration Exports

Secret Garage also exposes two optional server exports for integrations that need to control the status message displayed in the Garage Creator footer.

### SetCreatorFooterMessage

Changes the Creator footer message for all connected players.

```lua
exports['Secret-Garage']:SetCreatorFooterMessage(
    'All systems operational',
    'success'
)
```

#### Supported tones

```
info
success
warning
error
```

The message is server-owned and automatically synchronized with connected clients.

This can be useful for:

* Update services
* License systems
* Server status information
* Integration notices

***

### GetCreatorFooterMessage

Returns the current Creator footer message.

```lua
local footer = exports['Secret-Garage']:GetCreatorFooterMessage()

print(footer.text)
print(footer.tone)
```

#### Example Return

```lua
{
    text = 'All systems operational',
    tone = 'success'
}
```

***

## Recommended Integration Practice

Whenever possible, use the public exports provided by Secret Garage instead of directly triggering internal events or accessing internal tables.

For example, prefer:

```lua
exports['Secret-Garage']:GiveVehicleKey(plate, source)
```

instead of calling internal Secret Garage events.

The public exports are designed to provide a **stable integration layer** between Secret Garage and external FiveM resources.
