diff --git a/resource/interface/client/notify.lua b/resource/interface/client/notify.lua index ae19135..c8f09d6 100644 --- a/resource/interface/client/notify.lua +++ b/resource/interface/client/notify.lua @@ -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