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)

ParameterTypeDescription

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).


GetPluginConfig

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

exports.sonorancad.GetPluginConfig(submoduleName)
ParameterTypeDescription

submoduleName

string

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


GetUnitByPlayerId

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

exports.sonorancad.GetUnitByPlayerId(player)
ParameterTypeDescription

player

PlayerSource

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

GetUnitCache

Returns the global UnitCache table containing unit data.

exports.sonorancad.GetUnitCache()

None

registerEndpoints

Registers API endpoints for use with the sonorancad resource.

exports.sonorancad.registerEndpoints()

None

addBlip

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

exports.sonorancad.addBlip(coords, colorHex, subType, toolTip, icon, dataTable, cb)
ParameterTypeDescription

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.

addBlips

Adds multiple blips to the map using the SonoranCAD integration.

exports.sonorancad.addBlips(blips, cb)

ParameterTypeDescription

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.

removeBlip

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

exports.sonorancad.removeBlip(ids, cb)
ParameterTypeDescription

ids

table

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

cb

function

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

modifyBlipd

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

exports.sonorancad.modifyBlipd(blipId, dataTable)
ParameterTypeDescription

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

getBlips

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

exports.sonorancad.getBlips(cb)
ParameterTypeDescription

cb

function

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

removeWithSubtype

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

exports.sonorancad.removeWithSubtype(subType, cb)
ParameterTypeDescription

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.

call911

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

exports.sonorancad.call911(caller, location, description, postal, plate, cb)
ParameterTypeDescription

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.

addTempBlipData

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

exports.sonorancad.addTempBlipData(blipId, blipData, waitSeconds, returnToData)
ParameterTypeDescription

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

addTempBlipColor

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

exports.sonorancad.addTempBlipData(blipId, color, waitSeconds, returnToColor)
ParameterTypeDescription

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

remove911

Removes an active 911 call from the SonoranCAD system.

exports.sonorancad.remove911(callId)
ParameterTypeDescription

callId

string

The unique ID of the 911 call to be removed.

addCallNote

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

exports.sonorancad.addCallNote(callId, note)
ParameterTypeDescription

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.

setCallPostal

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

exports.sonorancad.setCallPostal(callId, postal)
ParameterTypeDescription

callId

string

The unique ID of the 911 call to be removed.

postal

string

The new postal code to assign to the 911 call.

performLookup

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

exports.sonorancad.performLookup(plate, cb)
ParameterTypeDescription

plate

string

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

cb

function

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

Last updated