Docs

X3D Music

Free ESX boombox: place it on the ground or mount it on a car, play YouTube with a shared queue and distance falloff; speakers survive restarts.

Buy / Get freeConfig builder

Installation

  1. Put the x3d_music folder in resources/. Do not rename the folder.
  2. Run install.sql to create x3d_music_speakers and add the boombox item (with ox_inventory, add the item to items.lua instead; the file has an example).
  3. Add to server.cfg:
set x3d_music_ytkey "your YouTube API key"
ensure oxmysql
ensure es_extended
ensure x3d_music

Put the key in server.cfg only. Never put it in config/config.lua, which is sent to every player.

Getting a YouTube API key (free)

  1. Open the Google Cloud Console and create a project.
  2. APIs & Services > Library: find YouTube Data API v3 and enable it.
  3. Credentials > Create credentials > API key, then copy the key.
  4. Put it in server.cfg as above and restart the resource.

The free quota is 10,000 units a day and one search costs about 101, which is plenty for most servers. Without a key, players can still place speakers but cannot search or add songs.

Requirements

Resource Required Used for
es_extended yes ESX Legacy
oxmysql yes saving placed speakers

All settings: config/config.lua

Setting Default Meaning
Config.Locale 'th' 'th' or 'en'
Config.Item / Config.PropModel 'boombox' / 'prop_boombox_01' Item and prop
Config.SearchMaxResults 12 Search results
Config.SearchCooldownMs 4000 Time between searches (ms)
Config.MaxTrackSeconds 10800 Longest song (s); live streams cannot be added
Config.InteractDistance 2.5 [E] distance
Config.StreamDistance 65.0 Distance at which speakers appear
Config.Ranges / Config.DefaultRange {10,20,30} / 20 Selectable ranges
Config.DefaultVolume 60 Starting volume
Config.FalloffPower 1.6 How fast the volume drops with distance
Config.MaxConcurrentAudible 3 Speakers heard at once
Config.MaxSpeakers / Config.MaxPerPlayer 40 / 2 Speakers per server / per player
Config.QueueMax 25 Longest queue
Config.PublicQueue true false = only the owner adds songs
Config.AdminGroups admin, superadmin Control every speaker and use musicstop
Config.VehicleMount on Mount on vehicles, maxZOffset
Config.OwnedVehiclesTable 'owned_vehicles' ESX vehicle table for the owner check

Fitting your server: addons/

File Functions Default
addons/items/server.lua Items.Return(identifier) Into the ESX bag; if full or offline, returned on the next join
addons/vehiclekey/server.lua VehicleKey.Has(source, plate, vehicle) In the driver seat, or the owner in owned_vehicles
addons/notify/client.lua Notify(message, kind) esx_notify, then ox_lib, then ESX
addons/prompt/client.lua Prompt.Draw3D, Prompt.IsInteractPressed 3D text, [E]

Admin commands

Command Does
musicstop all Stops music and clears the queue on every speaker
musicstop <id> Stops one speaker (ids look like g12, v3)

Troubleshooting

Symptom Cause / fix
Search says there is no key set x3d_music_ytkey is missing from server.cfg, or comes after the ensure line
A song will not add It is a live stream or longer than Config.MaxTrackSeconds
Using the item does nothing The boombox item is missing from the database, or the player hit Config.MaxPerPlayer
Some songs are silent The uploader disabled embedding on YouTube; try another song
View product page