mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
refactor(notify): minor cleanup for notification audio
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user