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

# SBS-RADIO

### Overview

`sbs-radio` is a FiveM script designed to work with the **QBCore** framework that allows players to use radio items to communicate over different channels. It supports channel restrictions based on player jobs and duty status.

The script also logs radio join/leave events to a Discord webhook for monitoring.

***

### Features

* Usable radio item for connecting/disconnecting to radio channels.
* Job-based restricted radio channels.
* Dynamic radio item description update reflecting the connected channel.
* Discord webhook logging for radio actions (join/leave).
* Integration with **pma-voice** for voice channel permission checks.
* Works with QBCore inventory system.

***

### Dependencies

Make sure the following dependencies are installed and properly configured:

1. **Latest Release of** [**QBCore Framework**](https://github.com/qbcore-framework/qb-core)
   * Required for player data and inventory management.
2. **Latest Release of** [**PMA-Voice**](https://github.com/AvarianKnight/pma-voice)
   * Handles voice channel functionality and permission checks.
3. **Latest Release of** [**QB-INVENTORY**](https://github.com/qbcore-framework/qb-inventory) **OR** [**OX\_INEVNTORY**](https://github.com/overextended/ox_inventory/releases/latest/download/ox_inventory.zip)
   * Required for show item metadata
4. **Latest Release of** [**QB-RADIALMENU**](https://github.com/qbcore-framework/qb-radialmenu)
   * You link it with radio for quickly channel connection
5. **Discord Webhook**
   * Used for sending radio log messages.

***

### Configuration

Configuration options are set in the `config.lua` file.

| Setting              | Description                                                    |
| -------------------- | -------------------------------------------------------------- |
| `RadioItem`          | The inventory item name used for radios (default: `"radio"`).  |
| `RestrictedChannels` | Table defining restricted channels and which jobs have access. |
| `RadioLogsWebhook`   | Discord webhook URL for radio log messages.                    |

Example:

```lua
Config = {}

Config.Locale = 'en' 
Config.RadioItem = 'radio'
Config.MaxFrequency = 999
Config.RadioLogsWebhook = "PUT YOUR WEBHOOK URL HERE"

Config.RestrictedChannels = {
    [1] = { police = true, ambulance = true},
    [2] = { police = true, ambulance = true},
    [3] = { police = true, ambulance = true},
    [4] = { police = true, ambulance = true},
    [5] = { police = true, ambulance = true},
    [6] = { police = true, ambulance = true},
    [7] = { police = true, ambulance = true},
    [8] = { police = true, ambulance = true},
    [9] = { police = true, ambulance = true},
    [10] = { police = true, ambulance = true},
}
```

***

### Installation

1. Ensure **QBCore** and **pma-voice** resources are installed and running on your server.
2. Place the `sbs-radio` resource folder in your server's resources directory.
3. Add the following lines to your `server.cfg`:

```
ensure qb-core
ensure pma-voice
ensure sbs-radio
```

4. Edit `config.lua` with your custom settings, including your Discord webhook URL.
5. Add item <kbd>radio</kbd> For :\
   \&#xNAN;***QB-inventory :***\
   ***Go to***\ <kbd>qb-core/shared/items</kbd>  and add this

   ```lua
   radio                        = { name = 'radio', label = 'Radio', weight = 2000, type = 'item', image = 'radio.png', unique = true, useable = true, shouldClose = true, description = '' },
   ```

   \
   \&#xNAN;***OX\_INVENTORY :***\
   ***Go to***\ <kbd>ox\_inventory/data/items</kbd> and add this

   ```lua
   ['radio'] = {
       label = 'Radio',
       weight = 1000,
       allowArmed = true,
       consume = 0,
       client = {
           event = 'sbs-radio:use'
       },
   },
   ```

***

Item Image

<figure><img src="/files/2IbNwDSHjocWTiyxiqWZ" alt=""><figcaption></figcaption></figure>

***

### Usage

* Players receive/use the radio item (`Config.RadioItem`) to connect to radio channels.
* When attempting to join restricted channels, the script checks the player's job and duty status.
* Radio item descriptions are updated dynamically to show connection status.
* Join and leave events are automatically logged and sent to Discord.

***

### Server Events & Callbacks

| Event/Callback                                       | Description                                      |
| ---------------------------------------------------- | ------------------------------------------------ |
| `sbs-radio:use`                                      | Triggered when a player uses the radio item.     |
| `sbs-radio:updateItemDescription(slot, description)` | Updates the radio item description in inventory. |
| `sb-radio:logRadioAction(action, channel)`           | Logs a player’s join/leave radio actions.        |
| Callback `"sbs-radio:hasRadioItem"`                  | Checks if player has the radio item.             |

***

### Notes

* Make sure that the `RestrictedChannels` table matches your server's job names and roles.
* The radio item name must match an item in your QBCore inventory.
* Localization keys should be present for all relevant messages if using multilingual support.
* Adjust webhook settings to a valid Discord webhook URL for logging.


---

# 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:

```
GET https://shadow-byte-studio.gitbook.io/shadow-byte-studio-docs/sbs-radio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
