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.
-- Give $10,000 to the police department
local success = exports['m-BossMenu']:AddSocietyMoney('police', 10000)
if success then
print("Money added successfully!")
end
-- Deduct $5,000 from mechanic shop
local success = exports['m-BossMenu']:RemoveSocietyMoney('mechanic', 5000)
if success then
print("Money deducted successfully!")
end
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)
end
-- 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)
end
local success = exports['m-BossMenu']:CancelInvoice(42)
if success then
print("Invoice cancelled!")
end
local employees = exports['m-BossMenu']:GetEmployees('police')
print("Total employees: " .. #employees)
for _, emp in ipairs(employees) do
print(emp.name .. " - Grade: " .. emp.grade)
end
local success = exports['m-BossMenu']:HireEmployee(
'ABC12345', -- Citizen ID
'police', -- Job
1 -- Grade (Officer)
)
local success = exports['m-BossMenu']:FireEmployee('ABC12345')
if success then
print("Employee fired!")
end
-- Promote to grade 3
local success = exports['m-BossMenu']:SetEmployeeGrade('ABC12345', 3)
local stock = exports['m-BossMenu']:GetWarehouseStock('mechanic')
for _, item in ipairs(stock) do
print(item.item_name .. ": " .. item.quantity)
end
-- Add 50 repair kits to mechanic warehouse
local success = exports['m-BossMenu']:AddWarehouseItem('mechanic', 'repairkit', 50)
-- 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!")
end
-- 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)
end
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")
end
local success = exports['m-BossMenu']:ClockIn('ABC12345', 'police')
if success then
print("Clocked in successfully!")
end
local success = exports['m-BossMenu']:ClockOut('ABC12345')
if success then
print("Clocked out successfully!")
end
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))
-- 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
end
-- 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)
-- 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)
-- 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)