feat(client/notification): add support for native audio sounds (#455)

This commit is contained in:
Ethan
2024-04-03 04:48:08 +01:00
committed by GitHub
parent 1ab6d3dd00
commit 5e6db9d024
2 changed files with 30 additions and 0 deletions

View File

@@ -14,6 +14,9 @@
---@field iconAnimation? IconAnimationType;
---@field iconColor? string;
---@field alignIcon? 'top' | 'center';
---@field sound? {bank?: string, set: string, name: string}
local enableSound = GetConvar('ox:enableSound', 'true') == 'true'
---`client`
---@param data NotifyProps
@@ -23,6 +26,18 @@ function lib.notify(data)
action = 'notify',
data = data
})
if not enableSound then return end
if data.sound then
if data.sound?.bank then
lib.requestAudioBank(data.sound.bank)
end
local soundId = GetSoundId()
PlaySoundFrontend(soundId, data.sound.name, data.sound.set, true)
ReleaseSoundId(soundId)
if data.sound?.bank then
ReleaseNamedScriptAudioBank(data.sound.bank)
end
end
end
---@class DefaultNotifyProps