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)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)submoduleName
string
The name of the submodule whose configuration is to be retrieved.
table or nil
A table containing the configuration for the specified plugin.
Returns
nilif 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.")
endGetUnitByPlayerId
Retrieves the unit information associated with a player based on their identifiers.
exports.sonorancad.GetUnitByPlayerId(player)player
PlayerSource
The player ID for whom the associated unit is being retrieved.
table or nil
A table representing the unit information for the player if found in
UnitCache.nilif 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.")
endGetUnitCache
Returns the global UnitCache table containing unit data.
None
table
The entire
UnitCachetable, which stores unit-related data.If
UnitCacheis empty or uninitialized, an empty table is returned.
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.
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.
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.
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.
blipId
number
The unique ID of the blip to be modified.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
origin
number
Source of the dispatch call (see ORIGIN enum in SonoranCAD documentation). Typically 0
status
number
Initial call status (see STATUS enum). Typically 0
priority
number
Call priority: 1 (high), 2 (medium), 3 (low).
block
string
Block or unit number of the incident location.
address
string
Full address or street description of the incident.
postal
string
Postal code corresponding to the call’s location.
title
string
Short title of the dispatch call (e.g., "Traffic Stop").
code
string
CAD signal or code (e.g., "10-39 - Traffic Stop").
primary
number
Identifier of the primary unit assigned to the call.
trackPrimary
boolean
Whether to track the primary unit on the live map.
description
string
Detailed description of the situation.
notes
array
Array of note objects related to the call. Optional.
metaData
array
Custom key-value metadata for internal tracking or display. Optional.
units
array
Array of unit API IDs (e.g., Steam hex IDs) to assign to the call.
cb
function
Callback function to handle the API response.
This function does not return a value directly. The data modification happens asynchronously using API requests.
Last updated
Was this helpful?

