Exports & state ​
What other resources may rely on: a dispatch that wants to know who is flying a bird, a job that recalls birds, a dashboard that reads what the birds filed. np_spy-pigeon keeps this surface small, because everything about evidence and cases lives in np_surveillance (below).
The resource name has a dash, so use bracket syntax: exports['np_spy-pigeon']:IsPigeon(src).
Rules that hold for all of it:
- Tables you get are copies. Changing them changes nothing in np_spy-pigeon.
- Wait for the resource before the first call:
GetResourceState('np_spy-pigeon') == 'started'. - np_spy-pigeon fires no events of its own. Subscribe to np_surveillance's stream for what the birds do.
Server exports ​
server
| Export | Returns |
|---|---|
IsPigeon(src) |
true while that player flies a bird (from the moment the flight is accepted until it is cleaned up) |
GetSessions() |
A list of the active flights (below) |
EndSession(src, reason) |
true when that player had a flight (it is being ended), false otherwise |
-- is this player a bird?
local flying = exports['np_spy-pigeon']:IsPigeon(src)
-- send every bird home
for _, s in ipairs(exports['np_spy-pigeon']:GetSessions()) do
exports['np_spy-pigeon']:EndSession(s.src, 'recall')
end
GetSessions ​
{ { id = 'S-6702a1f0-1', src = 12, loftId = 'mrpd', bird = 'pigeon', serial = 'MRPD-07', callsign = 'Gary',
operator = 'John Doe', caseId = 12, -- caseId is nil on a flight without a case
loadout = { camera = true, mic = true, mark = false, dropping = 5 },
startedAt = 1790000000, linkRange = 2500.0, batteryCapacity = 700,
battery = 64, health = 100, alt = 68, state = 'flying', coords = { x = 0.0, y = 0.0, z = 0.0, w = 0.0 } } }
state is one of launching, flying, perched, charging, camera, gliding, grabbed, returning. battery,
health, alt, state and coords are refreshed every Config.Session.telemetryInterval (2 s). Treat the list as read
only.
EndSession ​
EndSession(src, reason) asks the client to end the flight: the bird is turned back into the player, the body at the loft
is removed, and the cooldown starts. If the client does not answer within ten seconds the server cleans up anyway.
reason is a short string ('recall' when you give none). 'caught' and 'body' count as lost and start the long
lostCooldown; every other reason is a normal return with the short returnCooldown. np_admin's staff actions use
'admin'.
Client export ​
client
| Export | Returns |
|---|---|
IsPigeon() |
true while the local player is a bird |
State bag ​
While a bird flies, Player(src).state.npSpyPigeon is set and replicated. It is nil at any other time.
-- { id, serial, callsign, bird, loftId, state }
local bag = Player(src).state.npSpyPigeon
if bag then print(bag.callsign, bag.serial, bag.state) end
| Field | Content |
|---|---|
id |
The flight id |
serial, callsign |
The bird (MRPD-07, Gary) |
bird |
pigeon, seagull or crow |
loftId |
The loft it left from |
state |
The flight state, as in GetSessions |
The case is not in the bag; ask GetSessions() on the server if you need it.
Reading bird intel ​
np_spy-pigeon stores no evidence. Everything a bird files is np_surveillance intel on a case, read with np_surveillance's
own API (np_surveillance → Exports, hooks on
#hooks).
-- server: every entry the birds file, as it is added
exports.np_surveillance:onIntel(function(intel)
if not intel.source or intel.source.type ~= 'bird' then return end
print(('%s (%s) filed a %s on case %s'):format(
intel.payload.callsign, intel.payload.serial, intel.kind, intel.caseId))
end)
-- server: the case behind it (title, status, members, subjects)
local case = exports.np_surveillance:getCase(intel.caseId)
| Field of the intel | Content for a bird |
|---|---|
source |
{ type = 'bird', id = <serial> } |
kind |
document (photo), sighting (plate read, mark) or audio (mic) |
severity |
1 for photos and audio, 2 for sightings, 4 for a plate on an np_helicam BOLO list |
coords |
Where the bird was |
subjectId |
Set on the sighting of a marked person |
payload.bird, .serial, .callsign, .operator |
The bird type, serial, callsign and the officer's name |
payload of a photo |
media = 'photo', url, street, heading, plates, people |
payload of a plate read |
plate, model, color, bolo, how = 'plate read' |
payload of the mic |
voices, seconds, how = 'directional mic' |
payload of a mark |
how = 'bird mark', and name (a person) or plate and model (a vehicle) |
A printable case file is made in np_surveillance's Dossiers tab (Dossiers); there is no separate export for it here.
The bird also announces itself to np_surveillance as the source np_spy-pigeon and pings it. That is the bridge's
business and carries no case data (Integrations → np_surveillance).