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.


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.


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


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.


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.


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.


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.


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

Last updated