Exports & API
Server and client exports for integrating with Oxide Vending.
Server Exports
Business Management (admin.lua)
GetAllBusinesses
Returns all businesses from cache.
local businesses = exports['oxide-vending']:GetAllBusinesses()
-- Returns: table { [business_id] = business_data, ... }
GetBusinessById
Get a specific business by ID.
local business = exports['oxide-vending']:GetBusinessById(businessId)
-- Returns: business_data or nil
GetBusinessByOwner
Get a business by owner's citizen ID.
local business = exports['oxide-vending']:GetBusinessByOwner(citizenid)
-- Returns: business_data or nil
GetBusinessStats
Get statistics for a business.
local stats = exports['oxide-vending']:GetBusinessStats(businessId)
-- Returns: {
-- machine_count = number,
-- total_revenue = number,
-- uncollected_balance = number,
-- total_items_sold = number,
-- }
Machine Management (admin.lua)
GetAllMachines
Returns all machines from cache.
local machines = exports['oxide-vending']:GetAllMachines()
-- Returns: table { [machine_id] = machine_data, ... }
GetMachineById
Get a specific machine by ID.
local machine = exports['oxide-vending']:GetMachineById(machineId)
-- Returns: machine_data or nil
GetMachinesByBusiness
Get all machines for a business.
local machines = exports['oxide-vending']:GetMachinesByBusiness(businessId)
-- Returns: table { machine_data, ... }
GetMachineStats
Get statistics for a machine.
local stats = exports['oxide-vending']:GetMachineStats(machineId)
-- Returns: machine stats data or nil
GetMachineStock
Get current stock for a machine.
local stock = exports['oxide-vending']:GetMachineStock(machineId)
-- Returns: table { [slot] = { item_name, quantity, price }, ... }
Employee Management (admin.lua)
GetEmployeesByBusiness
Get all employees for a business.
local employees = exports['oxide-vending']:GetEmployeesByBusiness(businessId)
-- Returns: table { [citizenid] = employee_data, ... }
Transaction History (admin.lua)
GetTransactionHistory
Get paginated transaction history.
local transactions = exports['oxide-vending']:GetTransactionHistory(businessId, limit, offset)
-- limit: max 500, default 50
-- offset: default 0
-- Returns: table of transaction records
Admin Operations (admin.lua)
AdminDeleteBusiness
Force delete a business (bypasses all checks).
local success, message = exports['oxide-vending']:AdminDeleteBusiness(businessId, adminIdentifier)
-- adminIdentifier: optional, for logging
-- Returns: boolean, string
AdminDeleteMachine
Force delete a machine (bypasses all checks, no refund).
local success, message = exports['oxide-vending']:AdminDeleteMachine(machineId, adminIdentifier)
-- adminIdentifier: optional, for logging
-- Returns: boolean, string
Progression System (progression.lua)
GetBusinessLevel
Get the current level of a business.
local level = exports['oxide-vending']:GetBusinessLevel(businessId)
-- Returns: number (1-10)
GetBusinessProgression
Get full progression data for a business.
local prog = exports['oxide-vending']:GetBusinessProgression(businessId)
-- Returns: {
-- id = number,
-- business_id = string,
-- level = number,
-- current_xp = number,
-- total_xp_earned = number,
-- lifetime_revenue = number,
-- last_daily_bonus = string (date),
-- daily_bonus_streak = number,
-- }
AddXP
Grant XP to a business.
local success, leveledUp = exports['oxide-vending']:AddXP(businessId, amount, source, notifySource)
-- amount: XP to grant
-- source: string describing the XP source
-- notifySource: player source to notify (optional)
-- Returns: boolean (success), boolean (leveled up)
AddRevenue
Track revenue for progression (does not add money, just tracks).
local leveledUp = exports['oxide-vending']:AddRevenue(businessId, amount)
-- Returns: boolean (leveled up)
GetMaxMachines
Get the maximum number of machines allowed for a business.
local max = exports['oxide-vending']:GetMaxMachines(businessId)
-- Returns: number
GetMaxEmployees
Get the maximum number of employees allowed for a business.
local max = exports['oxide-vending']:GetMaxEmployees(businessId)
-- Returns: number
IsMachineTypeUnlocked
Check if a business can purchase a specific machine type.
local unlocked = exports['oxide-vending']:IsMachineTypeUnlocked(businessId, machineType)
-- machineType: 'drinks', 'snacks', 'general', 'electronics'
-- Returns: boolean
IsWarehouseUnlocked
Check if a business can purchase a warehouse.
local unlocked = exports['oxide-vending']:IsWarehouseUnlocked(businessId)
-- Returns: boolean
GetPricingRange
Get the allowed pricing range for an item based on business level.
local minPrice, maxPrice = exports['oxide-vending']:GetPricingRange(businessId, itemName)
-- Returns: number, number
GetWholesaleDiscount
Get the wholesale discount percentage for a business.
local discount = exports['oxide-vending']:GetWholesaleDiscount(businessId)
-- Returns: number (0.0 to 0.20)
GetNPCRevenueBoost
Get the NPC revenue boost percentage for a business.
local boost = exports['oxide-vending']:GetNPCRevenueBoost(businessId)
-- Returns: number (0.0 to 0.35)
CreateProgressionRecord
Create a progression record for a business.
local success = exports['oxide-vending']:CreateProgressionRecord(businessId)
-- Returns: boolean
ClaimDailyBonus
Claim the daily XP bonus for a business.
local success, xpOrError, streak = exports['oxide-vending']:ClaimDailyBonus(source, businessId)
-- source: player server ID
-- Returns: boolean, number|string, number
-- On success: true, xp_amount, streak_days
-- On failure: false, error_message
NPC Sales (npc_sales.lua)
GetNPCSalesStats
Get NPC sales simulation statistics.
local stats = exports['oxide-vending']:GetNPCSalesStats()
-- Returns: {
-- totalSales = number,
-- totalRevenue = number,
-- simulationActive = boolean,
-- lastTickTime = number,
-- tickInterval = number,
-- }
Warehouse System (warehouse.lua)
GetBusinessInventory
Get all warehouse inventory for a business.
local inventory = exports['oxide-vending']:GetBusinessInventory(businessId)
-- Returns: table { [item_name] = quantity, ... }
GetBusinessInventoryItem
Get quantity of a specific item in warehouse.
local quantity = exports['oxide-vending']:GetBusinessInventoryItem(businessId, itemName)
-- Returns: number (0 if not found)
GetBusinessInventoryList
Get warehouse inventory as a formatted list.
local items = exports['oxide-vending']:GetBusinessInventoryList(businessId)
-- Returns: table { { item_name, label, quantity, image }, ... }
AddToWarehouse
Add items to a business's warehouse inventory.
local success, error = exports['oxide-vending']:AddToWarehouse(businessId, itemName, quantity)
-- Returns: boolean, string|nil
RemoveFromWarehouse
Remove items from a business's warehouse inventory.
local success, error = exports['oxide-vending']:RemoveFromWarehouse(businessId, itemName, quantity)
-- Returns: boolean, string|nil
HasWarehouse
Check if a business owns a warehouse.
local hasWarehouse = exports['oxide-vending']:HasWarehouse(businessId)
-- Returns: boolean
GetWarehouseByBusiness
Get warehouse data for a business.
local warehouse = exports['oxide-vending']:GetWarehouseByBusiness(businessId)
-- Returns: { business_id, access_code, bucket_id } or nil
GetTotalWarehouseItems
Get total item count in a business's warehouse.
local totalItems = exports['oxide-vending']:GetTotalWarehouseItems(businessId)
-- Returns: number
GetWarehouseByBucket
Get warehouse data by routing bucket ID.
local warehouse, businessId = exports['oxide-vending']:GetWarehouseByBucket(bucketId)
-- Returns: warehouse_data or nil, business_id
PurchaseWarehouse
Purchase a warehouse for a business.
local success, error = exports['oxide-vending']:PurchaseWarehouse(source, businessId)
-- source: player server ID
-- Returns: boolean, string|nil
UpdateWarehouseCode
Update a warehouse's access code.
local success, error = exports['oxide-vending']:UpdateWarehouseCode(businessId, newCode)
-- Returns: boolean, string|nil
ValidateAccessCode
Validate a warehouse access code and retrieve associated data.
local valid, businessId, warehouse = exports['oxide-vending']:ValidateAccessCode(code)
-- Returns: boolean, string|nil, table|nil
Client Exports
Dashboard (nui.lua)
OpenDashboard
Open the NUI dashboard.
exports['oxide-vending']:OpenDashboard()
CloseDashboard
Close the NUI dashboard.
exports['oxide-vending']:CloseDashboard()
OpenContract
Open the business registration contract NUI.
exports['oxide-vending']:OpenContract()
CloseContract
Close the business registration contract NUI.
exports['oxide-vending']:CloseContract()
Placement (placement.lua)
StartPlacement
Start machine placement mode.
exports['oxide-vending']:StartPlacement(machineType, modelName)
CancelPlacement
Cancel active placement mode.
exports['oxide-vending']:CancelPlacement()
IsInPlacementMode
Check if the player is currently placing a machine.
local placing = exports['oxide-vending']:IsInPlacementMode()
-- Returns: boolean
GetPlacementState
Get the current placement state data.
local state = exports['oxide-vending']:GetPlacementState()
-- Returns: placement state table
Warehouse (warehouse.lua)
OpenChangeCodeMenu
Open the warehouse access code change menu.
exports['oxide-vending']:OpenChangeCodeMenu()
Usage Examples
Check if Player Can Place More Machines
-- Server-side
local businessId = 'vend-123456'
local currentMachines = #exports['oxide-vending']:GetMachinesByBusiness(businessId)
local maxMachines = exports['oxide-vending']:GetMaxMachines(businessId)
if currentMachines >= maxMachines then
-- Cannot place more machines
return false
end
Grant Bonus XP from External Script
-- Server-side
local businessId = 'vend-123456'
local success, leveledUp = exports['oxide-vending']:AddXP(businessId, 500, 'Event Bonus', source)
if leveledUp then
TriggerClientEvent('QBCore:Notify', source, 'Your business leveled up!', 'success')
end
Check Machine Type Availability
-- Server-side
local businessId = 'vend-123456'
if not exports['oxide-vending']:IsMachineTypeUnlocked(businessId, 'electronics') then
-- Business hasn't unlocked electronics yet
local level = exports['oxide-vending']:GetBusinessLevel(businessId)
print('Business is level ' .. level .. ', electronics unlock at level 6')
end
Open Dashboard from Another Resource
-- Client-side
RegisterCommand('mybusiness', function()
exports['oxide-vending']:OpenDashboard()
end)
Monitor NPC Sales
-- Server-side
CreateThread(function()
while true do
Wait(60000) -- Check every minute
local stats = exports['oxide-vending']:GetNPCSalesStats()
print(string.format(
'[Monitor] NPC Sales: %d total, $%d revenue',
stats.totalSales,
stats.totalRevenue
))
end
end)