πŸ”„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

Get 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

Add money to a company account.

Parameters:

  • jobName (string) - Name of the job/company

  • amount (number) - Amount to add

Returns: boolean - Success status

Example:


RemoveSocietyMoney

Remove money from a company account.

Parameters:

  • jobName (string) - Name of the job/company

  • amount (number) - Amount to remove

Returns: boolean - Success status

Example:


Invoice Functions

CreateInvoice

Create a new invoice from a company to a player.

Parameters:

  • senderId (number) - Source ID of the sender

  • targetId (number) - Source ID or identifier of the target

  • amount (number) - Invoice amount

  • reason (string) - Reason/description for the invoice

  • jobName (string, optional) - Job name (defaults to sender's job)

Returns: table - { success = boolean, message = string }

Example:


GetInvoices

Get all invoices for a specific job.

Parameters:

  • jobName (string) - Name of the job/company

  • status (string, optional) - Filter by status: "pending", "paid", "cancelled"

Returns: table - Array of invoice objects

Example:


CancelInvoice

Cancel an existing invoice.

Parameters:

  • invoiceId (number) - ID of the invoice to cancel

Returns: boolean - Success status

Example:


Employee Management

GetEmployees

Get all employees of a specific job.

Parameters:

  • jobName (string) - Name of the job/company

Returns: table - Array of employee objects

Example:


HireEmployee

Hire a player to a job.

Parameters:

  • citizenid (string) - Citizen ID of the player

  • jobName (string) - Job to hire them for

  • grade (number, optional) - Starting grade (default: 0)

Returns: boolean - Success status

Example:


FireEmployee

Fire an employee (set them to unemployed).

Parameters:

  • citizenid (string) - Citizen ID of the employee

Returns: boolean - Success status

Example:


SetEmployeeGrade

Promote or demote an employee.

Parameters:

  • citizenid (string) - Citizen ID of the employee

  • grade (number) - New grade/rank

Returns: boolean - Success status

Example:


Warehouse Functions

GetWarehouseStock

Get all items in a company's warehouse.

Parameters:

  • jobName (string) - Name of the job/company

Returns: table - Array of stock items

Example:


AddWarehouseItem

Add items to the warehouse.

Parameters:

  • jobName (string) - Name of the job/company

  • itemName (string) - Item identifier

  • quantity (number) - Amount to add

Returns: boolean - Success status

Example:


RemoveWarehouseItem

Remove items from the warehouse.

Parameters:

  • jobName (string) - Name of the job/company

  • itemName (string) - Item identifier

  • quantity (number) - Amount to remove

Returns: boolean - Success status

Example:


Transaction Functions

GetTransactions

Get transaction history for a company.

Parameters:

  • jobName (string) - Name of the job/company

  • limit (number, optional) - Maximum number of transactions to return

Returns: table - Array of transaction objects

Example:


AddTransaction

Manually add a transaction record.

Parameters:

  • jobName (string) - Name of the job/company

  • type (string) - Transaction type: "deposit", "withdraw", "payment", etc.

  • amount (number) - Transaction amount

  • description (string) - Transaction description

  • clientName (string, optional) - Client name (default: "System")

Returns: boolean - Success status

Example:


Duty Clock Functions

GetDutyStatus

Check if a player is currently on duty.

Parameters:

  • citizenid (string) - Citizen ID of the player

Returns: table - { onDuty = boolean, data = table or nil }

Example:


ClockIn

Clock in a player to start their duty.

Parameters:

  • citizenid (string) - Citizen ID of the player

  • jobName (string) - Job name

Returns: boolean - Success status

Example:


ClockOut

Clock out a player to end their duty.

Parameters:

  • citizenid (string) - Citizen ID of the player

Returns: boolean - Success status

Example:


GetDutyHours

Get total duty hours for a player.

Parameters:

  • citizenid (string) - Citizen ID of the player

  • period (string, optional) - Time period: "today", "week", "month", or nil (all time)

Returns: number - Total hours worked

Example:


Practical Use Cases

Example 1: Custom Job Payment System

Example 2: Auto-Fine System

Example 3: Warehouse Integration

Example 4: Company Balance Check


Important Notes

  1. Server-Side Only: All exports are server-side only for security

  2. Error Handling: Always check return values before proceeding

  3. Citizen ID Format: Use the correct identifier format for your framework (QBCore vs ESX)

  4. Database: Ensure all database tables are properly installed


Last updated