LogoLogo
SupportServer Hosting
  • Sonoran CAD
  • 📱Download The App
    • Steam Browser - Workaround
    • Web Browser - Clear Cache
    • Desktop App - Clear Cache
    • GTA RP Tablet - Clear Cache
    • Steam Browser - Clear Cache
  • Why Choose Sonoran CAD?
    • 🏆Why Choose Sonoran CAD?
  • Other Products
    • 🖥️FiveM Hosting
    • 📝Sonoran CMS
    • 📡Sonoran Radio
  • Tutorials
    • Getting Started
      • Registering Your Account
      • Registering Your Community
      • Inviting Users to Your CAD
      • Granting Account Permissions
      • View Your Limits
      • Community ID and API Keys
      • Troubleshooting
    • Customization
      • Custom Domain & Login Page
      • Customizing Your Layout
      • Community Branding and Settings
      • Creating Custom Record and Report Types
      • Sharing Custom Records
      • Custom Search Types
      • Geographical Settings
      • Penal Codes
      • 10-Codes
      • Addresses and Street Names
      • Unit Status Codes
      • Tone Board
      • Custom Audio Notifications
      • Custom Emails
      • Quick Links
      • Custom Page Colors
      • User Account Restrictions
      • Configuring Multiple Servers
      • Advanced Query Strings
    • Dispatching
      • Creating a Call
      • Self Dispatch
      • Timers
      • Command Line Interface (CLI)
    • Records Management
      • Record Lookups
      • Adding a Record
      • PDF Records
      • Scene Diagram Builder
    • Administration
      • System Logs
      • Remove User Account
      • Deleting or Transferring your CAD
    • Other Features
      • Configurable Hotkeys
      • Voice Commands
      • Volume and Language
  • Integration Capabilities
    • 🗃️Paid Integration Resources
      • Mobile Command Center
      • ATM Robbery
      • In-Vehicle Radar
      • Evidence Camera
      • Power Grid
      • Speed Cameras
      • Shot Spotter
    • 🛠️Integrated Vendors
    • 📺Twitch Bodycam, Bot, & Lighting Integration
    • Database Sync and Merge
      • Database Sync Credentials
      • QB Core Mapping Tutorial
      • Troubleshooting
    • Discord Bot Integration
    • Discord Rich Presence
    • Discord Webhooks
    • TeamSpeak 3 Integration
    • Stream Deck Integration
    • 🎮FiveM
      • FiveM Installation
        • Submodule Configuration
          • Submodule Troubleshooting
          • Submodule Configuration Updates
        • FiveM Submodules
          • Body Camera
          • Call Commands
          • Check API ID
          • Civilian Integration
          • Dispatch Notify
          • Emergency Response Simulator (ERS)
          • Framework Support (ESX/QBCore) and Auto Fines
          • FivePD
          • ForceReg
          • Kick
          • Locations
          • Live Map
          • Lookups
          • Postals
          • Smart Signs
          • Sonoran Radio (sonrad)
          • Station Alert
          • Tablet & Mini-CAD
          • TeamSpeak 3
          • Traffic Stop
          • Unit Status
          • VehReg
          • WraithV2
      • FiveM Development Documentation
        • Client Functions
        • Shared Functions
        • Server Functions
        • Server Events
        • HTTP Request Handling
      • Error Codes
    • 🎮Roblox ER:LC
  • Developer API Documentation
    • 📖API Integration
      • Getting Started
        • Retrieving Your Credentials
        • Integration API ID
        • Account Secret ID
      • Push Events
        • Event Restrictions
        • Record Events
          • Record Added
          • Record Edited
          • Record Removed
        • Unit Events
          • Unit Panic
          • Unit Login
          • Unit Logoff
          • Unit Status Update
          • Unit Group Name Change
          • Unit Group Add
          • Unit Group Remove
        • Dispatch Events
          • New Dispatch
          • Modified Dispatch
          • Closed Dispatch
          • Dispatch Note
          • Attach Unit
          • Detach Unit
          • Toggle Bodycam
        • Event 911
        • Remove 911
        • Sign Updated
        • Tone Played
        • Civilian
          • Character Selected
        • ERS
          • New Callout
        • Station Alert
          • New Station Alert
      • API Endpoints
        • API Restrictions
        • Emergency
          • Identifiers
            • Get Identifiers
            • Modify Identifier
            • Set Identifier
            • Unit Panic
            • Kick Unit
            • Unit Status
            • Get Active Units
            • Update Unit Location
          • Dispatch and Emergency Calls
            • Get Calls
            • New Dispatch
            • Attach Unit
            • Detach Unit
            • Update Call Postal
            • Add Call Note
            • Update Call Primary
            • Close Dispatch
            • New 911 Call
            • Remove 911
          • Custom Blips
            • Get Map Blips
            • Add Blip
            • Modify Blip
            • Remove Blip
          • Street Signs
            • Set Street Sign Config
            • Update Street Sign
          • ERS
            • Set Available Callouts
          • Station Alert
            • Set Stations
        • Civilian
          • Set Character
          • Get Characters
          • New Character
          • Edit Character
          • Remove Character
          • DB Sync: Get Character Links
          • DB Sync: Link Character
        • General
          • Get Servers
          • Set Servers
          • Get Version
          • Set Penal Codes
          • Set API IDs
          • Custom Records
            • API Options for Adding and Modifying Records
            • Get Record Templates
            • New Record
            • Edit Record
            • Remove Record
          • Lookup By Value
          • Lookup Name or Plate
          • Get Account
          • Get Accounts
          • Check API ID
          • Apply Permission Key
          • Modify Account Permissions
          • Kick or Ban User
          • Verify Secret
          • Auth Street Signs
          • Set Postal Config
          • Set Clock Time
          • Send Photo
          • Leave Community
          • Join Community
        • Local Endpoints
          • Smart Lighting
        • Internal
          • FiveM Download
      • API Examples
        • Emergency
          • LUA Examples
            • Dispatch and Emergency Calls
              • New 911 Call
              • Remove 911
              • Add Call Note
              • Set Call Postal
            • Custom Blips
              • Add Blip
              • Add Blips
              • Add Temp Blip
              • Get Map Blips
              • Remove Blip
              • Remove Blip With Subtype
            • General
              • Lookup Name or Plate
          • JavaScript Examples
            • Dispatch and Emergency Calls
              • New 911 Call
              • Remove 911
              • Add Call Note
              • Set Call Postal
            • Custom Blips
              • Add Blip
              • Add Blips
              • Add Temp Blip
              • Get Map Blips
              • Remove Blip
              • Remove Blip With Subtype
            • General
              • Lookup Name or Plate
      • Development Branch
    • 💵Developer Bounties
    • 🌎Translation Support
  • Pricing
    • Pricing FAQ
      • Military and First Responder Discount
      • Expert Installation
      • Accessing the Payment Center
      • Create and Manage a Subscription
      • Request Discord Role
    • View and Compare Plans
  • Roadmap
    • 📋Changelog
  • Other
    • AI QA
    • Contact Us
    • Policy
      • Rocket CAD Closure
      • Terms of Service
      • Privacy Policy
      • Refund and Purchase Policy
      • Discord Bot
    • Archive
      • Fire Siren
Powered by GitBook
On this page
  • isPluginLoaded
  • shallowcopy
  • stringsplit
  • findIndex
  • GetIdentifiers
  • PerformHttpRequestS
  • has_value
  • compareVersions

Was this helpful?

Edit on GitHub
  1. Integration Capabilities
  2. FiveM
  3. FiveM Development Documentation

Shared Functions

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

isPluginLoaded

Checks if a specific plugin is loaded by searching through the submodules table.

exports.sonorancad.isPluginLoaded(submoduleName)
Parameter
Type
Description

submoduleName

string

The name of the submodule to check for in the submodules table.

Type
Description

boolean

true if the specified submodule (pluginName) is found in the submodules table. false otherwise.

submodules = { "callcommands", "dispatchnotify", "civintegration" }

local isLoaded = isPluginLoaded("dispatchnotify")
print(isLoaded)  -- Output: true

local isLoaded2 = isPluginLoaded("vehreg")
print(isLoaded2)  -- Output: false

shallowcopy

Creates a shallow copy of a table or directly returns non-table values.

exports.sonorancad.shallowcopy(data)
Parameter
Type
Description

orig

any

The value or table to copy. Can be of any type: table, string, number, etc.

Type
Description

any

If orig is a table: Returns a new table with the same key-value pairs as orig. If orig is not a table (e.g., a number, string, boolean): Returns the value directly.

-- Example 1: Shallow copying a table
local original = { a = 1, b = 2, c = { 3, 4 } }
local copy = exports.sonorancad.shallowcopy(original)

print(copy.a)  -- Output: 1
print(copy.b)  -- Output: 2
print(copy.c)  -- Output: table: 0x... (same reference as original.c in shallow copy)

-- Example 2: Copying a non-table value
local value = 42
local valueCopy = exports.sonorancad.shallowcopy(value)
print(valueCopy)  -- Output: 42

stringsplit

Splits a string into substrings based on a specified delimiter.

exports.sonorancad.stringsplit(inputstr, sep)
Parameter
Type
Description

inputstr

string

The input string that will be split into substrings based on a specified delimiter (sep)

sep

string

(Optional) If not provided, the default is "%s", which matches any whitespace character

Type
Description

table

The table contains the substrings of inputstr split by the delimiter sep. The substrings are stored sequentially starting at index 1

local result = exports.sonorancad.stringsplit("Hello,World,Lua", ",")
-- result = { "Hello", "World", "Lua" }

local result2 = exports.sonorancad.stringsplit("One Two Three")
-- result2 = { "One", "Two", "Three" } (uses default separator: whitespace)

findIndex

Searches for a specific identifier in the LocationCache table and returns the index of the first matching entry.

exports.sonorancad.findIndex(identifier)
Parameter
Type
Description

identifier

any

The identifier to search for, compared against the apiId field of each entry in LocationCache.

Type
Description

number or nil

The index (i) of the first entry in LocationCache whose apiId matches identifier. nil if no matching entry is found

-- Example: Searching for an identifier in LocationCache
LocationCache = {
    { apiId = 101, name = "LocationA" },
    { apiId = 202, name = "LocationB" },
    { apiId = 303, name = "LocationC" },
}

local index = exports.sonorancad.findIndex(202)
print(index)  -- Output: 2

local notFound = exports.sonorancad.findIndex(404)
print(notFound)  -- Output: nil

GetIdentifiers

Extracts and organizes player identifiers into a key-value table format.

exports.sonorancad.GetIdentifiers(player)
Parameter
Type
Description

player

PlayerSource

The player source ID for whom the identifiers are being retrieved.

Type
Description

table

A key-value table where the keys are identifier types (e.g., steam, license, discord) and the values are the corresponding identifier strings.

local playerIdentifiers = exports.sonorancad.GetIdentifiers(1)

-- Output
-- playerIdentifiers = {
--     steam = "110000112345678",
--     license = "abcdef1234567890",
--     discord = "123456789012345678"
-- }

print(playerIdentifiers.steam)    -- Output: 110000112345678
print(playerIdentifiers.license)  -- Output: abcdef1234567890
print(playerIdentifiers.discord)  -- Output: 123456789012345678

PerformHttpRequestS

Simplifies making HTTP requests by providing a wrapper around exports["sonorancad"]:HandleHttpRequest.

exports.sonorancad.PerformHttpRequestS(url, cb, method, data, headers)
Parameter
Type
Description

url

string

The URL to which the HTTP request is sent.

cb

function

The callback function executed when the HTTP request completes.

method

string

The HTTP method to use (e.g., GET, POST, PUT, DELETE).

data

string

(Optional) The data to send with the HTTP request. Defaults to an empty string.

headers

table

(Optional) A table containing custom headers for the HTTP request. Defaults to include X-User-Agent.

Type
Description

none

This function does not directly return a value. Results are handled asynchronously via the cb callback function.

-- Example: Performing a POST request with custom data
local function callback(statusCode, response)
    print("Status:", statusCode)
    print("Response:", response)
end

exports.sonorancad.PerformHttpRequestS(
    "https://api.example.com/data", 
    callback, 
    "POST", 
    '{"key": "value"}', 
    { ["Content-Type"] = "application/json" }
)

has_value

Checks if a specific value exists in a table.

exports.sonorancad.has_value(tab, val)
Parameter
Type
Description

tab

table

The table to search for the value.

val

any

The value to search for within the table.

Type
Description

boolean

true if val is found in the table tab. false if val is not found, or if tab is nil.

-- Example 1: Checking if a value exists in a table
local myTable = { "apple", "banana", "cherry" }

local exists = exports.sonorancad.has_value(myTable, "banana")
print(exists)  -- Output: true

local notExists = exports.sonorancad.has_value(myTable, "grape")
print(notExists)  -- Output: false

-- Example 2: Handling a nil table
local nilTable = nil
local result = exports.sonorancad.has_value(nilTable, "value")
print(result)  -- Output: false (with debugLog: "nil passed to has_value, ignore")

compareVersions

Compares two semantic version strings.

exports.sonorancad.compareVersions(version1, version2)
Parameter
Type
Description

version1

string

The first version string (e.g., 1.0.0).

version2

string

The second version string (e.g., 1.0.1).

Type
Description

table

  • result: true if version1 is greater than version2, false otherwise.

  • parsedVersion1: The weighted numeric representation of version1.

  • parsedVersion2: The weighted numeric representation of version2.

  • version1: The original version1 string.

  • version2: The original version2 string.

-- Example: Comparing two versions
local comparison = exports.sonorancad.compareVersions("1.2.3", "1.1.10")

print(comparison.result)          -- Output: true
print(comparison.parsedVersion1)  -- Output: 10203
print(comparison.parsedVersion2)  -- Output: 10110

PreviousClient FunctionsNextServer Functions

Last updated 5 months ago

Was this helpful?

🎮