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 version2.2.1.
Module availability
| Module | Client | Server |
|---|---|---|
validator | Yes | Yes |
listener | Yes | Yes |
track | Yes | Yes |
config | Yes | Yes |
player | Yes | No |
spawn | Yes | No |
lui | Yes | No |
cooldown | Yes | Yes |
db | No | Yes |
esx | No | Yes |
Loader
Loads a module by name from the current runtime side.
Returns a module table or
nil when unavailable.Validator
Builders
Builders
object(fields), array(itemRule), string(), number(), integer(), boolean(), and callback() create rules.Rule methods
Rule methods
required(message?), message(message), min(value), max(value), between(min, max), oneOf(values), and parse(data).Return and errors
Return and errors
parse(data) returns true when data is valid. It raises Validation Error: ... when data is invalid.Listener
Registers a local event.
Registers a network event.
Validates positional event parameters before the callback runs.
Track
Returns a getter and setter pair. The setter accepts a value or a functional update.
Runs
callback whenever one of the dependency getters changes.Player
- Data
- State
- Lifecycle
data, inventory, accounts, and loadout read current ESX player data. Inventory and account lists support lookup by name. Loadout supports normalized weapon lookup.Config
Loads and caches a Lua config file. When
schema is supplied, the cached or freshly loaded value is validated before it is returned.Reloads a Lua config file, replaces the cached value, and optionally validates it.
Spawn
| Method | Description |
|---|---|
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
- Page
- Builder nodes
- Declarative nodes
lui.page(pageId, pageBuilder, props?), lui.render(pageId), lui.open(pageId, focusOptions?), and lui.close(pageId) manage client NUI pages.Cooldown
- Server
- Client
define(key, definition) registers a cooldown definition with initialDurationMs, durationMs, optional pauseTimerOn, and optional resetAfterZeroTicks.DB
| Method | Description |
|---|---|
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. |
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
| Method | Description |
|---|---|
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.