🔄Server Exports
What are Exports?
Exports are functions that can be called from other resources in your FiveM server. They allow different scripts to communicate and share functionality without modifying each other's code.
Think of exports as a public API - other resources can use these functions to interact with the Boss Menu system.
Money & Society Functions
GetSocietyBalance
GetSocietyBalanceGet the current balance of a company/job.
Parameters:
jobName(string) - Name of the job/company
Returns: number - Current balance
Example:
local balance = exports['m-BossMenu']:GetSocietyBalance('ambulance')
print("Hospital balance: $" .. balance)AddSocietyMoney
AddSocietyMoneyAdd money to a company account.
Parameters:
jobName(string) - Name of the job/companyamount(number) - Amount to add
Returns: boolean - Success status
Example:
-- Give $10,000 to the police department
local success = exports['m-BossMenu']:AddSocietyMoney('police', 10000)
if success then
print("Money added successfully!")
endRemoveSocietyMoney
RemoveSocietyMoneyRemove money from a company account.
Parameters:
jobName(string) - Name of the job/companyamount(number) - Amount to remove
Returns: boolean - Success status
Example:
-- Deduct $5,000 from mechanic shop
local success = exports['m-BossMenu']:RemoveSocietyMoney('mechanic', 5000)
if success then
print("Money deducted successfully!")
endInvoice Functions
CreateInvoice
CreateInvoiceCreate a new invoice from a company to a player.
Parameters:
senderId(number) - Source ID of the sendertargetId(number) - Source ID or identifier of the targetamount(number) - Invoice amountreason(string) - Reason/description for the invoicejobName(string, optional) - Job name (defaults to sender's job)
Returns: table - { success = boolean, message = string }
Example:
local result = exports['m-BossMenu']:CreateInvoice(
source, -- Sender (boss)
targetPlayerId, -- Target player
2500, -- Amount: $2,500
"Vehicle repair", -- Reason
"mechanic" -- Job name
)
if result.success then
print("Invoice created: " .. result.message)
else
print("Failed: " .. result.message)
endGetInvoices
GetInvoicesGet all invoices for a specific job.
Parameters:
jobName(string) - Name of the job/companystatus(string, optional) - Filter by status: "pending", "paid", "cancelled"
Returns: table - Array of invoice objects
Example:
-- Get all pending invoices for police
local invoices = exports['m-BossMenu']:GetInvoices('police', 'pending')
for _, invoice in ipairs(invoices) do
print("Invoice #" .. invoice.id .. ": $" .. invoice.amount)
endCancelInvoice
CancelInvoiceCancel an existing invoice.
Parameters:
invoiceId(number) - ID of the invoice to cancel
Returns: boolean - Success status
Example:
local success = exports['m-BossMenu']:CancelInvoice(42)
if success then
print("Invoice cancelled!")
endEmployee Management
GetEmployees
GetEmployeesGet all employees of a specific job.
Parameters:
jobName(string) - Name of the job/company
Returns: table - Array of employee objects
Example:
local employees = exports['m-BossMenu']:GetEmployees('police')
print("Total employees: " .. #employees)
for _, emp in ipairs(employees) do
print(emp.name .. " - Grade: " .. emp.grade)
endHireEmployee
HireEmployeeHire a player to a job.
Parameters:
citizenid(string) - Citizen ID of the playerjobName(string) - Job to hire them forgrade(number, optional) - Starting grade (default: 0)
Returns: boolean - Success status
Example:
local success = exports['m-BossMenu']:HireEmployee(
'ABC12345', -- Citizen ID
'police', -- Job
1 -- Grade (Officer)
)FireEmployee
FireEmployeeFire an employee (set them to unemployed).
Parameters:
citizenid(string) - Citizen ID of the employee
Returns: boolean - Success status
Example:
local success = exports['m-BossMenu']:FireEmployee('ABC12345')
if success then
print("Employee fired!")
endSetEmployeeGrade
SetEmployeeGradePromote or demote an employee.
Parameters:
citizenid(string) - Citizen ID of the employeegrade(number) - New grade/rank
Returns: boolean - Success status
Example:
-- Promote to grade 3
local success = exports['m-BossMenu']:SetEmployeeGrade('ABC12345', 3)Warehouse Functions
GetWarehouseStock
GetWarehouseStockGet all items in a company's warehouse.
Parameters:
jobName(string) - Name of the job/company
Returns: table - Array of stock items
Example:
local stock = exports['m-BossMenu']:GetWarehouseStock('mechanic')
for _, item in ipairs(stock) do
print(item.item_name .. ": " .. item.quantity)
endAddWarehouseItem
AddWarehouseItemAdd items to the warehouse.
Parameters:
jobName(string) - Name of the job/companyitemName(string) - Item identifierquantity(number) - Amount to add
Returns: boolean - Success status
Example:
-- Add 50 repair kits to mechanic warehouse
local success = exports['m-BossMenu']:AddWarehouseItem('mechanic', 'repairkit', 50)RemoveWarehouseItem
RemoveWarehouseItemRemove items from the warehouse.
Parameters:
jobName(string) - Name of the job/companyitemName(string) - Item identifierquantity(number) - Amount to remove
Returns: boolean - Success status
Example:
-- Remove 10 bandages from hospital warehouse
local success = exports['m-BossMenu']:RemoveWarehouseItem('ambulance', 'bandage', 10)
if not success then
print("Not enough items in warehouse!")
endTransaction Functions
GetTransactions
GetTransactionsGet transaction history for a company.
Parameters:
jobName(string) - Name of the job/companylimit(number, optional) - Maximum number of transactions to return
Returns: table - Array of transaction objects
Example:
-- Get last 10 transactions
local transactions = exports['m-BossMenu']:GetTransactions('police', 10)
for _, tx in ipairs(transactions) do
print(tx.date .. " - " .. tx.type .. ": $" .. tx.amount)
endAddTransaction
AddTransactionManually add a transaction record.
Parameters:
jobName(string) - Name of the job/companytype(string) - Transaction type: "deposit", "withdraw", "payment", etc.amount(number) - Transaction amountdescription(string) - Transaction descriptionclientName(string, optional) - Client name (default: "System")
Returns: boolean - Success status
Example:
exports['m-BossMenu']:AddTransaction(
'police',
'fine',
500,
'Speeding ticket',
'John Doe'
)Duty Clock Functions
GetDutyStatus
GetDutyStatusCheck if a player is currently on duty.
Parameters:
citizenid(string) - Citizen ID of the player
Returns: table - { onDuty = boolean, data = table or nil }
Example:
local status = exports['m-BossMenu']:GetDutyStatus('ABC12345')
if status.onDuty then
print("Player is on duty since: " .. status.data.clock_in)
else
print("Player is not on duty")
endClockIn
ClockInClock in a player to start their duty.
Parameters:
citizenid(string) - Citizen ID of the playerjobName(string) - Job name
Returns: boolean - Success status
Example:
local success = exports['m-BossMenu']:ClockIn('ABC12345', 'police')
if success then
print("Clocked in successfully!")
endClockOut
ClockOutClock out a player to end their duty.
Parameters:
citizenid(string) - Citizen ID of the player
Returns: boolean - Success status
Example:
local success = exports['m-BossMenu']:ClockOut('ABC12345')
if success then
print("Clocked out successfully!")
endGetDutyHours
GetDutyHoursGet total duty hours for a player.
Parameters:
citizenid(string) - Citizen ID of the playerperiod(string, optional) - Time period: "today", "week", "month", or nil (all time)
Returns: number - Total hours worked
Example:
local todayHours = exports['m-BossMenu']:GetDutyHours('ABC12345', 'today')
local weekHours = exports['m-BossMenu']:GetDutyHours('ABC12345', 'week')
local allTimeHours = exports['m-BossMenu']:GetDutyHours('ABC12345')
print(string.format("Today: %dh | Week: %dh | Total: %dh", todayHours, weekHours, allTimeHours))Practical Use Cases
Example 1: Custom Job Payment System
-- Give salary to all online employees
local employees = exports['m-BossMenu']:GetEmployees('police')
for _, emp in ipairs(employees) do
local Player = QBCore.Functions.GetPlayerByCitizenId(emp.citizenid)
if Player then
Player.Functions.AddMoney('bank', emp.salary)
-- Log transaction
exports['m-BossMenu']:AddTransaction(
'police',
'salary',
emp.salary,
'Monthly salary payment',
emp.name
)
end
endExample 2: Auto-Fine System
-- When player gets a speeding ticket
RegisterNetEvent('police:speedingTicket', function(targetId, amount)
local result = exports['m-BossMenu']:CreateInvoice(
source,
targetId,
amount,
'Speeding ticket - ' .. amount .. ' km/h over limit',
'police'
)
if result.success then
TriggerClientEvent('QBCore:Notify', source, 'Ticket issued!', 'success')
end
end)Example 3: Warehouse Integration
-- Custom crafting system that uses warehouse stock
RegisterNetEvent('mechanic:craftItem', function()
local src = source
-- Check if warehouse has materials
local stock = exports['m-BossMenu']:GetWarehouseStock('mechanic')
local hasSteel = false
for _, item in ipairs(stock) do
if item.item_name == 'steel' and item.quantity >= 10 then
hasSteel = true
break
end
end
if hasSteel then
-- Remove materials from warehouse
exports['m-BossMenu']:RemoveWarehouseItem('mechanic', 'steel', 10)
-- Give crafted item to player
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.AddItem('repairkit', 1)
end
end)Example 4: Company Balance Check
-- Before allowing expensive purchases
RegisterNetEvent('shop:buyExpensiveItem', function(itemPrice)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local job = Player.PlayerData.job.name
local balance = exports['m-BossMenu']:GetSocietyBalance(job)
if balance >= itemPrice then
exports['m-BossMenu']:RemoveSocietyMoney(job, itemPrice)
Player.Functions.AddItem('expensive_item', 1)
else
TriggerClientEvent('QBCore:Notify', src, 'Company has insufficient funds!', 'error')
end
end)Important Notes
Server-Side Only: All exports are server-side only for security
Error Handling: Always check return values before proceeding
Citizen ID Format: Use the correct identifier format for your framework (QBCore vs ESX)
Database: Ensure all database tables are properly installed
Last updated