From 1460814562a7485c45d181a30ec4fff58b6c991f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Buggz=C2=A0=C2=B7=C2=A0=E0=B8=85=5E=E2=80=A2=EF=BB=8C?= =?UTF-8?q?=E2=80=A2=5E=E0=B8=85?= <56521233+lGodHatesMel@users.noreply.github.com> Date: Sun, 4 Oct 2026 19:37:31 -0400 Subject: [PATCH] fix(notifications): drop phone banners when the player carries no phone Incoming messages (and every other app banner) still popped up for a player with no phone item, because the senders push sd-phone:client:notify without checking inventory. Gate the banner at the client entry point instead of at each sender: the handler asks the new sd-phone:server:carriesPhone callback, which reads util.carriesPhone from the live inventory, and drops the banner when it returns false. Emergency alerts still get through, and servers with no Phone.Items configured are unaffected. Message data is still delivered, so the text is there once a phone is picked up again; only the pop-up is suppressed. --- client/apps/notifications.lua | 7 ++++++- server/notifications/init.lua | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/apps/notifications.lua b/client/apps/notifications.lua index 2681df787..3be59a58f 100644 --- a/client/apps/notifications.lua +++ b/client/apps/notifications.lua @@ -6,9 +6,14 @@ local function push(data) SendNUIMessage({ action = 'sd-phone:notification', data = data }) end ----Landing point for the server notify export; shape-checked by push. +---Landing point for the server notify export; shape-checked by push. Dropped when the player is +---not carrying a phone (the server owns that answer); emergency alerts always get through. ---@param data table notification payload RegisterNetEvent('sd-phone:client:notify', function(data) + if type(data) == 'table' and not data.emergency + and not lib.callback.await('sd-phone:server:carriesPhone', false) then + return + end push(data) end) diff --git a/server/notifications/init.lua b/server/notifications/init.lua index b1b303b83..862b18f39 100644 --- a/server/notifications/init.lua +++ b/server/notifications/init.lua @@ -85,6 +85,12 @@ function notifications.notifyCid(cid, data) }) end +---Asked by the client before it shows a banner: a player with no phone item has nothing to buzz, +---so the pop-up is dropped. Answered from the live inventory, never cached. +lib.callback.register('sd-phone:server:carriesPhone', function(src) + return require('server.util').carriesPhone(src) +end) + ---Sends the same notification addressed by phone number instead of server id. The number is ---digit-normalised before lookup; an unassigned number or offline owner returns false. A ---number on a pocketed (non-active) phone arrives as a colour-tagged transient buzz.