refactor(notify): minor cleanup for notification audio

This commit is contained in:
Linden
2024-04-03 14:56:08 +11:00
parent 1922c8a8ec
commit dbbb4b6563

View File

@@ -10,34 +10,35 @@
---@field position? NotificationPosition
---@field type? NotificationType
---@field style? { [string]: any }
---@field icon? string | {[1]: IconProp, [2]: string};
---@field iconAnimation? IconAnimationType;
---@field iconColor? string;
---@field alignIcon? 'top' | 'center';
---@field sound? {bank?: string, set: string, name: string}
---@field icon? string | { [1]: IconProp, [2]: string }
---@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'
local settings = require 'resource.settings'
---`client`
---@param data NotifyProps
---@diagnostic disable-next-line: duplicate-set-field
function lib.notify(data)
local sound = settings.notification_audio and data.sound
data.sound = nil
SendNUIMessage({
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
if not sound then return end
if sound.bank then lib.requestAudioBank(sound.bank) end
local soundId = GetSoundId()
PlaySoundFrontend(soundId, sound.name, sound.set, true)
ReleaseSoundId(soundId)
if sound.bank then ReleaseNamedScriptAudioBank(sound.bank) end
end
---@class DefaultNotifyProps