'custom' - You need to make your own integrations!
Setup
This guide will help you setup society account functionality with T1GER Resources.
ESX
esx_addonaccount
Setting up functionality to create shared account in runtime is very simple; all you need to is download and install latest esx_addonaccount from here: https://github.com/esx-framework/esx_addonaccount.
Only do the following if you CANNOT download and install latest version and you are required/force to do the changes manually!!
If you prefer to keep your current esx_addonaccount resource for some weird reason, you can also manually implement the functionality.
Navigate to esx_addonaccount/server/main.lua
Find this function:
functionGetSharedAccount(name)
Add this export code below the function
exports("GetSharedAccount", GetSharedAccount)
Now in the same file, find this function:
functionAddSharedAccount(society,amount)
If the function exists, replace the whole function, if it doesn't exist, the insert - in both cases it's the same code:
functionAddSharedAccount(society,amount)-- society.name = job_name/society_name-- society.label = label for the job/account-- amount = if the shared account should start with x amountiftype(society) ~='table' ornot society?.name ornot society?.label thenreturnend-- check if account already exist?if SharedAccounts[society.name] ~=nilthenreturn SharedAccounts[society.name] end-- addon account:local account = MySQL.insert.await('INSERT INTO `addon_account` (name, label, shared) VALUES (?, ?, ?)', { society.name, society.label, 1 })ifnot account thenreturnend-- if addon account inserted, insert addon account data:local account_data = MySQL.insert.await('INSERT INTO `addon_account_data` (account_name, money) VALUES (?, ?)', { society.name, (amount or0) })ifnot account_data thenreturnend-- if all data inserted successfully to sql: SharedAccounts[society.name] =CreateAddonAccount(society.name, nil, (amount or0))return SharedAccounts[society.name]endexports("AddSharedAccount", AddSharedAccount)
You have succesfully set up esx_addonaccount to allow for automatic society account creation in runtime. All you need to do is restart the server!
QB Core
qb-banking
Setting up functionality to create shared account in runtime is very simple; all you need to is download and install latest qb-banking from here: https://github.com/qbcore-framework/qb-banking.
qb-management
Only do the following if you are using qb-management:
Navigate to qb-management/server/sv_boss.lua
Scroll down all the way to the bottom and insert the following code:
-- ## T1GER Integrations:functionCreateManagementAccount(job_name,amount)local findRow = MySQL.query.await('SELECT * FROM management_funds WHERE type = @type AND job_name = @job_name', { ['@job_name'] = job_name, ['@type'] ='boss' })ifnot findRow[1] then MySQL.insert('INSERT INTO management_funds (job_name, amount, type) VALUES (@job_name, @amount, @type)', { ['@job_name'] = job_name, ['@amount'] = amount or0, ['@type'] ='boss' }) Accounts[job_name] = amount or0endendexports("CreateManagementAccount", CreateManagementAccount)
Restart your server and you will now be able to create society accounts in runtime!
localfunctionCreateJobAccount(job,initialBalance)-- job(table): name(string), label(string) - job name and job label-- initialBalance(int): (optional) amount for account to start withifnot job.name ornot job.label thenreturnend-- check if account already exist?if cachedAccounts[job.name] thenreturn cachedAccounts[job.name] end cachedAccounts[job.name] = { id = job.name, type =locale('org'), name = job.label, frozen =0, amount = initialBalance or0, transactions = {}, auth = {}, creator =nil } MySQL.insert("INSERT INTO bank_accounts_new (id, amount, transactions, auth, isFrozen, creator) VALUES (?, ?, ?, ?, ?, NULL) ",{
job.name, cachedAccounts[job.name].amount, json.encode(cachedAccounts[job.name].transactions), json.encode({}), cachedAccounts[job.name].frozen
})return cachedAccounts[job.name]endexports('CreateJobAccount', CreateJobAccount)
You have succesfully set up qbox default banking resource to allow for automatic society account creation in runtime. All you need to do is restart the server!
Functions
These are the functions used in our T1GER resources.
These are also the functions you want to modify in case you want to integrate your custom society/shared account resource. Simply use 'custom' in Config.SocietyAccount and integrate your export/functions in the if/else statements for 'custom'.
GetSharedAccount
GetSharedAccount(society)-- parameters: society(string)-- returns account(table or integer (based on resource return value))