mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
feat(esx_notify): add toggle for notification sound playback
This PR adds support for enabling or disabling the notification sound in `esx_notify`. A new variable `NotificationSoundEnabled` (default: true) controls whether a sound should be played when a notification is shown. ```lua ---@type boolean Whether the notification sound should be played local NotificationSoundEnabled = true ``` - [x] My commit messages and PR title follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. - [ ] My changes have been tested locally and function as expected. - [x] My PR does not introduce any breaking changes. - [x] I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
local Debug = ESX.GetConfig().EnableDebug
|
||||
|
||||
---@type boolean Whether the notification sound should be played.
|
||||
local NotificationSoundEnabled = true
|
||||
|
||||
---@param notificatonType string the notification type
|
||||
---@param length number the length of the notification
|
||||
---@param message any the message :D
|
||||
@@ -35,7 +38,8 @@ local function Notify(notificatonType, length, message, title)
|
||||
type = notificatonType or "info",
|
||||
length = length or 5000,
|
||||
message = message or "ESX-Notify",
|
||||
title = title or "New Notification"
|
||||
title = title or "New Notification",
|
||||
NotificationSoundEnabled = NotificationSoundEnabled
|
||||
}))
|
||||
end
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ w.addEventListener("message", (event) => {
|
||||
title: event.data.title || "New Notification",
|
||||
message: event.data.message,
|
||||
length: event.data.length,
|
||||
NotificationSoundEnabled: event.data.NotificationSoundEnabled,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -173,7 +174,10 @@ const notification = (data) => {
|
||||
width: "0%",
|
||||
})
|
||||
|
||||
playNotificationSound(data.type)
|
||||
if (data.NotificationSoundEnabled) {
|
||||
playNotificationSound(data.type)
|
||||
}
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
$(`#${id} .notify-progress`).css("width", "100%")
|
||||
|
||||
Reference in New Issue
Block a user