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.

ESX

The esx module exists on the server only. It wraps common ESX item and account operations and returns false when the player source or payload is invalid.
local esx = sure.getModule('esx')

Give and remove items

local ok = esx.giveItem(source, 'bread', 2)

if not ok then
  print(('Could not give item to source %s'):format(source))
end

Add and remove account money

esx.addMoney(source, 'bank', 500)
esx.removeMoney(source, 'money', 100)

esx.addMoneyEntries(source, {
  { accountName = 'bank', amount = 500 },
  { accountName = 'money', amount = 100 }
})

Transactions

transactions(playerSource, entries) is the lower-level primitive used by the helper methods. Each transaction is { action, argsList }.
ActionESX method
1xPlayer.addInventoryItem
-1xPlayer.removeInventoryItem
2xPlayer.addAccountMoney
-2xPlayer.removeAccountMoney
esx.transactions(source, {
  { 1, { { 'bread', 2 }, { 'water', 1 } } },
  { 2, { { 'bank', 500 } } }
})
The module validates payload shape before applying transactions. It returns false for malformed entries, missing players, or unknown transaction actions.

API

giveItem(playerSource, itemName, amount)
function
required
Gives one inventory item to a player.
giveItems(playerSource, items)
function
Gives multiple inventory items. Each entry must include itemName and numeric amount.
removeItem(playerSource, itemName, amount)
function
required
Removes one inventory item from a player.
removeItems(playerSource, items)
function
Removes multiple inventory items.
addMoney(playerSource, accountName, amount)
function
required
Adds money to one ESX account.
removeMoney(playerSource, accountName, amount)
function
required
Removes money from one ESX account.
ok
boolean
All ESX helper methods return true when the operation is accepted and false when validation or player lookup fails.