> For the complete documentation index, see [llms.txt](https://hane-mod-studio.gitbook.io/hane-mod-studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hane-mod-studio.gitbook.io/hane-mod-studio/hane-scripts/hane-radio/exports-and-api.md).

# Exports & API

Hane Radio provides client-side exports for integration with other scripts.

***

### Client Exports

#### `IsRadioOn`

Check if the player's radio is currently active.

```lua
local isOn = exports['hane_radio']:IsRadioOn()
```

**Returns:** `boolean`

***

#### `GetCurrentFrequency`

Get the player's primary (main) frequency.

```lua
local freq = exports['hane_radio']:GetCurrentFrequency()
```

**Returns:** `number | nil`

***

#### `GetSecondaryFrequency`

Get the player's secondary frequency (dual listen).

```lua
local freq = exports['hane_radio']:GetSecondaryFrequency()
```

**Returns:** `number | nil`

***

#### `GetActiveChannel`

Get which channel is currently active for transmitting (`'primary'` or `'secondary'`).

```lua
local channel = exports['hane_radio']:GetActiveChannel()
```

**Returns:** `string` — `'primary'` or `'secondary'`

***

#### `GetActiveFrequency`

Get the frequency of the currently active transmitting channel.

```lua
local freq = exports['hane_radio']:GetActiveFrequency()
```

**Returns:** `number | nil`

***

#### `SwitchActiveChannel`

Switch the active transmitting channel between primary and secondary.

```lua
exports['hane_radio']:SwitchActiveChannel()
```

***

#### `ConnectToChannel`

Programmatically connect the player to a specific frequency.

```lua
exports['hane_radio']:ConnectToChannel(frequency)
```

| Parameter   | Type   | Description       |
| ----------- | ------ | ----------------- |
| `frequency` | number | Frequency to join |

***

#### `DisconnectFromChannel`

Programmatically disconnect the player from a specific frequency.

```lua
exports['hane_radio']:DisconnectFromChannel(frequency)
```

| Parameter   | Type   | Description        |
| ----------- | ------ | ------------------ |
| `frequency` | number | Frequency to leave |

***

#### `OpenRadioUI`

Open the radio NUI interface.

```lua
exports['hane_radio']:OpenRadioUI()
```

***

#### `CloseRadioUI`

Close the radio NUI interface.

```lua
exports['hane_radio']:CloseRadioUI()
```

***

#### `useRadio`

Toggle the radio (used by inventory systems as item use export).

```lua
exports['hane_radio']:useRadio()
```

***

#### `GetLocale`

Get a translated string by key.

```lua
local text = exports['hane_radio']:GetLocale('emergency_sent')
```

**Returns:** `string`

***

### Integration Examples

#### Auto-connect officers to department channel

```lua
-- In your duty script
RegisterNetEvent('myduty:onDuty', function(job)
    if job == 'police' then
        exports['hane_radio']:ConnectToChannel(1.00)
    end
end)
```

#### Check if player is on radio before action

```lua
if exports['hane_radio']:IsRadioOn() then
    -- Player has radio active
    local freq = exports['hane_radio']:GetActiveFrequency()
    print('Player is on frequency: ' .. freq)
end
```
