Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion client/apps/notifications.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions server/notifications/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading