Setup
Instructions on how to setup your job/society integrations with your framework to create shared accounts for jobs in runtime!
ESX
QBCore
qb-banking
qb-bankingqb-management
qb-management3
Insert new function
--- Creates a management account for a job in qb-management.
---@param job_name string The name of the job to create the management account for.
---@param amount number|nil The initial balance of the account (defaults to 0 if not provided).
---@return boolean success Returns `true` if the account was created successfully, `false` otherwise.
function CreateManagementAccount(job_name, amount)
-- Ensure a valid job name is provided
if type(job_name) ~= "string" or job_name == "" then
error("Invalid job_name provided")
end
amount = amount or 0 -- Default to 0 if no amount is provided
-- Check if account already exists in cache
if Accounts[job_name] then
return Accounts[job_name] -- Account already exists, no need to create it again
end
-- Insert the new account into the database
local insertSuccess = MySQL.insert.await('INSERT INTO management_funds (job_name, amount, type) VALUES (@job_name, @amount, @type)', {
['@job_name'] = job_name,
['@amount'] = amount,
['@type'] = 'boss'
})
if not insertSuccess then
error("Database error: Failed to insert management account")
end
-- Store in local cache
Accounts[job_name] = amount
return Accounts[job_name]
end
exports("CreateManagementAccount", CreateManagementAccount)Qbox
Last updated