mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
feat(client/notification): add support for native audio sounds (#455)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user