OrigenNetwork
Docs

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.

text
custom/
├── client.lua   ← TextUI and notification bridges
└── server.lua   ← Framework, permissions, economy, and inventory bridges

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

lua
HelpText.GetResourceName = function()
    return 'ox_lib'
end

HelpText.ShowHelpText(message, position?)

Shows the TextUI on screen. Called automatically when the player enters a machine's interaction radius.

ParameterTypeDescription
messagestringText to display
positionstring?Position on screen. Defaults to 'left-center'
lua
-- Default implementation (ox_lib)
HelpText.ShowHelpText = function(message, position)
    exports.ox_lib:showTextUI(message, {
        position = position or 'left-center',
        icon     = 'shopping-cart',
    })
end

HelpText.HideHelpText()

Hides the active TextUI. Called automatically when the player leaves the interaction radius.

lua
-- Default implementation (ox_lib)
HelpText.HideHelpText = function()
    exports.ox_lib:hideTextUI()
end

Notify

Controls in-game toast notifications sent to the player (purchase success, errors, etc.).


Notify.GetResourceName()string

Returns the name of the resource providing notifications.

lua
Notify.GetResourceName = function()
    return 'ox_lib'
end

Notify.SendNotify(message, type?, time?)

Simple notification without a title.

ParameterTypeDescription
messagestringText to display
typestring?'success' | 'error' | 'info' | 'warning'. Defaults to 'info'
timenumber?Duration in milliseconds. Defaults to 3000
lua
-- 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',
    })
end

Notify.SendNotification(title, message, type?, time?)

Notification with a title.

ParameterTypeDescription
titlestringNotification title. Defaults to 'Vending'
messagestringNotification body
typestring?'success' | 'error' | 'info' | 'warning'. Defaults to 'info'
timenumber?Duration in milliseconds. Defaults to 3000
lua
-- 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',
    })
end

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

ParameterTypeDescription
sourcenumberPlayer 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):

  1. Framework admin flag (qb-core / qbx_core)
  2. Any ACE group defined in Config.GroupPermissions
  3. The generic command ACE ace
ParameterTypeDescription
sourcenumberPlayer server ID
lua
-- Usage example inside a callback
local level = Custom.getStaffLevel(source)
if not level then return end -- not an admin

Custom.getMoney(source, account?)number | nil

Returns the player's balance in the given account.

ParameterTypeDescription
sourcenumberPlayer server ID
accountstring?'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.

ParameterTypeDescription
sourcenumberPlayer server ID
amountnumberAmount to deduct (must be > 0)
accountstring?'cash' (default) or 'bank'
reasonstring?Transaction label. Defaults to 'origen_vendings'

Possible error strings:

ErrorCause
'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
lua
local ok, err = Custom.removeMoney(source, 50, 'cash')
if not ok then
    print('Payment failed:', err)
end

Custom.giveItem(source, itemName, amount, metadata?)boolean

Gives an item to the player using the active inventory. Checks carry capacity when supported.

ParameterTypeDescription
sourcenumberPlayer server ID
itemNamestringInternal item name
amountnumberQuantity to give
metadatatable?Optional item metadata

Custom.itemExists(itemName)boolean

Returns true if the item is registered in the active inventory.

ParameterTypeDescription
itemNamestringInternal 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:

FieldTypeDescription
namestringInternal item name
labelstringDisplay name
weightnumberItem weight
stackbooleanWhether the item is stackable
imagestringResolved NUI image URL, or '' if not found