Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sure-developer.com/llms.txt

Use this file to discover all available pages before exploring further.

API Reference

This page is a compact reference for sure_lib version 2.2.1.

Module availability

ModuleClientServer
validatorYesYes
listenerYesYes
trackYesYes
configYesYes
playerYesNo
spawnYesNo
luiYesNo
cooldownYesYes
dbNoYes
esxNoYes

Loader

sure.getModule(name)
function
required
Loads a module by name from the current runtime side.
module
table | nil
Returns a module table or nil when unavailable.

Validator

Builders

object(fields), array(itemRule), string(), number(), integer(), boolean(), and callback() create rules.
required(message?), message(message), min(value), max(value), between(min, max), oneOf(values), and parse(data).
parse(data) returns true when data is valid. It raises Validation Error: ... when data is invalid.

Listener

listener:on(eventName, callback)
function
Registers a local event.
listener:onNet(eventName, callback)
function
Registers a network event.
listenerMeta:expect(...validators)
function
Validates positional event parameters before the callback runs.

Track

track.state(stateName, initialValue)
function
Returns a getter and setter pair. The setter accepts a value or a functional update.
track.effect(callback, dependencies)
function
Runs callback whenever one of the dependency getters changes.

Player

data, inventory, accounts, and loadout read current ESX player data. Inventory and account lists support lookup by name. Loadout supports normalized weapon lookup.

Config

config:load(filePath, schema?)
function
Loads and caches a Lua config file. When schema is supplied, the cached or freshly loaded value is validated before it is returned.
config:reload(filePath, schema?)
function
Reloads a Lua config file, replaces the cached value, and optionally validates it.

Spawn

MethodDescription
spawn:ped(model, coords, heading, opts?)Spawns a client ped or registers a proximity stream entry.
spawn:object(model, coords, opts?)Spawns a client object or registers a proximity stream entry.
spawn:scope()Creates an isolated cleanup scope with scoped ped, object, and deleteAll methods.
spawn:deleteAll()Deletes tracked spawned entities and removes stream points.

LUI

lui.page(pageId, pageBuilder, props?), lui.render(pageId), lui.open(pageId, focusOptions?), and lui.close(pageId) manage client NUI pages.

Cooldown

define(key, definition) registers a cooldown definition with initialDurationMs, durationMs, optional pauseTimerOn, and optional resetAfterZeroTicks.

DB

MethodDescription
db:schema(schemaName, definition?)Creates a model object. definition.tableName overrides the SQL table name.
model:findMany({ where? })Runs SELECT * with optional equality filters.
model:findFirst({ where? })Runs SELECT * ... LIMIT 1 and returns one row or nil.
model:create({ data })Inserts sorted data fields and returns the insert id from oxmysql.
model:update({ data, where })Updates rows. A non-empty where clause is required.
model:delete({ where })Deletes rows. A non-empty where clause is required.
model:raw(sql, params?)Runs a raw query_async call.
Console command: sure_lib:db push <schemaName> creates a table from db/<schemaName>.lua; sure_lib:db pull <targetTable> writes a schema file from the current database table.

ESX

MethodDescription
giveItem(playerSource, itemName, amount)Give one inventory item.
giveItems(playerSource, items)Give multiple inventory items.
removeItem(playerSource, itemName, amount)Remove one inventory item.
removeItems(playerSource, items)Remove multiple inventory items.
addMoney(playerSource, accountName, amount)Add account money.
addMoneyEntries(playerSource, accounts)Add multiple account entries.
removeMoney(playerSource, accountName, amount)Remove account money.
removeMoneyEntries(playerSource, accounts)Remove multiple account entries.
transactions(playerSource, entries)Apply low-level action batches.
All ESX helpers return a boolean. false means invalid input, missing player, malformed transaction data, or an unknown transaction action.