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] 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%")