Skip to content

Commit bd3df9e

Browse files
committed
fix: audio bank an optional param and playSoundFromEntity server side now works
1 parent e6bf30e commit bd3df9e

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

client/main.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local function loadAudioBank(audioBank)
2+
if not audioBank then return end
23
local timeout = 500
34
while not RequestScriptAudioBank(audioBank, false) do
45
if timeout == 0 then
@@ -11,8 +12,13 @@ local function loadAudioBank(audioBank)
1112
return true
1213
end
1314

15+
local function releaseAudioBank(audioBank)
16+
if not audioBank then return end
17+
ReleaseNamedScriptAudioBank(audioBank)
18+
end
19+
1420
---@class PlaySoundParams
15-
---@field audioBank string
21+
---@field audioBank? string
1622
---@field audioName string|string[]
1723
---@field audioRef string
1824

@@ -27,12 +33,12 @@ local function playSound(data)
2733
PlaySoundFrontend(soundId, audioName, data.audioRef, false)
2834
ReleaseSoundId(soundId)
2935
end
30-
ReleaseNamedScriptAudioBank(data.audioBank)
36+
releaseAudioBank(data.audioBank)
3137
end
3238

3339
exports('PlaySound', playSound)
3440

35-
RegisterNetEvent('mana_audio:client:playSoundFromEntity', playSound)
41+
RegisterNetEvent('mana_audio:client:playSound', playSound)
3642

3743
---@class PlaySoundFromEntityParams: PlaySoundParams
3844
---@field entity number
@@ -49,7 +55,7 @@ local function playSoundFromEntity(data)
4955
PlaySoundFromEntity(soundId, audioName, data.entity, data.audioRef, false, false)
5056
ReleaseSoundId(soundId)
5157
end
52-
ReleaseNamedScriptAudioBank(data.audioBank)
58+
releaseAudioBank(data.audioBank)
5359
end
5460

5561
exports('PlaySoundFromEntity', playSoundFromEntity)
@@ -79,7 +85,7 @@ local function playSoundFromCoords(data)
7985
PlaySoundFromCoord(soundId, audioName, data.coords.x, data.coords.y, data.coords.z, data.audioRef, false, data.range, false)
8086
ReleaseSoundId(soundId)
8187
end
82-
ReleaseNamedScriptAudioBank(data.audioBank)
88+
releaseAudioBank(data.audioBank)
8389
end
8490

8591
exports('PlaySoundFromCoords', playSoundFromCoords)

0 commit comments

Comments
 (0)