Custom · origen_vendings
The custom/ folder contains the bridge layer for origen_vendings. These files are excluded from escrow and are the only files you should edit to integrate the resource with your stack.
custom/
├── client.lua ← TextUI and notification bridges
└── server.lua ← Framework, permissions, economy, and inventory bridgesOnly edit files inside custom/. All other resource files are escrow-protected and should not be modified.
custom/client.lua
Defines two bridge objects used across the entire client side: HelpText and Notify.
HelpText
Controls the TextUI prompt shown when the player is near a vending machine.
HelpText.GetResourceName() → string
Returns the name of the resource providing the TextUI.
HelpText.GetResourceName = function()
return 'ox_lib'
endHelpText.ShowHelpText(message, position?)
Shows the TextUI on screen. Called automatically when the player enters a machine's interaction radius.
| Parameter | Type | Description |
|---|---|---|
message | string | Text to display |
position | string? | Position on screen. Defaults to 'left-center' |
-- Default implementation (ox_lib)
HelpText.ShowHelpText = function(message, position)
exports.ox_lib:showTextUI(message, {
position = position or 'left-center',
icon = 'shopping-cart',
})
endHelpText.HideHelpText()
Hides the active TextUI. Called automatically when the player leaves the interaction radius.
-- Default implementation (ox_lib)
HelpText.HideHelpText = function()
exports.ox_lib:hideTextUI()
endNotify
Controls in-game toast notifications sent to the player (purchase success, errors, etc.).
Notify.GetResourceName() → string
Returns the name of the resource providing notifications.
Notify.GetResourceName = function()
return 'ox_lib'
endNotify.SendNotify(message, type?, time?)
Simple notification without a title.
| Parameter | Type | Description |
|---|---|---|
message | string | Text to display |
type | string? | 'success' | 'error' | 'info' | 'warning'. Defaults to 'info' |
time | number? | Duration in milliseconds. Defaults to 3000 |
-- Default implementation (ox_lib)
Notify.SendNotify = function(message, _type, time)
exports.ox_lib:notify({
description = message,
type = _type or 'info',
duration = time or 3000,
position = Config.NotificationPosition or 'top-right',
})
endNotify.SendNotification(title, message, type?, time?)
Notification with a title.
| Parameter | Type | Description |
|---|---|---|
title | string | Notification title. Defaults to 'Vending' |
message | string | Notification body |
type | string? | 'success' | 'error' | 'info' | 'warning'. Defaults to 'info' |
time | number? | Duration in milliseconds. Defaults to 3000 |
-- Default implementation (ox_lib)
Notify.SendNotification = function(title, message, _type, time)
exports.ox_lib:notify({
title = title or 'Vending',
description = message,
type = _type or 'info',
duration = time or 3000,
position = Config.NotificationPosition or 'top-right',
})
endcustom/server.lua
Defines the Custom bridge object used across the entire server side. Handles framework integration, permissions, economy, and inventory.
The inventory provider is cached on first use. If you change Config.Inventory at runtime, restart the resource to re-detect.
Custom.getIdentifier(source) → string | nil
Returns the player's unique identifier (citizenid for QBCore/QBX, license for ESX).
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
Custom.getStaffLevel(source) → 'full' | false
Checks if the player has admin access to the vending panel. Returns 'full' if they do, false otherwise.
Checks (in order):
- Framework admin flag (
qb-core/qbx_core) - Any ACE group defined in
Config.GroupPermissions - The generic
commandACE ace
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
-- Usage example inside a callback
local level = Custom.getStaffLevel(source)
if not level then return end -- not an adminCustom.getMoney(source, account?) → number | nil
Returns the player's balance in the given account.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
account | string? | 'cash' (default) or 'bank' |
Custom.removeMoney(source, amount, account?, reason?) → boolean, string?
Deducts money from the player. Returns true on success, or false plus an error string on failure.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
amount | number | Amount to deduct (must be > 0) |
account | string? | 'cash' (default) or 'bank' |
reason | string? | Transaction label. Defaults to 'origen_vendings' |
Possible error strings:
| Error | Cause |
|---|---|
'invalid_amount' | Amount is nil, 0, or negative |
'player_not_found' | Framework could not resolve the player |
'insufficient_funds' | Balance is lower than the requested amount |
'framework_denied' | The framework's RemoveMoney returned false |
'framework_not_supported' | Active framework is not handled |
local ok, err = Custom.removeMoney(source, 50, 'cash')
if not ok then
print('Payment failed:', err)
endCustom.giveItem(source, itemName, amount, metadata?) → boolean
Gives an item to the player using the active inventory. Checks carry capacity when supported.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
itemName | string | Internal item name |
amount | number | Quantity to give |
metadata | table? | Optional item metadata |
Custom.itemExists(itemName) → boolean
Returns true if the item is registered in the active inventory.
| Parameter | Type | Description |
|---|---|---|
itemName | string | Internal item name |
Custom.getInventoryName() → string
Returns the name of the currently active inventory resource (e.g. 'ox_inventory', 'qb-inventory'). Useful for logs and debugging.
Custom.getAllInventoryItems() → table[]
Returns all items registered in the active inventory, sorted alphabetically by label. Used by the admin panel to populate the item selector.
Each entry in the returned table:
| Field | Type | Description |
|---|---|---|
name | string | Internal item name |
label | string | Display name |
weight | number | Item weight |
stack | boolean | Whether the item is stackable |
image | string | Resolved NUI image URL, or '' if not found |