> For the complete documentation index, see [llms.txt](https://acestudios.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://acestudios.gitbook.io/docs/roleplay/live-radio/commands-and-exports.md).

# Commands, Exports & Items

Controls, commands, exports, events and generated inventory items.

## Controls & commands

| Action                                   | How                                                                                                                                                                                |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Open the station list                    | `Q` (`Config.StationListKey`) or `/openliveradio` — while driving or in the front passenger seat, or on foot wearing headphones                                                    |
| Nearby music sources (mute for yourself) | `Q` in range of a boombox or DJ deck when there's no station list to open (on foot without headphones, or a back seat); otherwise the **Music sources** button in the station list |
| Open the host console                    | `F6` (`Config.HostConsoleKey`) or `/openliveradiohost`                                                                                                                             |
| Open the admin panel                     | `/liveradioadmin` (requires `Config.AdminAcePermission`)                                                                                                                           |
| Put on / take off headphones             | `/headphones` (`Config.Headphones.Command`), only when no headphones item is set                                                                                                   |
| Place a boombox                          | `/boombox` (`Config.Boombox.Command`), only when no boombox item is set                                                                                                            |
| Place a DJ deck                          | `/djdeck` (`Config.DJDeck.Command`), only when no DJ deck item is set                                                                                                              |

Players can rebind the station list and host console keys in **Settings → Key Bindings → FiveM**. The GTA radio wheel is disabled in vehicles.

## Exports

Frequencies can be numbers or strings (`93.7` or `"93.7"`). Exports that change something return `true`, or `false` plus a short reason.

### Server

| Export                              | What it does                                                                                                                                                           |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GetStations()`                     | Every station, keyed by frequency                                                                                                                                      |
| `GetStation(frequency)`             | One station, or `nil`                                                                                                                                                  |
| `GetPlayerStation(playerId)`        | The frequency a player is tuned to, or `nil`                                                                                                                           |
| `GetListeners(frequency)`           | Server IDs of everyone tuned in                                                                                                                                        |
| `TunePlayer(playerId, frequency)`   | Tunes a player in (broadcast range still applies)                                                                                                                      |
| `UntunePlayer(playerId)`            | Turns a player's radio off                                                                                                                                             |
| `CreateStation(frequency, options)` | Creates a server station. `options`: `{ Mode = 'Music' or 'Podcast', Playlist = { urls }, Range = 'Global', Name = 'Weazel FM', Genre = 'News', Description = '...' }` |
| `RemoveStation(frequency)`          | Removes any station and disconnects its listeners                                                                                                                      |
| `AddTrack(frequency, url)`          | Queues a track (starts it if nothing is playing)                                                                                                                       |
| `SkipTrack(frequency)`              | Plays the next track                                                                                                                                                   |
| `SetPaused(frequency, paused)`      | Pauses or resumes the music                                                                                                                                            |
| `StopBroadcast(frequency)`          | Ends a player's Live Voice or Podcast broadcast                                                                                                                        |
| `IsHostBanned(playerId)`            | `true` while the player is banned from hosting                                                                                                                         |

{% hint style="warning" %}
Stations made with `CreateStation` **aren't saved**. Create them when your resource starts, and again on the `ace_liveradio:ready` event, in case Live Radio itself restarts:
{% endhint %}

```lua
local function CreateNewsStation()
    exports.ace_liveradio:CreateStation(99.9, { Mode = 'Podcast', Name = 'Weazel News' })
end

AddEventHandler('ace_liveradio:ready', CreateNewsStation)
CreateThread(function()
    if GetResourceState('ace_liveradio') == 'started' then CreateNewsStation() end
end)
```

**Server events:**

| Event                               | Parameters                                                  |
| ----------------------------------- | ----------------------------------------------------------- |
| `ace_liveradio:ready`               | —                                                           |
| `ace_liveradio:stationCreated`      | `frequency, ownerId` (`ownerId` is `0` for script stations) |
| `ace_liveradio:stationRemoved`      | `frequency`                                                 |
| `ace_liveradio:playerJoinedStation` | `playerId, frequency`                                       |
| `ace_liveradio:playerLeftStation`   | `playerId, frequency`                                       |

### Client

| Export                             | What it does                                                                            |
| ---------------------------------- | --------------------------------------------------------------------------------------- |
| `GetCurrentStation()`              | The frequency this player is tuned to, or `nil`                                         |
| `IsListening()`                    | `true` while tuned in                                                                   |
| `GetStations()`                    | Every station, keyed by frequency                                                       |
| `OpenStationList()`                | Opens the station list (driver or front passenger, or on foot with `Config.Headphones`) |
| `OpenHostConsole()`                | Opens the host console (hosting permissions still apply)                                |
| `CloseAll()`                       | Closes the station list, host console and admin panel                                   |
| `Tune(frequency)`                  | Tunes in, or turns the radio off with `nil`                                             |
| `SetVolume(0-100)` / `GetVolume()` | The player's radio volume                                                               |

## Items

On start, the resource detects your inventory and writes ready-to-paste item definitions for the microphone (`Config.HostItem`), headphones, boombox and DJ deck to the `items/` folder. It only lists the ones your config actually uses.

| Generated file           | Inventory                 | Where it goes                   |
| ------------------------ | ------------------------- | ------------------------------- |
| `items/ox_inventory.lua` | ox\_inventory (also Qbox) | `ox_inventory/data/items.lua`   |
| `items/qb-core.lua`      | QBCore / qb-inventory     | `qb-core/shared/items.lua`      |
| `items/qs-inventory.lua` | qs-inventory              | `qs-inventory/shared/items.lua` |
| `items/esx.sql`          | ESX                       | Run it against your database    |

Copy the entries you need into your inventory, add an image for each, and restart the inventory. Turn this off with `Config.GenerateItemFiles = false` in `config_advanced.lua`.

{% hint style="info" %}
With ox\_inventory or QBCore, the **startup summary** also warns about items your config uses that the inventory doesn't have yet.
{% endhint %}

### ox\_inventory item format

{% tabs %}
{% tab title="Headphones" %}

```lua
['headphones'] = {
    label = 'Headphones',
    weight = 300,
    stack = false,
    close = true,
    description = 'Listen to the radio on foot.',
    consume = 0, -- not used up
    server = { export = 'ace_liveradio.useHeadphones' },
},
```

{% endtab %}

{% tab title="Boombox" %}

```lua
['boombox'] = {
    label = 'Boombox',
    weight = 3000,
    stack = false,
    close = true,
    description = 'Place it and play a radio station for everyone nearby.',
    consume = 0, -- not used up
    server = { export = 'ace_liveradio.useBoombox' },
},
```

{% endtab %}

{% tab title="DJ Deck" %}

```lua
['djdeck'] = {
    label = 'DJ Deck',
    weight = 8000,
    stack = false,
    close = true,
    description = 'Set it up and play a station for the whole party.',
    consume = 0, -- not used up
    server = { export = 'ace_liveradio.useDJDeck' },
},
```

{% endtab %}

{% tab title="Microphone" %}

```lua
['microphone'] = {
    label = 'Microphone',
    weight = 500,
    stack = false,
    close = true,
    description = 'Needed to host a radio station.',
},
```

Used only when `Config.HostItem` is set to an item name (default `false`).
{% endtab %}
{% endtabs %}

None of the items are used up (`consume = 0`, or no `consume` for the microphone, which is only checked for carrying).
