⚙️Exports

Comprehensive instructions on configuring files and utilizing export functions.

Billing Exports

This module provides a set of exports to interact with the billing system.

You can use these exports from other resources with:

exports["crm-billing"]:functionName(args)

🔸getInvoiceById

Retrieve a single invoice by its ID.

local crm_invoice = exports["crm-billing"]:getInvoiceById(crm_id)

Parameters

  • crm_id (number) – Invoice ID.

Returns

  • (table | nil) – Invoice object if found, otherwise nil.

Example

local crm_invoice = exports["crm-billing"]:getInvoiceById(12)
if crm_invoice then
    print(("Invoice #%s amount: %s"):format(crm_invoice.crm_id, crm_invoice.crm_amount))
end

🔸getPlayerInvoices

Retrieve all invoices for a player.

local crm_invoices = exports["crm-billing"]:getPlayerInvoices(crm_identifier)

Parameters

  • crm_identifier (string) – Character identifier.

Returns

  • (table | nil) – Table of player invoices if found, otherwise nil.

Example

local crm_invoices = exports["crm-billing"]:getPlayerInvoices("RO7G58L8")
if crm_invoices then
    for _, crm_invoice in pairs(crm_invoices) do
        print(("Invoice #%s - %s$"):format(crm_invoice.crm_id, crm_invoice.crm_reason))
    end
end

🔸getSocietyInvoices

Retrieve all invoices for a society (job).

local crm_invoices = exports["crm-billing"]:getSocietyInvoices(crm_job)

Parameters

  • crm_job (string) – Job name (e.g., "police", "mechanic").

Returns

  • (table | nil) – Table of society invoices if found, otherwise nil.

Example

local crm_invoices = exports["crm-billing"]:getSocietyInvoices("police")
if crm_invoices then
    print(("Police department has %s invoices"):format(#crm_invoices))
end

🔸payInvoice

Pay an invoice if possible.

local crm_success = exports["crm-billing"]:payInvoice(crm_id)

Parameters

  • crm_id (number) – Invoice ID.

Returns

  • (boolean)true if paid successfully, false otherwise.

Example

local crm_ok = exports["crm-billing"]:payInvoice(10)
if crm_ok then
    print("Invoice paid successfully!")
else
    print("Failed to pay invoice.")
end

🔸cancelInvoice

Cancel an invoice.

local crm_success = exports["crm-billing"]:cancelInvoice(crm_id)

Parameters

  • crm_id (number) – Invoice ID.

Returns

  • (boolean)true if invoice was cancelled, false if not found.

Example

if exports["crm-billing"]:cancelInvoice(5) then
    print("Invoice cancelled.")
else
    print("Invoice not found.")
end

🔸addPersonalInvoice

Create a new personal invoice.

exports["crm-billing"]:addPersonalInvoice(crm_sender, crm_receiver, crm_amount, crm_reason, crm_cb)

Parameters

  • crm_sender (number) – Sender server ID (must be online).

  • crm_receiver (number) – Receiver server ID (must be online).

  • crm_amount (number) – Invoice amount.

  • crm_reason (string) – Invoice data. Example:

  • crm_cb (function | optional) – Callback function returning the created invoice.

Example

exports["crm-billing"]:addPersonalInvoice(
    1,  -- sender
    2,  -- receiver
    crm_amount = 150,
    crm_reason = "Repair service",
    function(crm_invoice)
        print("Invoice created with ID:", crm_invoice.crm_id)
    end
)

🔸addSocietyInvoice

Create a new society invoice.

local crm_invoice = exports["crm-billing"]:addSocietyInvoice(crm_data)

Parameters

  • crm_data (table) – Invoice data. Example:

    {
        crm_id = "police", -- society Name
        crm_label = "Police Department", -- society Label
        crm_receiver = 1, -- Target player server id
        crm_amount = 600, -- Invoice amount
        crm_reason = "Reckless driving", -- Invoice reason
    }

Returns

  • (table | false) – Invoice object if created, otherwise false.

Example

local crm_invoice = exports['crm-billing']:addSocietyInvoice({
    crm_id = "police", -- society Name
    crm_label = "Police Department", -- society Label
    crm_receiver = 1, -- Target player server id
    crm_amount = 600, -- Invoice amount
    crm_reason = "Reckless driving", -- Invoice reason
})
if crm_invoice then
    print("Invoice created with ID:", crm_invoice.crm_id)
end

🔸addOfflineInvoice

Create a new offline invoice.

local crm_invoice exports["crm-billing"]:addOfflineInvoice(crm_data)

Parameters

  • crm_data (table) – Invoice data. Example:

    {
        crm_type = "crm-society", -- "crm-personal" or "crm-society"
        crm_sender = {crm_id = "police", crm_label = "Police Department"},
        crm_receiver = {crm_id = "Z4VNKWZ5", crm_label = "Dev Nezaik"},
        crm_amount = 600, -- Invoice amount
        crm_reason = "Reckless driving", -- Invoice reason
    }

Returns

  • (table | false) – Invoice object if created, otherwise false.

Example

-- PERSONAL INVOICE
local crm_personal_invoice = exports['crm-billing']:addOfflineInvoice({
    crm_type = "crm-personal",
    crm_sender = {crm_id = "Z4VNKWZ5", crm_label = "Dev Nezaik"},
    crm_receiver = {crm_id = "A6RFMX9", crm_label = "CoreM Dev"},
    crm_reason = "Custom Reason",
    crm_amount = 500,
})
if crm_personal_invoice then
    print("Invoice created with ID:", crm_personal_invoice.crm_id)
end

-- SOCIETY INVOICE
local crm_society_invoice = exports['crm-billing']:addOfflineInvoice({
    crm_type = "crm-society",
    crm_sender = {crm_id = "ambulance", crm_label = "EMS"},
    crm_receiver = {crm_id = "A6RFMX9", crm_label = "CoreM Dev"},
    crm_reason = "Custom Reason",
    crm_amount = 500,
})
if crm_society_invoice then
    print("Invoice created with ID:", crm_society_invoice.crm_id)
end

Last updated