> 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

sbs-radio Documentation

### 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 :\
   ***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 = '' },
   ```

   \
   ***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="https://838935413-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLZ2ceeAMsMj0M4qdz2T%2Fuploads%2FLgwVtsw8SI7SqpSLbo7W%2Fradio2.png?alt=media&amp;token=fa34e4d5-5ac6-4874-9289-57a02cf277bf" 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.
