Exports ​
Server ​
server
| Export | Returns | Description |
|---|---|---|
GetAircraft() |
Aircraft[] |
Every registered aircraft, parked ones included. See below |
GetAircraftByNetId(netId) |
Aircraft | nil |
One aircraft by network id |
SetTransponder(netIdOrEntity, data) |
state | nil, err |
Change an aircraft's transponder. See below |
GetSubscribers() |
table[] |
Everyone receiving radar data: { source, mode, range, primary } |
RegisterAccessCheck(fn) |
boolean |
Add a veto hook. See below |
GetAircraft ​
for _, a in ipairs(exports.np_flightradar:GetAircraft()) do
print(a.callsign, a.kind, a.squawk, a.transponder, a.emergency, a.coords)
end
local a = exports.np_flightradar:GetAircraftByNetId(netId)
| Field | Type | Description |
|---|---|---|
netId |
number | Network id |
entity |
number | Server entity handle |
kind |
'heli' | 'plane' |
|
model |
number | Model hash |
plate |
string | nil | Trimmed plate |
callsign |
string | Resolved callsign (see Configuration) |
squawk |
string | 4 octal digits |
transponder |
boolean | Transponder on |
emergency |
string | nil | '7500', '7600' or '7700' while squawking it with the transponder on |
coords |
vector3 | Position |
heading |
number | GTA heading (degrees, counter-clockwise) |
speed |
number | Ground speed in m/s |
pilot |
number | nil | Server id of the pilot, if a player flies it |
GetAircraft ignores Config.Traffic; it lists every helicopter and plane the server knows.
SetTransponder ​
local state, err = exports.np_flightradar:SetTransponder(netId, { on = true, squawk = '7700', callsign = 'AIR-1' })
if not state then print('transponder failed:', err) end
netIdOrEntity is a network id or a server entity handle. data may contain any of:
| Key | Value |
|---|---|
on |
boolean |
squawk |
4 digits 0 – 7, as a string (or an integer up to 7777) |
callsign |
String, cleaned to A-Z0-9-, max. 8. '' or false resets it |
Returns the new state { on, squawk, callsign }, or nil and an error key: not_in_aircraft (no such registered
aircraft), squawk_invalid or callsign_invalid. There is no seat check and no rate limit for exports. Switching into
an emergency squawk alerts exactly as if the pilot had done it, with by = nil.
RegisterAccessCheck ​
exports.np_flightradar:RegisterAccessCheck(function(src, mode)
if mode == 'ground' and not exports.my_dispatch:IsSignedIn(src) then return false end
end)
fn(src, mode) runs every time the server resolves a mode for a player, after the job, item, seat and admin checks
and after Config.CanUse. Return false to deny that mode; any other value allows it. Errors are caught and count as
allowed. Returns false if fn is not callable. Hooks can't be removed, so register them once when your resource
starts. Resolved access is cached for up to 30 s per player.
Client ​
client
| Export | Returns | Description |
|---|---|---|
OpenRadar(mode?) |
Open the panel. nil = best granted mode, or 'admin', 'station', 'ground', 'air', 'item'. 'phone' and unknown values count as nil. The server still decides |
|
CloseRadar() |
Close the panel | |
IsRadarOpen() |
boolean |
|
GetContacts() |
Contact[] |
The latest contacts (see NUI contract), all ranges |
GetTransponder() |
table | nil |
{ on, squawk, callsign, canEdit } for the aircraft you sit in, or nil |
SetSquawk(code) |
boolean |
Ask the server to set your squawk. true when the request was sent (you are pilot or allowed copilot, valid code) |
useScanner(data, slot) |
np_inventory item use. Toggles the panel in item mode |
if exports.np_flightradar:IsRadarOpen() then exports.np_flightradar:CloseRadar() end
local x = exports.np_flightradar:GetTransponder()
if x and x.canEdit then exports.np_flightradar:SetSquawk('7600') end