From 6cae839f8fb81b82ffde93d54f406bf822c08ce1 Mon Sep 17 00:00:00 2001 From: RodericAguilar <84584545+RodericAguilar@users.noreply.github.com> Date: Mon, 28 Jul 2025 08:42:26 +0200 Subject: [PATCH 1/3] 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. --- [core]/esx_notify/Notify.lua | 6 +++++- [core]/esx_notify/nui/js/script.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/[core]/esx_notify/Notify.lua b/[core]/esx_notify/Notify.lua index a0503f6f..f0045251 100644 --- a/[core]/esx_notify/Notify.lua +++ b/[core]/esx_notify/Notify.lua @@ -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 diff --git a/[core]/esx_notify/nui/js/script.js b/[core]/esx_notify/nui/js/script.js index b2a24bd3..73902b80 100644 --- a/[core]/esx_notify/nui/js/script.js +++ b/[core]/esx_notify/nui/js/script.js @@ -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%") From cd0874dc6bdc7a7f8d70a960edb9964665b25999 Mon Sep 17 00:00:00 2001 From: RodericAguilar <84584545+RodericAguilar@users.noreply.github.com> Date: Mon, 28 Jul 2025 11:54:56 +0200 Subject: [PATCH 2/3] refactor(esx_notify): move sound toggle to config and apply camelCase --- [core]/esx_notify/Config.lua | 3 +++ [core]/esx_notify/Notify.lua | 4 +--- [core]/esx_notify/fxmanifest.lua | 2 +- [core]/esx_notify/nui/js/script.js | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 [core]/esx_notify/Config.lua diff --git a/[core]/esx_notify/Config.lua b/[core]/esx_notify/Config.lua new file mode 100644 index 00000000..90f6d653 --- /dev/null +++ b/[core]/esx_notify/Config.lua @@ -0,0 +1,3 @@ +Config = {} + +Config.notificationSoundEnabled = true \ No newline at end of file diff --git a/[core]/esx_notify/Notify.lua b/[core]/esx_notify/Notify.lua index f0045251..0061974e 100644 --- a/[core]/esx_notify/Notify.lua +++ b/[core]/esx_notify/Notify.lua @@ -1,7 +1,5 @@ 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 @@ -39,7 +37,7 @@ local function Notify(notificatonType, length, message, title) length = length or 5000, message = message or "ESX-Notify", title = title or "New Notification", - NotificationSoundEnabled = NotificationSoundEnabled + notificationSoundEnabled = Config.notificationSoundEnabled })) end diff --git a/[core]/esx_notify/fxmanifest.lua b/[core]/esx_notify/fxmanifest.lua index 55862551..39492e81 100644 --- a/[core]/esx_notify/fxmanifest.lua +++ b/[core]/esx_notify/fxmanifest.lua @@ -8,7 +8,7 @@ description 'A beautiful and simple NUI notification system for ESX' shared_script '@es_extended/imports.lua' -client_scripts { 'Notify.lua' } +client_scripts { 'Notify.lua', 'Config.lua'} ui_page 'nui/index.html' diff --git a/[core]/esx_notify/nui/js/script.js b/[core]/esx_notify/nui/js/script.js index 73902b80..1152ed14 100644 --- a/[core]/esx_notify/nui/js/script.js +++ b/[core]/esx_notify/nui/js/script.js @@ -83,7 +83,7 @@ w.addEventListener("message", (event) => { title: event.data.title || "New Notification", message: event.data.message, length: event.data.length, - NotificationSoundEnabled: event.data.NotificationSoundEnabled, + notificationSoundEnabled: event.data.notificationSoundEnabled, }) }) @@ -174,7 +174,7 @@ const notification = (data) => { width: "0%", }) - if (data.NotificationSoundEnabled) { + if (data.notificationSoundEnabled) { playNotificationSound(data.type) } From 55bb0d223f74226e40eac844b59d34c10547160f Mon Sep 17 00:00:00 2001 From: RodericAguilar <84584545+RodericAguilar@users.noreply.github.com> Date: Mon, 28 Jul 2025 13:40:27 +0200 Subject: [PATCH 3/3] Update fxmanifest.lua --- [core]/esx_notify/fxmanifest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/esx_notify/fxmanifest.lua b/[core]/esx_notify/fxmanifest.lua index 39492e81..b74403b2 100644 --- a/[core]/esx_notify/fxmanifest.lua +++ b/[core]/esx_notify/fxmanifest.lua @@ -8,7 +8,7 @@ description 'A beautiful and simple NUI notification system for ESX' shared_script '@es_extended/imports.lua' -client_scripts { 'Notify.lua', 'Config.lua'} +client_scripts { 'Config.lua', 'Notify.lua'} ui_page 'nui/index.html'