Server exports

Notifications and signal

Server exports that send a notification to a player's notebook and read the player's signal.

Any resource may call these exports.

#Notify

Sends a notification to a player's notebook.

lua---@param src integer player server id
---@param data table { title, message, app?, offline?, kind?, icon?, duration?, progress? }
---@return boolean sent
exports['fx-pocketbook']:Notify(src, data)
luaexports['fx-pocketbook']:Notify(source, {
    title = 'Sheriff',
    message = 'Your hunting licence expires tomorrow.',
    app = 'kartlarim',
    kind = 'warn',
})

The fields are the same as the client [Notify](/phone/docs/pocketbook/exports/client/notifications-and-signal): only title and message are required, and a field that is not valid is left out.

Field Type What it does
title string Required. Cut to 64 characters.
message string Required. Cut to 220 characters.
app string The sending app's id: its name, picture, sound and badge. Clicking the card opens the app.
offline boolean true shows it even when the player has no signal.
kind string 'info', 'success', 'warn', 'error', 'money', 'mail' or 'telegram': a coloured ribbon. Notices of the same app and kind fold into one card with a "+N new" count.
icon string An app id whose picture the card shows instead of the sender's.
duration number Milliseconds on screen, 1500 to 15000.
progress number or false 0 to 1 for a fixed line, false for none.
  • Returns false when the player has no loaded character, or title or message is not a string.
  • true means it was sent to the player. On the player's side the same rules as the client [Notify](/phone/docs/pocketbook/exports/client/notifications-and-signal) apply: without signal and without offline = true it waits until the signal comes back.
  • Every call is written to the server log with the calling resource.

#GetSignal

Returns a player's signal bars as the server sees them.

lua---@param src integer
---@return integer bars 0 to 5
exports['fx-pocketbook']:GetSignal(src)
lualocal bars = exports['fx-pocketbook']:GetSignal(source)

The server counts:

  • 5 when Config.Signal.Enabled is false.
  • 5 when the player is inside a town listed in Config.Towns (the player's game reports the town every poll; a report is kept for Config.Signal.IdleInterval × 3 ms, at least 6 seconds).
  • Otherwise the best of every relay pole in the same routing bucket within Config.Signal.Pole.Range metres, and, while the separate fx-radio resource is started, a worn back radio with a charged battery. A pole gives more bars the closer the player stands.

#CanUseOnline

Returns whether a player's signal is strong enough to send or to receive.

lua---@param src integer
---@param operation 'send'|'receive'
---@return boolean ok
exports['fx-pocketbook']:CanUseOnline(src, operation)
luaif not exports['fx-pocketbook']:CanUseOnline(source, 'send') then
    return { ok = false, error = 'No telegraph line here.' }
end
  • 'receive' compares the bars with Config.Signal.ReceiveBars. Any other value compares them with Config.Signal.SendBars.
  • Call it in your custom app actions when the action needs a line. The core does not check signal for custom apps.