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.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getCash(source)
await exports.pefcl.getCash(source)
await exports.pefcl.getCash(source: number)
- Export arguments:
- source:
number
- PlayerSrc
- source:
addCash
Adds cash to the player
- Lua Example
- JS Example
- TS Example
exports.pefcl:addCash(source, amount)
await exports.pefcl.addCash(source, amount)
await exports.pefcl.addCash(source: number, amount: number)
- Export arguments:
- source:
number
- PlayerSrc
- amount:
number
- Amount of cash to be added
- source:
removeCash
Removs cash from the player
- Lua Example
- JS Example
- TS Example
exports.pefcl:removeCash(source, amount)
await exports.pefcl.removeCash(source, amount)
await exports.pefcl.removeCash(source: number, amount: number)
- Export arguments:
- source:
number
- PlayerSrc
- amount:
number
- Amount of cash to be removed
- source:
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.
- Lua Example
- JS Example
- TS Example
exports.pefcl:depositCash(source, { amount = amount, message = message })
await exports.pefcl.depositCash(source, , { amount, message })
await exports.pefcl.depositCash(source: number, { amount, message }: { amount: number, message: string })
- Export arguments:
- source:
number
- PlayerSrc
- amount:
number
- Amount of cash to be deposited
- message:
string
- Transaction message
- source:
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.
- Lua Example
- JS Example
- TS Example
exports.pefcl:withdrawCash(source, { amount = amount, message = message })
await exports.pefcl.withdrawCash(source, , { amount, message })
await exports.pefcl.withdrawCash(source: number, { amount, message }: { amount: number, message: string })
- Export arguments:
- source:
number
- PlayerSrc
- amount:
number
- Amount of cash to be deposited
- message:
string
- Transaction message
- source:
Bank balance
getTotalBankBalance
Retrieve total bank balance.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getTotalBankBalance(source)
await exports.pefcl.getTotalBankBalance(source)
await exports.pefcl.getTotalBankBalance(source: number)
getDefaultAccountBalance
Retrieve bank balance from default account.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getDefaultAccountBalance(source)
await exports.pefcl.getDefaultAccountBalance(source)
await exports.pefcl.getDefaultAccountBalance(source: number)
addBankBalance
Adds money to the default account of the player. Message is optional.
- Lua Example
- JS Example
- TS Example
exports.pefcl:addBankBalance(source, { amount = amount, message = message })
await exports.pefcl.addBankBalance(source, amount, message)
await exports.pefcl.addBankBalance(source: number, amount: number, message?: string)
Export arguments:
- source:
number
- PlayerSrc
- amount:
number
- Amount of money to be added to default the account
- message:
string
- Transaction message
- source:
removeBankBalance
Removes money from the default account of the player. Message is optional.
- Lua Example
- JS Example
- TS Example
exports.pefcl:removeBankBalance(source, { amount = amount, message = message })
await exports.pefcl.removeBankBalance(source, {amount, message})
await exports.pefcl.removeBankBalance(source: number, {amount: number, message?: string})
- Export arguments:
- source:
number
- PlayerSrc
- amount:
number
- Amount of money to be removed from the default account
- message:
string
- Transaction message
- source:
getTotalBankBalanceByIdentifier
Retrieve total bank balance.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getTotalBankBalanceByIdentifier(source, identifier)
await exports.pefcl.getTotalBankBalanceByIdentifier(source, identifier)
await exports.pefcl.getTotalBankBalanceByIdentifier(source: number, identifier: string)
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.
- Lua Example
- JS Example
- TS Example
exports.pefcl:addBankBalanceByIdentifier(source, { identifier = identifier, amount = amount, message = message })
await exports.pefcl.addBankBalanceByIdentifier(source, { identifier, amount, message })
await exports.pefcl.addBankBalanceByIdentifier(source, { identifier, amount, message }: { identifier: string, amount: number, message?: string })
- 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
- source:
removeBankBalanceByIdentifier
Does not require player to be online.Removes money from the default account of specified player. Message is optional.
- Lua Example
- JS Example
- TS Example
exports.pefcl:removeBankBalanceByIdentifier(source, { identifier = identifier, amount = amount, message = message })
await exports.pefcl.removeBankBalanceByIdentifier(source, { identifier, amount, message })
await exports.pefcl.removeBankBalanceByIdentifier(source, { identifier, amount, message }: source: number, { identifier: string, amount: number, message?: string })
- Export arguments:
- identifier:
string
- Player identifier
- amount:
number
- Amount of money to be added to the default account
- message:
string
- Transaction message
- identifier:
Accounts
createAccount
Does not require player to be online.Create an account for player, with specific type & name.
- Lua Example
- JS Example
- TS Example
exports.pefcl:createUniqueAccount(source, { identifier = identifier, name = name, type = type })
await exports.pefcl.createUniqueAccount(source, { identifier, name, type })
await exports.pefcl.createUniqueAccount(source, { identifier, name, type }: source: number, { identifier: string, name: string, type: AccountType })
- Export arguments:
- source:
number
- PlayerSrc
- identifier:
string
- Owner identifier of account
- name:
number
- Account name
- type:
personal | shared
- Transaction message
- source:
getAccounts
Retrieve all accounts for player.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getAccounts(source)
await exports.pefcl.getAccounts(source)
await exports.pefcl.createAccount(source: number)
- Export arguments:
- source:
number
- PlayerSrc
- source:
getAccountsByIdentifier
Does not require player to be online.Retrieve all accounts for player by identifier.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getAccountsByIdentifier(source, identifier)
await exports.pefcl.getAccountsByIdentifier(source, identifier)
await exports.pefcl.createAccount(source: number, identifier: string)
- Export arguments:
- source:
number
- Source for player / character (Optionnal. you can set it to -1)
- identifier:
string
- Identifier for player / character
- source:
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.
- Lua Example
- JS Example
- TS Example
exports.pefcl:createInvoice(source, { to = to, toIdentifier = toIdentifier, from = from, fromIdentifier = fromIdentifier, amount = amount, message = message, receiverAccountIdentifier = receiverAccountIdentifier, expiresAt = expiresAt })
await exports.pefcl.createInvoice(source, { to, toIdentifier, from, fromIdentifier, amount, message, recieverAccountId, expiresAt })
await exports.pefcl.createInvoice(source: number, { to, toIdentifier, from, fromIdentifier, amount, message, recieverAccountId, expiresAt }: { to: string; toIdentifier: string; from: string; fromIdentifier: string; amount: number; message: string, recieverAccountId?: number; expiresAt?: string })
- 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"
- This is a message that should explain who sent the invoice. Examples:
- fromIdentifier:
string
- Identifier of the player who should receive the money from the invoice, unless
receiverAccountIdentifier
is specified.
- Identifier of the player who should receive the money from the invoice, unless
- amount:
number
- Decides how much the invoice should be
- message:
string
- Invoice description. Examples:
- "For the repairs"
- Invoice description. Examples:
- 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.
- to:
getInvoices
Retrieve all invoices for player by source.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getInvoices(source)
await exports.pefcl.getInvoices(source)
await exports.pefcl.getInvoices(source: number)
- Export arguments:
- source:
number
- PlayerSrc
- source:
getUnpaidInvoices
Retrieve all UNPAID invoices for player by source.
- Lua Example
- JS Example
- TS Example
exports.pefcl:getUnpaidInvoices(source)
await exports.pefcl.getUnpaidInvoices(source)
await exports.pefcl.getUnpaidInvoices(source: number)
- Export arguments:
- source:
number
- PlayerSrc
- source:
Player
loadPlayer
Load player into PEFCL via export. This is used to bridge existing framework with PEFCL. Such as QB & ESX.
- Lua Example
- JS Example
- TS Example
exports.pefcl:loadPlayer(source, { identifier = identifer, name = name, source = source })
await exports.pefcl.loadPlayer(source, { identifier, name, source })
await exports.pefcl.loadPlayer(source: number, { identifier, name, source }: { identifier: string, name: string, source: number })
- Export arguments:
- identifier:
string
- Player / Character identifier
- name:
number
- Player name
- source:
number
- PlayerSrc
- identifier:
unloadPlayer
Unload player from PEFCL via export. This is used to bridge existing framework with PEFCL. Such as QB & ESX.
- Lua Example
- JS Example
- TS Example
exports.pefcl:unloadPlayer(source)
await exports.pefcl.loadPlayer(source)
await exports.pefcl.loadPlayer(source: number)
- Export arguments:
- source:
number
- PlayerSrc
- source:
Events
"pefcl:newAccountBalance"
This will get emitted every time: the balance is updated for an account.
AddEventHandler("pefcl:newAccountBalance", function(account: Account)
{...}
end)
"pefcl:newAccountCreated"
This will get emitted every time: a new account is created.
AddEventHandler("pefcl:newAccountCreated", function(account: Account)
{...}
end)
"pefcl:accountDeleted"
This will get emitted every time: an account is deleted.
AddEventHandler("pefcl:accountDeleted", function(account: Account)
{...}
end)
"pefcl:newCash"
This will get emitted every time: the cash amount is updated.
AddEventHandler("pefcl:newCash", function(cash: Cash)
{...}
end)
"pefcl:newTransaction"
This will get emitted every time: a new transaction is created.
AddEventHandler("pefcl:newTransaction", function(transaction: Transaction)
{...}
end)
"pefcl:newInvoice"
This will get emitted every time: a new invoice is created.
AddEventHandler("pefcl:newInvoice", function(invoice: Invoice)
{...}
end)