GhiaccioScripts

Radio

Installation

Ensure order, the radio item and framework notes for the Radio.

#1. Copy the resources

Copy ghiaccio_radio and ghiaccio_radio_props into resources/. Both are downloaded from portal.cfx.re > Granted Assets (see Cfx.re Escrow & asset grant).

#2. server.cfg

Start the radio after pma-voice, the framework and oxmysql, and ghiaccio_radio_props before ghiaccio_radio:

cfg
ensure pma-voice
setr voice_enableRadioAnim 0        # REQUIRED: radio animations are handled by ghiaccio_radio
ensure oxmysql                      # optional
ensure es_extended                  # or qb-core / qbx_core
ensure ghiaccio_radio_props         # BEFORE ghiaccio_radio (radio prop)
ensure ghiaccio_radio

With Config.MuteNativeClicks = true (default) the pma-voice microphone clicks are muted: the radio NUI plays its own sounds.

#3. Create the radio item

The item is required by default (Config.RequireItem = true). Use the snippet for your inventory, or set Config.RequireItem = false.

#ox_inventory (also Qbox)

In ox_inventory/data/items.lua:

lua
['radio'] = {
    label = 'Radio',
    weight = 500,
    stack = false,
    close = true,
    description = 'A walkie-talkie.',
    client = { event = 'ghiaccio_radio:client:use' },   -- using the item opens the radio
},

#qb-inventory / ps-inventory / lj-inventory

In qb-core/shared/items.lua:

lua
radio = { name = 'radio', label = 'Radio', weight = 500, type = 'item', image = 'radio.png', unique = true, useable = true, shouldClose = true, description = 'A walkie-talkie.' },

Use is registered by the resource with CreateUseableItem when Config.UsableItem = true.

#qs-inventory

In qs-inventory/shared/items.lua:

lua
['radio'] = { name = 'radio', label = 'Radio', weight = 500, type = 'item', image = 'radio.png', unique = true, useable = true, shouldClose = true, description = 'A walkie-talkie.' },

#ESX inventory

Run on the items table:

sql
INSERT INTO `items` (`name`, `label`, `weight`) VALUES ('radio', 'Radio', 1);
-- versions with a `limit` column:  (`name`, `label`, `limit`) VALUES ('radio', 'Radio', 1);

Use is registered with ESX.RegisterUsableItem.

Different item name: Config.Item. Forced inventory: Config.Inventory = 'ox' | 'qb' | 'qs' | 'esx' | 'none'. Without an inventory (standalone) the requirement is ignored with a console warning. The server checks the item on open, power on, every connect and every Config.ItemCheckSeconds seconds (default 5): if the player loses it, the radio switches off and the window closes.

#4. Start and check the console

Restart and read the console: it prints the chosen framework, inventory and storage. Then open the radio in game with /radio (or F5).

#Database

No SQL to run by hand. With oxmysql started, the tables ghiaccio_radio_players and ghiaccio_radio_migrations are created by migrations. Without oxmysql the data goes to the server KVP (Config.Database = 'auto').

#Framework notes

  • ESX Legacy: job and grade from job.grade; usable item with ESX.RegisterUsableItem.
  • QBCore / Qbox: job and grade from job.grade.level, on-duty support, metadata.callsign as fallback callsign.
  • Standalone: nobody has a job and there is no inventory. Plug your own job system by returning { name, grade } from bridge/server/standalone.lua.

#Escrow: what you can edit

Encrypted: client/, server/, shared/. Plain and editable: config.lua, config_server.lua, bridge/, adapters/, locales/, stream/.