Skip to main content

Server exports & events

Exports

PEFCL exposes a few useful exports that be used from other resources to integrate better with the financing system. The exports support both callback & promises.

Cash

getCash

Gets cash from the player, framework integrated. When framework integration is enabled you need to export the functions required. Read more under Framework Integration.

exports.pefcl:getCash(source)
  • Export arguments:
    • source: number
      • PlayerSrc

addCash

Adds cash to the player

exports.pefcl:addCash(source, amount)
  • Export arguments:
    • source: number
      • PlayerSrc
    • amount: number
      • Amount of cash to be added

removeCash

Removs cash from the player

exports.pefcl:removeCash(source, amount)
  • Export arguments:
    • source: number
      • PlayerSrc
    • amount: number
      • Amount of cash to be removed

depositCash

Takes money from cash and deposits it into the player's default bank account. If framework integration is enabled PEFCL uses the export "removeCash" to take cash from the player.

exports.pefcl:depositCash(source, { amount = amount, message = message })
  • Export arguments:
    • source: number
      • PlayerSrc
    • amount: number
      • Amount of cash to be deposited
    • message: string
      • Transaction message

withdrawCash

Withdraws money from the player's default bank account and adds as cash. If framework integration is enabled PEFCL uses the export "addCash" to give cash to the player.

exports.pefcl:withdrawCash(source, { amount = amount, message = message })
  • Export arguments:
    • source: number
      • PlayerSrc
    • amount: number
      • Amount of cash to be deposited
    • message: string
      • Transaction message

Bank balance

getTotalBankBalance

Retrieve total bank balance.

exports.pefcl:getTotalBankBalance(source)

getDefaultAccountBalance

Retrieve bank balance from default account.

exports.pefcl:getDefaultAccountBalance(source)

addBankBalance

Adds money to the default account of the player. Message is optional.

exports.pefcl:addBankBalance(source, { amount = amount, message = message })
  • Export arguments:

    • source: number
      • PlayerSrc
    • amount: number
      • Amount of money to be added to default the account
    • message: string
      • Transaction message

removeBankBalance

Removes money from the default account of the player. Message is optional.

exports.pefcl:removeBankBalance(source, { amount = amount, message = message })
  • Export arguments:
    • source: number
      • PlayerSrc
    • amount: number
      • Amount of money to be removed from the default account
    • message: string
      • Transaction message

getTotalBankBalanceByIdentifier

Retrieve total bank balance.

exports.pefcl:getTotalBankBalanceByIdentifier(source, identifier)

addBankBalanceByIdentifier

Does not require player to be online.

Adds money to the default account of specified player. Message is optional. This export can be used to create recurring payments to players, such as a job salary.

exports.pefcl:addBankBalanceByIdentifier(source, { identifier = identifier, amount = amount, message = message })
  • Export arguments:
    • source: number
      • PlayerSrc
    • identifier: string
      • Player identifier
    • amount: number
      • Amount of money to be added to the default account
    • message: string
      • Transaction message

removeBankBalanceByIdentifier

Does not require player to be online.

Removes money from the default account of specified player. Message is optional.

exports.pefcl:removeBankBalanceByIdentifier(source, { identifier = identifier, amount = amount, message = message })
  • Export arguments:
    • identifier: string
      • Player identifier
    • amount: number
      • Amount of money to be added to the default account
    • message: string
      • Transaction message

Accounts

createAccount

Does not require player to be online.

Create an account for player, with specific type & name.

exports.pefcl:createUniqueAccount(source, { identifier = identifier, name = name, type = type })
  • Export arguments:
    • source: number
      • PlayerSrc
    • identifier: string
      • Owner identifier of account
    • name: number
      • Account name
    • type: personal | shared
      • Transaction message

getAccounts

Retrieve all accounts for player.

exports.pefcl:getAccounts(source)
  • Export arguments:
    • source: number
      • PlayerSrc

getAccountsByIdentifier

Does not require player to be online.

Retrieve all accounts for player by identifier.

exports.pefcl:getAccountsByIdentifier(source, identifier)
  • Export arguments:
    • source: number
      • Source for player / character (Optionnal. you can set it to -1)
    • identifier: string
      • Identifier for player / character

Invoices

createInvoice

Does not require player to be online.

Creates a invoice with specified information. Invoice will be sent to the player. Possible to define which account recieves the money as well.

exports.pefcl:createInvoice(source, { to = to, toIdentifier = toIdentifier, from = from, fromIdentifier = fromIdentifier, amount = amount, message = message, receiverAccountIdentifier = receiverAccountIdentifier, expiresAt = expiresAt })
  • Export arguments:
    • to: string
      • Name of the player that should pay the invoice.
    • toIdentifier: string
      • Identifier of the player who should pay the invoice.
    • from: string
      • This is a message that should explain who sent the invoice. Examples:
        • "Police Dpt."
        • "John Doe"
    • fromIdentifier: string
      • Identifier of the player who should receive the money from the invoice, unless receiverAccountIdentifier is specified.
    • amount: number
      • Decides how much the invoice should be
    • message: string
      • Invoice description. Examples:
        • "For the repairs"
    • receiverAccountIdentifier?: string
      • Optional. If specified, the invoice amount will be sent to the specified account once it's paid.
      • If you have job accounts, this is the identifier of the job: "ambulance", "police", "taxi" etc
    • expiresAt?: string
      • Optional. If specified, the invoice will expire at the specified date.

getInvoices

Retrieve all invoices for player by source.

exports.pefcl:getInvoices(source)
  • Export arguments:
    • source: number
      • PlayerSrc

getUnpaidInvoices

Retrieve all UNPAID invoices for player by source.

exports.pefcl:getUnpaidInvoices(source)
  • Export arguments:
    • source: number
      • PlayerSrc

Player

loadPlayer

Load player into PEFCL via export. This is used to bridge existing framework with PEFCL. Such as QB & ESX.

exports.pefcl:loadPlayer(source, { identifier = identifer, name = name, source = source })
  • Export arguments:
    • identifier: string
      • Player / Character identifier
    • name: number
      • Player name
    • source: number
      • PlayerSrc

unloadPlayer

Unload player from PEFCL via export. This is used to bridge existing framework with PEFCL. Such as QB & ESX.

exports.pefcl:unloadPlayer(source)
  • Export arguments:
    • source: number
      • PlayerSrc

Events

"pefcl:newAccountBalance"

This will get emitted every time: the balance is updated for an account.

AddEventHandler("pefcl:newAccountBalance", function(account: Account)
{...}
end)

Interface: Account

"pefcl:newAccountCreated"

This will get emitted every time: a new account is created.

AddEventHandler("pefcl:newAccountCreated", function(account: Account)
{...}
end)

Interface: Account

"pefcl:accountDeleted"

This will get emitted every time: an account is deleted.

AddEventHandler("pefcl:accountDeleted", function(account: Account)
{...}
end)

Interface: Account

"pefcl:newCash"

This will get emitted every time: the cash amount is updated.

AddEventHandler("pefcl:newCash", function(cash: Cash)
{...}
end)

Interface: Cash

"pefcl:newTransaction"

This will get emitted every time: a new transaction is created.

AddEventHandler("pefcl:newTransaction", function(transaction: Transaction)
{...}
end)

Interface: Transaction

"pefcl:newInvoice"

This will get emitted every time: a new invoice is created.

AddEventHandler("pefcl:newInvoice", function(invoice: Invoice)
{...}
end)

Interface: Invoice