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.