For the complete documentation index, see llms.txt. This page is also available as Markdown.

Server Functions

This page will explain all exported functions from the SonoranCAD Core that can be used on the server side

CadIsPlayerLinked

Checks if a specific CAD API ID exists by sending a request to the API and executing a callback with the result.

exports.sonorancad.CadIsPlayerLinked(apiId, callback)
Parameter
Type
Description

apiId

string

The CAD API ID to check. If empty or nil, the function assumes the ID does not exist.

callback

function

A function executed after the check completes. Receives a single parameter: exists (boolean).

This function does not return a value directly. Instead, the result of the API check is passed to the callback function.

-- Example: Checking if a CAD API ID exists
local function onApiIdCheck(exists)
    if exists then
        print("API ID exists!")
    else
        print("API ID does not exist.")
    end
end

exports.sonorancad.CadIsPlayerLinked("123456", onApiIdCheck)  -- Output depends on API response
exports.sonorancad.CadIsPlayerLinked("", onApiIdCheck)        -- Output: "API ID does not exist."

GetPluginConfig

Provides access to a specific plugin's configuration using the plugin name.

exports.sonorancad.GetPluginConfig(submoduleName)
Parameter
Type
Description

submoduleName

string

The name of the submodule whose configuration is to be retrieved.

Type
Description

table or nil

  • A table containing the configuration for the specified plugin.

  • Returns nil if the plugin name is invalid or if no configuration exists.

-- Example: Retrieving a plugin's configuration
local pluginConfig = exports.sonorancad.GetPluginConfig("callcommands")

if pluginConfig then
    print("Plugin Config:", json.encode(pluginConfig))
else
    print("Plugin not found or no configuration available.")
end

GetUnitByPlayerId

Retrieves the unit information associated with a player based on their identifiers.

exports.sonorancad.GetUnitByPlayerId(player)
Parameter
Type
Description

player

PlayerSource

The player ID for whom the associated unit is being retrieved.

Type
Description

table or nil

  • A table representing the unit information for the player if found in UnitCache.

  • nil if no associated unit is found.

-- Example: Getting the unit associated with a player
local unit = GetUnitByPlayerId(1)

if unit then
    print("Unit found:", json.encode(unit))
else
    print("No unit associated with this player.")
end

GetUnitCache

Returns the global UnitCache table containing unit data.

Parameter
Type
Description

includeDispatchers

boolean

Include an array of active dispatchers as well

callback

function

Optional callback that receives unitCache, dispatchers. Use this when calling the export from another CFX runtime or when callback-style handling is preferred.

Type
Description

table

  • The entire UnitCache table, which stores unit-related data.

  • If UnitCache is empty or uninitialized, an empty table is returned.

  • If includeDispatchers is true, will return arg1 - Standard UnitCache table, arg2- Array of dispatchers online. If false will only return standard UnitCache array.

  • When callback is provided, the same values are passed to the callback as unitCache, dispatchers. If includeDispatchers is false, the callback receives an empty dispatcher table for the second argument.

  • Dispatchers will be shown regardless if they are in-game or not. To check if a dispatcher is also in-game use the isInGame flag (boolean) on the unit

For in-game integrations, GetUnitCache is the preferred way to read active CAD unit data from another server resource. It reads SonoranCADFiveM's local real-time cache, so it is not limited by the public v2 API request limit and can be called repeatedly by your resource. If you are building an external service outside of FiveM, use the v2 Get Active Units API endpoint instead.

Each cached unit payload now includes unit.data.communityUserId when the CAD account was linked through the v2 community link flow. That gives third-party resources a stable way to map a CAD unit or push event back to an in-game player without relying on legacy API IDs.

To understand where that value comes from, see Map Players to CAD Users and the FiveM resource's LINKING_V2.md.

Typical pattern:

registerEndpoints

Registers API endpoints for use with the sonorancad resource.

None

This function does not return a value. It registers API endpoints with sonorancad.

addBlip

Adds a new blip to the map using the SonoranCAD integration.

Parameter
Type
Description

coords

vec2 (table)

A table containing x and y coordinates for the blip location.

colorHex

string

The hexadecimal color code (e.g., "#FF0000") for the blip.

subType

string

The subtype of the blip (e.g., police, fire, etc.).

toolTop

string

The tooltip text that appears when hovering over the blip.

icon

string

The icon for the blip (e.g., a specific image or identifier for visual context).

dataTable

table

Additional data associated with the blip, stored in a custom table.

cb

function

(Optional) A callback function executed with the API response.

This function does not return a value directly. The response from the API request is passed to the cb callback function if provided.

addBlips

Adds multiple blips to the map using the SonoranCAD integration.

Parameter
Type
Description

blips

table

A table containing multiple blip data objects to be added. (See addBlip for blip structure)

cb

function

(Optional) A callback function executed with the API response.

This function does not return a value directly. The response from the API request is passed to the cb callback function if provided.

removeBlip

Removes one or more blips from the map using the SonoranCAD integration.

Parameter
Type
Description

ids

table

A table containing the IDs of the blips to be removed.

cb

function

(Optional) A callback function executed with the API response.

This function does not return a value directly. The response from the API request is passed to the cb callback function if provided.

modifyBlipd

Modifies an existing blip's data on the map using the SonoranCAD integration.

Parameter
Type
Description

blipId

number

The unique ID of the blip to be modified.

dataTable

table

A table containing the new data for the blip. See addBlip for blip data structure

This function does not return a value. The request is sent to the MODIFY_BLIP endpoint.

getBlips

Fetches the list of all active blips from the SonoranCAD system.

Parameter
Type
Description

cb

function

(Optional) A callback function executed with the API response containing the blips.

This function does not return a value directly. The response from the API request is passed to the cb callback function if provided.

removeWithSubtype

Removes all blips of a specific subtype from the map using the SonoranCAD system.

Parameter
Type
Description

subType

string

The subtype of the blips to be removed (e.g., police, fire, etc.).

cb

function

(Optional) A callback function executed with the API response containing the blips.

This function does not return a value directly. The response from the removeBlip API request is passed to the cb callback function if provided.

call911

The call911 function facilitates the creation of a 911 emergency call within the SonoranCAD system by sending a structured API request.

Parameter
Type
Description

caller

string

Name of the individual initiating the call.

location

string

Description of the call's location (e.g., street address).

description

string

Detailed information about the emergency situation.

postal

string

Postal code corresponding to the call's location.

plate

string

(Optional) License plate number associated with the call, if applicable.

cb

function

(Optional) Callback function to handle the API response.

coords

table

A table containing the X and Y coordinates of the emergency call's location, typically sourced from in-game player or vehicle position. This is used to place the call accurately on the live map in CAD systems or dispatch plugins.

customMeta

table

A flexible table for including any custom metadata relevant to the emergency call.

deleteAfter

int

Number of minutes to automatically remove the call from CAD after

This function does not return a value directly. The response from the API request is passed to the cb callback function, if provided.

addTempBlipData

Temporarily modifies a blip's data in the SonoranCAD system and then reverts it back to its original data after a specified duration.

Parameter
Type
Description

blipId

number

The unique ID of the blip to modify.

blipData

table

A table containing the temporary data to apply to the blip. See addBlip for blip data structure

waitSeconds

number

The duration in seconds for which the temporary data will be applied.

returnToData

table

A table containing the original data to revert the blip to after the duration expires. See addBlip for blip data structure

This function does not return a value directly. The data modification happens asynchronously using API requests.

addTempBlipColor

Temporarily changes a blip's color in the SonoranCAD system and reverts it to its original color after a specified duration.

Parameter
Type
Description

blipId

number

The unique ID of the blip to modify.

color

string

The temporary hexadecimal color code to apply to the blip (e.g., "#FF0000")

waitSeconds

number

The duration in seconds for which the temporary data will be applied.

returnToColor

string

The original hexadecimal color code to revert the blip to after the duration expires

This function does not return a value directly. The color modification happens asynchronously using API requests.

remove911

Removes an active 911 call from the SonoranCAD system.

Parameter
Type
Description

callId

string

The unique ID of the 911 call to be removed.

This function does not return a value. The removal of the 911 call is handled asynchronously through the API request.

addCallNote

Adds a note to an existing 911 call in the SonoranCAD system.

Parameter
Type
Description

callId

string

The unique ID of the 911 call to be removed.

note

string

The content of the note to be added, typically describing the caller.

This function does not return a value. The addition of the call note is handled asynchronously through the API request.

setCallPostal

Updates the postal code of an existing 911 call in the SonoranCAD system.

Parameter
Type
Description

callId

string

The unique ID of the 911 call to be removed.

postal

string

The new postal code to assign to the 911 call.

This function does not return a value. The postal code update is handled asynchronously through the API request.

performLookup

Performs a lookup in the SonoranCAD system for information associated with a license plate.

Parameter
Type
Description

plate

string

The license plate number to look up in the SonoranCAD system.

cb

function

(Optional) A callback function executed with the API response.

This function does not return a value directly. The response from the API request is passed to the cb callback function if provided.

createDispatchCall

Creates a dispatch call in SonoranCAD using the v2 dispatch request format.

Parameter
Type
Description

data

table

A v2 create-dispatch request.

cb

function

Optional callback receiving (result, success).

The data table supports the same fields as the Create Dispatch Call v2 endpoint. origin, status, priority, and title are required. Include at least one of communityUserIds, accounts, roblox, or discord. To create an unassigned call, pass an empty communityUserIds or accounts array.

metaData must contain flat string key/value pairs. Coordinates belong directly under metaData as x, y, and z; do not pass a nested coords table.

This function does not return a value directly. If provided, cb receives a result string and a boolean indicating whether the request succeeded.

cadNameLookup

Perform a name lookup in CAD (Requires "Lookups" submodule to be enabled)

Parameter
Type
Description

first

string

First Name

last

string

Last Name

mi

string

Middle Initial

callback

function

Callback function to handle the API response.

autoLookup

string

API ID of the user to perform a lookup via API ID rather than name

This function will return the custom records related to the name as denoted in the Custom Records section

cadPlateLookup

Perform a plate lookup in CAD (Requires "Lookups" submodule to be enabled)

Parameter
Type
Description

plate

string

Plate number to lookup

basicFlag

null

Depreciated parameter, can be set to nil

callback

function

Callback function to handle the API response.

autoLookup

string

API ID of the user to perform a lookup via API ID rather than name

This function will return the custom records related to the plate as denoted in the Custom Records section

cadGetPlateInformation

Retrieve parsed registration, vehicle, owner, BOLO, and warrant data for a single plate while reusing the shared plate-information cache. This is the same lookup path used by the WraithV2 integration.

This function requires the lookups submodule to be enabled. Results are cached by normalized plate number for 60 seconds by default unless you override or bypass the cache in the options table.

Parameter
Type
Description

plate

string

Plate number to look up. Leading and trailing whitespace is trimmed before caching and lookup.

callback

function

Callback invoked as callback(regData, vehData, charData, boloData, warrantData).

options

table

Optional settings for CAD popup behavior and cache control.

options.autoLookup

string

Community user ID to trigger the CAD-side auto-open lookup behavior.

options.cacheTtlMs

number

Override the cache lifetime in milliseconds. Defaults to 60000.

options.bypassCache

boolean

When true, skips cache reads and writes for this request.

options.forceRefresh

boolean

When true, ignores any existing cached entry and refreshes it from CAD.

This function does not return values directly. The callback receives five parsed arrays:

  • regData: matching registration records

  • vehData: matching vehicle record data

  • charData: matching owner/civilian record data

  • boloData: active BOLO flags for the plate

  • warrantData: active warrant flags for the plate

getAllWarrantsAndBolos

Retrieve all active and inactive warrants and bolos with pagination support

Parameter
Type
Description

options

table

Options for pagination and filtering. If omitted, defaults are used (Optional)

options.pageSize / options.limit

number

Page size per API request. Default 100

options.offset

number

Starting offset for pagination. Default 0

options.maxPages / options.pageLimit / options.pages

number

Max number of pages to fetch before stopping (caps total results). Default: no cap

options.statuses / options.status

table | string | number

Status filter(s). Defaults to {0, 1} (open + closed). Accepts numeric values or strings: "open", "active", "closed", "inactive", "pending", "approved", "rejected"

options.types

table<number>

Record types to include. Default {2, 3} (Warrant + BOLO)

cb

function

Callback invoked as cb(records, meta) where records is the aggregated list and meta includes paging info or an error.

Last updated

Was this helpful?