mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
refactor(notify): minor cleanup for notification audio
This commit is contained in:
@@ -10,34 +10,35 @@
|
|||||||
---@field position? NotificationPosition
|
---@field position? NotificationPosition
|
||||||
---@field type? NotificationType
|
---@field type? NotificationType
|
||||||
---@field style? { [string]: any }
|
---@field style? { [string]: any }
|
||||||
---@field icon? string | {[1]: IconProp, [2]: string};
|
---@field icon? string | { [1]: IconProp, [2]: string }
|
||||||
---@field iconAnimation? IconAnimationType;
|
---@field iconAnimation? IconAnimationType
|
||||||
---@field iconColor? string;
|
---@field iconColor? string
|
||||||
---@field alignIcon? 'top' | 'center';
|
---@field alignIcon? 'top' | 'center'
|
||||||
---@field sound? {bank?: string, set: string, name: string}
|
---@field sound? { bank?: string, set: string, name: string }
|
||||||
|
|
||||||
local enableSound = GetConvar('ox:enableSound', 'true') == 'true'
|
local settings = require 'resource.settings'
|
||||||
|
|
||||||
---`client`
|
---`client`
|
||||||
---@param data NotifyProps
|
---@param data NotifyProps
|
||||||
---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function lib.notify(data)
|
function lib.notify(data)
|
||||||
|
local sound = settings.notification_audio and data.sound
|
||||||
|
data.sound = nil
|
||||||
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'notify',
|
action = 'notify',
|
||||||
data = data
|
data = data
|
||||||
})
|
})
|
||||||
if not enableSound then return end
|
|
||||||
if data.sound then
|
if not sound then return end
|
||||||
if data.sound?.bank then
|
|
||||||
lib.requestAudioBank(data.sound.bank)
|
if sound.bank then lib.requestAudioBank(sound.bank) end
|
||||||
end
|
|
||||||
local soundId = GetSoundId()
|
local soundId = GetSoundId()
|
||||||
PlaySoundFrontend(soundId, data.sound.name, data.sound.set, true)
|
PlaySoundFrontend(soundId, sound.name, sound.set, true)
|
||||||
ReleaseSoundId(soundId)
|
ReleaseSoundId(soundId)
|
||||||
if data.sound?.bank then
|
|
||||||
ReleaseNamedScriptAudioBank(data.sound.bank)
|
if sound.bank then ReleaseNamedScriptAudioBank(sound.bank) end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class DefaultNotifyProps
|
---@class DefaultNotifyProps
|
||||||
|
|||||||
Reference in New Issue
Block a user