Import custom-made audio files and spatialize them in GTA V
April 10, 2026
In this tutorial, we will see how to import manually created audio files and spatialize them in GTA V using FiveM and the xSound mod.
We will add the native audio method later.
Prerequisites
- GTA V installed
- FiveM installed with a functional local server
- A mod installed (see the tutorial for creating a mod and scripting with FiveM)
Installing the xSound mod
- Download the latest version of xSound from the GitHub repository.
- Extract the archive, rename the obtained folder to xsound, and place it in the resources directory of your server, for example: C:\Users<user>\Desktop\txData\FiveMBasicServerCFXDefault_BC1780.base\resources\xsound
- Open the server configuration file (server.cfg) and add the following line to ensure the mod is loaded: ensure xsound
The mod is now correctly installed.
Preparing the audio script in the FiveM server
(optional if you don't already have a script folder)
- In the resources directory of your server, create a new folder named audio_mod (or any name of your choice).
- Add an fxmanifest.lua file in this folder with the following content:
fx_version 'cerulean'
game 'gta5'
author 'An awesome dude'
description 'Audio spatialization demo'
version '1.0.0'
files {
'sounds/sound-1.wav'
}
client_script 'audio_script.lua'
- Create the audio_script.lua file (in the same folder) and paste the following code into it:
local spawnPos = vector3(-22.28888, 22.04243, 72.0)
local soundPos1 = vector3(spawnPos.x, spawnPos.y - 5.0, spawnPos.z - 1.0) -- adjust `triangleWidth` if needed
local xSound = exports.xsound
Citizen.CreateThread(function()
-- Player spawn management
exports.spawnmanager:setAutoSpawnCallback(function()
exports.spawnmanager:spawnPlayer({
x = spawnPos.x,
y = spawnPos.y,
z = spawnPos.z,
model = 'A_M_M_Golfer_01'
}, function()
print("Player spawned at custom location with custom model.")
end)
end)
exports.spawnmanager:setAutoSpawn(true)
exports.spawnmanager:forceRespawn()
-- Play spatialized sound
xSound:PlayUrlPos("mySound", "https://cfx-nui-custom_code/sounds/sound-1.wav", 1.0, soundPos1, true)
xSound:Distance("mySound", 20.0)
xSound:setSoundDynamic("mySound", true)
end)
-- Separate thread to display debug markers
Citizen.CreateThread(function()
while true do
Wait(0)
-- Marker 1 (red)
DrawMarker(1, soundPos1.x, soundPos1.y, soundPos1.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1.0, 1.0, 1.0, 255, 0, 0, 100, false, true, 2, false, nil, nil, false)
-- Listening distance circle (radius 20 m)
local radius = 20.0
local segments = 64
local angle = (2 * math.pi) / segments
for i = 0, segments do
local x1 = soundPos1.x + radius * math.cos(i * angle)
local y1 = soundPos1.y + radius * math.sin(i * angle)
local x2 = soundPos1.x + radius * math.cos((i + 1) * angle)
local y2 = soundPos1.y + radius * math.sin((i + 1) * angle)
DrawLine(x1, y1, soundPos1.z + 0.2, x2, y2, soundPos1.z + 0.2, 255, 0, 0, 100)
end
end
end)
Attention: when referencing a file in our script, the path must be relative to the server and the mod, following the following convention:
https://cfx-nui-${resourceName}/${filepath}In my case, the correct path is:https://cfx-nui-custom_code/sounds/sound-1.wav
- Save the audio file (sound-1.wav) in the sounds subfolder of the audio_mod directory.
- Open the server.cfg file (at the root of the server) and add the following line:
start audio_mod
Testing the script
- Launch your FiveM server.
- Connect with the FiveM client.
- The player should appear at the defined position, and the sound sound-1.wav will be played spatially around the point soundPos1.
- The red markers and the 20 m circle will allow you to visualize the listening area.
Translated by AI from the French version.





