### Query Documentation via HTTP GET Source: https://snipe-1.gitbook.io/product-docs/banking Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific and self-contained. Use this when the answer is not explicitly present, for clarification, or to retrieve related sections. ```http GET https://snipe-1.gitbook.io/product-docs/banking.md?ask= ``` -------------------------------- ### Update esx_addonaccounts for Snipe Banking Integration Source: https://snipe-1.gitbook.io/product-docs/banking Replace the `CreateAddonAccount` function in `esx_addonaccounts/server/classes/addonaccount.lua` to use Snipe Banking exports for getting account balances and for add/remove/set money operations. Also, update the `onResourceStart` event handler in `esx_addonaccounts/server/main.lua` to initialize accounts using Snipe Banking and create a thread to load society accounts. ```lua local function TrimString(name) -- remove word society_ from name return name:sub(9) end function CreateAddonAccount(name, owner, money) local self = {} self.name = name self.job = TrimString(name) self.owner = owner sself.money = exports["snipe-banking"]:GetAccountBalance(self.job) function self.addMoney(m) self.money = self.money + m self.save() exports["snipe-banking"]:AddMoneyToAccount(self.job, m) end function self.removeMoney(m) self.money = self.money - m self.save() exports["snipe-banking"]:RemoveMoneyFromAccount(self.job, m) end function self.setMoney(m) self.money = m self.save() exports["snipe-banking"]:SetAccountMoney(self.job, m) end function self.save() -- if self.owner == nil then -- MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ?', {self.money, self.name}) -- else -- MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?', {self.money, self.name, self.owner}) -- end TriggerClientEvent('esx_addonaccount:setMoney', -1, self.job, self.money) end return self end ``` ```lua AddEventHandler('onResourceStart', function(resourceName) if resourceName == GetCurrentResourceName() then local accounts = MySQL.query.await('SELECT * FROM addon_account LEFT JOIN addon_account_data ON addon_account.name = addon_account_data.account_name UNION SELECT * FROM addon_account RIGHT JOIN addon_account_data ON addon_account.name = addon_account_data.account_name') local newAccounts = {} for i = 1, #accounts do local account = accounts[i] if account.shared == 0 then if not Accounts[account.name] then AccountsIndex[#AccountsIndex + 1] = account.name Accounts[account.name] = {} end Accounts[account.name][#Accounts[account.name] + 1] = CreateAddonAccount(account.name, account.owner, account.money) end end if next(newAccounts) then MySQL.prepare('INSERT INTO addon_account_data (account_name, money) VALUES (?, ?)', newAccounts) for i = 1, #newAccounts do local newAccount = newAccounts[i] SharedAccounts[newAccount[1]] = CreateAddonAccount(newAccount[1], nil, 0) end end end end) CreateThread(function() -- wait until snipe-banking starts while not GetResourceState('snipe-banking') == 'started' do Wait(100) end Wait(5000) local accounts = exports["snipe-banking"]:GetJobGangAccounts() for k, v in pairs(accounts) do local accountName = "society_"..k SharedAccounts[accountName] = CreateAddonAccount(accountName, nil, v) end end) ``` -------------------------------- ### Integrate Snipe-Banking in ESX Addon Accounts Source: https://snipe-1.gitbook.io/product-docs/banking.md Modify `esx_addonaccounts/server/classes/addonaccount.lua` to use `snipe-banking` for getting account balances and performing money operations. This replaces direct database interactions for these specific functions. ```lua local function TrimString(name) -- remove word society_ from name return name:sub(9) end function CreateAddonAccount(name, owner, money) local self = {} self.name = name self.job = TrimString(name) self.owner = owner sself.money = exports["snipe-banking"]:GetAccountBalance(self.job) function self.addMoney(m) self.money = self.money + m self.save() exports["snipe-banking"]:AddMoneyToAccount(self.job, m) end function self.removeMoney(m) self.money = self.money - m self.save() exports["snipe-banking"]:RemoveMoneyFromAccount(self.job, m) end function self.setMoney(m) self.money = m self.save() exports["snipe-banking"]:SetAccountMoney(self.job, m) end sfunction self.save() -- if self.owner == nil then -- MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ?', {self.money, self.name}) -- else -- MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?', {self.money, self.name, self.owner}) -- end TriggerClientEvent('esx_addonaccount:setMoney', -1, self.job, self.money) end return self end ``` -------------------------------- ### CreateJobGangAccount Source: https://snipe-1.gitbook.io/product-docs/banking Creates a new job or gang account with a specified name, label, starting balance, and type. ```APIDOC ## CreateJobGangAccount(name, label, amount, isJob) ### Description Creates a new job or gang account. The `name` is used for internal operations, `label` is for display in transactions, `amount` is the initial balance, and `isJob` determines if it's a job or gang account. ### Parameters - **name** (string) - Required - The internal name of the account. - **label** (string) - Required - The display name for the account. - **amount** (number) - Required - The starting balance for the account. - **isJob** (boolean) - Required - True if it's a job account, false if it's a gang account. ``` -------------------------------- ### Replace ESX Addon Accounts onResourceStart Event Source: https://snipe-1.gitbook.io/product-docs/banking.md Replace the `onResourceStart` event handler in `esx_addonaccounts/server/main.lua` to correctly load accounts and initialize shared accounts using `snipe-banking`. ```lua AddEventHandler('onResourceStart', function(resourceName) if resourceName == GetCurrentResourceName() then local accounts = MySQL.query.await('SELECT * FROM addon_account LEFT JOIN addon_account_data ON addon_account.name = addon_account_data.account_name UNION SELECT * FROM addon_account RIGHT JOIN addon_account_data ON addon_account.name = addon_account_data.account_name') local newAccounts = {} for i = 1, #accounts do local account = accounts[i] if account.shared == 0 then if not Accounts[account.name] then AccountsIndex[#AccountsIndex + 1] = account.name Accounts[account.name] = {} end Accounts[account.name][#Accounts[account.name] + 1] = CreateAddonAccount(account.name, account.owner, account.money) end end if next(newAccounts) then MySQL.prepare('INSERT INTO addon_account_data (account_name, money) VALUES (?, ?)', newAccounts) for i = 1, #newAccounts do local newAccount = newAccounts[i] SharedAccounts[newAccount[1]] = CreateAddonAccount(newAccount[1], nil, 0) end end end end) CreateThread(function() -- wait until snipe-banking starts while not GetResourceState('snipe-banking') == 'started' do Wait(100) end Wait(5000) local accounts = exports["snipe-banking"]:GetJobGangAccounts() for k, v in pairs(accounts) do local accountName = "society_"..k SharedAccounts[accountName] = CreateAddonAccount(accountName, nil, v) end end) ``` -------------------------------- ### Display Progress Bar and Open Bank UI Source: https://snipe-1.gitbook.io/product-docs/banking Shows a progress bar before opening the main bank UI. Call with `true` to initiate the progress bar and UI sequence. ```lua exports["snipe-banking"]:DoProgress(true) ``` -------------------------------- ### Display Progress Bar and Open ATM UI Source: https://snipe-1.gitbook.io/product-docs/banking Shows a progress bar before opening the ATM UI. Call with `false` to initiate the progress bar and UI sequence. ```lua exports["snipe-banking"]:DoProgress(false) ``` -------------------------------- ### Comment out qb-management exports Source: https://snipe-1.gitbook.io/product-docs/banking Comment out the specified server exports in qb-management/fxmanifest.lua to prevent conflicts with snipe-banking. ```lua -- server_exports { -- 'AddMoney', -- 'AddGangMoney', -- 'RemoveMoney', -- 'RemoveGangMoney', -- 'GetAccount', -- 'GetGangAccount', -- } ``` -------------------------------- ### OpenATM Source: https://snipe-1.gitbook.io/product-docs/banking Opens the ATM UI without displaying a progress bar. ```APIDOC ## OpenATM() ### Description Opens the ATM user interface directly without showing a progress bar. ### Usage `exports["snipe-banking"]:OpenATM()` ``` -------------------------------- ### DoProgress Source: https://snipe-1.gitbook.io/product-docs/banking Displays a progress bar and opens either the bank or ATM UI. ```APIDOC ## DoProgress(boolean) ### Description Shows a progress bar and then opens either the BANK UI or ATM UI based on the boolean parameter. `true` opens the bank UI, `false` opens the ATM UI. ### Parameters - **boolean** (boolean) - Required - `true` to open bank UI, `false` to open ATM UI. ``` -------------------------------- ### Configure Flagged Account Alert in PS Dispatch (sv_dispatchcodes.lua) Source: https://snipe-1.gitbook.io/product-docs/banking Add a new entry to `sv_dispatchcodes.lua` to define the 'flagged_account' alert. This configuration specifies display properties and recipients. ```lua ["flagged_account"] = {displayCode = '10-13', description ="Flagged Account", radius = 0, recipientList = {'police'}, blipSprite = 110, blipColour = 1, blipScale = 1.5, blipLength = 2, sound = "Lose_1st", sound2 = "GTAO_FM_Events_Soundset", offset = "false", blipflash = "false"}, ``` -------------------------------- ### OpenBank Source: https://snipe-1.gitbook.io/product-docs/banking Opens the bank UI without displaying a progress bar. ```APIDOC ## OpenBank() ### Description Opens the bank user interface directly without showing a progress bar. ### Usage `exports["snipe-banking"]:OpenBank()` ``` -------------------------------- ### Implement Flagged Account Alert in PS Dispatch (cl_events.lua) Source: https://snipe-1.gitbook.io/product-docs/banking Add this Lua function to `cl_events.lua` to trigger the 'flagged_account' dispatch event. Ensure `dispatchcodename` matches `sv_dispatchcodes.lua`. ```lua local function FlaggedAccount() local currentPos = GetEntityCoords(PlayerPedId()) local locationInfo = getStreetandZone(currentPos) local gender = GetPedGender() local PlayerPed = PlayerPedId() TriggerServerEvent("dispatch:server:notify", { dispatchcodename = "flagged_account", -- has to match the codes in sv_dispatchcodes.lua so that it generates the right blip dispatchCode = "10-11", firstStreet = locationInfo, gender = gender, model = nil, plate = nil, priority = 2, firstColor = nil, automaticGunfire = false, origin = { x = currentPos.x, y = currentPos.y, z = currentPos.z }, dispatchMessage = "Flagged Account Accessed", job = {"police"} -- has to match the recipientList in sv_dispatchcodes.lua }) end exports("FlaggedAccount", FlaggedAccount) ``` -------------------------------- ### Add Account Freeze Check in esx_extended Source: https://snipe-1.gitbook.io/product-docs/banking Modify the `getAccount` function in `esx_extended/server/classes/player.lua` to check if a bank account is frozen via Snipe Banking before returning its balance. This ensures frozen accounts show zero money. ```lua function self.getAccount(account) if account == "bank" and exports["snipe-banking"]:IsAccountFrozenForIdentifier(self.identifier) then -- add this line return {name = "bank", money = 0} end for k,v in ipairs(self.accounts) do if v.name == account then return v end end end ``` -------------------------------- ### Configure Flagged Account Alert in PS Dispatch (sv_dispatchcodes.lua) Source: https://snipe-1.gitbook.io/product-docs/banking.md Add or modify the 'flagged_account' entry in `sv_dispatchcodes.lua` to define alert properties and recipients for PS Dispatch v2. Ensure the `recipientList` matches the job/gang you want to notify. ```lua ["flagged_account"] = {displayCode = '10-13', description ="Flagged Account", radius = 0, recipientList = {'police'}, blipSprite = 110, blipColour = 1, blipScale = 1.5, blipLength = 2, sound = "Lose_1st", sound2 = "GTAO_FM_Events_Soundset", offset = "false", blipflash = "false"}, ``` -------------------------------- ### Open Bank UI without Progress Bar Source: https://snipe-1.gitbook.io/product-docs/banking Directly opens the bank UI without displaying a progress bar. Use this for immediate access to the bank interface. ```lua exports["snipe-banking"]:OpenBank() ``` -------------------------------- ### IsAccountFrozenForIdentifier Source: https://snipe-1.gitbook.io/product-docs/banking Checks if an account is frozen based on the player identifier. Use citizenid for qbcore and charid for esx. ```APIDOC ## IsAccountFrozenForIdentifier(playerIdentifier) ### Description Returns true if the account is frozen. ### Parameters #### Path Parameters - **playerIdentifier** (string) - Required - The player's identifier (citizenid for qbcore, charid for esx). ``` -------------------------------- ### CreateJobTransactions Source: https://snipe-1.gitbook.io/product-docs/banking.md Creates a job or gang transaction. Should be triggered from where the transaction is made. Supports deposits, withdrawals, and transfers. ```APIDOC ## CreateJobTransactions(jobgang, amount, memo, type, identifier, otherPlayerIdentifier, isJob) ### Description Creates a transaction for a job or gang account. This should be called when a transaction occurs. ### Method Not applicable (function call) ### Parameters #### Path Parameters - **jobgang** (string) - Required - The name of the job or gang. - **amount** (number) - Required - The transaction amount. - **memo** (string) - Required - A memo for the transaction. - **type** (string) - Required - The type of transaction (e.g., `deposit`, `withdraw`, `transfer`). - **identifier** (string) - Required - The identifier of the player initiating the transaction (e.g., `citizenid` for qbcore, `charid` for esx). - **otherPlayerIdentifier** (string) - Optional - The identifier of the other player involved in a transfer. - **isJob** (boolean) - Required - Set to true if the transaction involves a job/gang. ``` -------------------------------- ### IsAccountFrozen Source: https://snipe-1.gitbook.io/product-docs/banking Checks if a player's bank account is frozen. ```APIDOC ## IsAccountFrozen() ### Description Returns a boolean indicating whether the player's bank account is frozen. ### Returns - **boolean** - True if the account is frozen, false otherwise. ``` -------------------------------- ### Open ATM UI without Progress Bar Source: https://snipe-1.gitbook.io/product-docs/banking Directly opens the ATM UI without displaying a progress bar. Use this for immediate access to the ATM interface. ```lua exports["snipe-banking"]:OpenATM() ``` -------------------------------- ### Implement Flagged Account Alert in Moz Dispatch Source: https://snipe-1.gitbook.io/product-docs/banking Use this Lua function to trigger a 'Flagged Account Accessed' alert in Moz Dispatch. It defines alert details and sends it to the server. ```lua local function FlaggedAccount() local alertInfo = functions.getAlertInfo() local alert = { information = 'Flagged Account Accessed', priority = 'low', department = 'police', duration = 10000, code = '10-13A', location = alertInfo.location, blip = { radius = 50.0, sprite = 1, color = 1, scale = 1.0, alpha = 128, shortRange = true, name = 'Flagged Account', fadeAfter = 10000, } } TriggerServerEvent('moz-dispatch:server:sendAlert', alert) end exports('FlaggedAccount', FlaggedAccount) ``` -------------------------------- ### IsAccountFrozenForPlayerId Source: https://snipe-1.gitbook.io/product-docs/banking Checks if a player's account is frozen. Requires the player's source ID. ```APIDOC ## IsAccountFrozenForPlayerId(playerId) ### Description Returns true if the player's account is frozen. ### Parameters #### Path Parameters - **playerId** (number) - Required - The player's source ID. ``` -------------------------------- ### CreatePersonalTransactions Source: https://snipe-1.gitbook.io/product-docs/banking.md Creates a personal transaction. Should be triggered from where the transaction is made. Supports deposits, withdrawals, and transfers. ```APIDOC ## CreatePersonalTransactions(identifier, amount, memo, type, otherPlayerIdentifier, isJob) ### Description Creates a personal transaction record. This should be called when a transaction occurs. ### Method Not applicable (function call) ### Parameters #### Path Parameters - **identifier** (string) - Required - The identifier of the player initiating the transaction (e.g., `citizenid` for qbcore, `charid` for esx). - **amount** (number) - Required - The transaction amount. - **memo** (string) - Required - A memo for the transaction. - **type** (string) - Required - The type of transaction (e.g., `deposit`, `withdraw`, `transfer`). - **otherPlayerIdentifier** (string) - Optional - The identifier of the other player involved in a transfer. - **isJob** (boolean) - Required - Set to true if the transaction involves a job/gang. ``` -------------------------------- ### Create Job/Gang Account with Snipe Banking Source: https://snipe-1.gitbook.io/product-docs/banking Use this function to create new bank accounts for jobs or gangs. Ensure you use only snipe-banking exports for subsequent money operations on these accounts. The `isJob` parameter determines if it's a job or gang account. ```lua CreateJobGangAccount(name, label, amount, isJob) ``` -------------------------------- ### CreateJobTransactions Source: https://snipe-1.gitbook.io/product-docs/banking Should be triggered when a job or gang transaction is made. Requires jobgang name, amount, memo, type, identifier, otherPlayerIdentifier (if transfer), and isJob flag. ```APIDOC ## CreateJobTransactions(jobgang, amount, memo, type, identifier, otherPlayerIdentifier, isJob) ### Description Creates a job or gang transaction record. ### Parameters #### Path Parameters - **jobgang** (string) - Required - The name of the job or gang. - **amount** (number) - Required - The transaction amount. - **memo** (string) - Required - A description for the transaction. - **type** (string) - Required - The type of transaction (deposit/withdraw/transfer). - **identifier** (string) - Required - The player's identifier (citizenid for qbcore, charid for esx). - **otherPlayerIdentifier** (string) - Optional - The identifier of the other player if the type is transfer. - **isJob** (boolean) - Required - True if the transaction is to/from a job, false otherwise. ``` -------------------------------- ### CreatePersonalTransactions Source: https://snipe-1.gitbook.io/product-docs/banking Should be triggered when a personal transaction is made. Requires identifier, amount, memo, type, otherPlayerIdentifier (if transfer), and isJob flag. ```APIDOC ## CreatePersonalTransactions(identifier, amount, memo, type, otherPlayerIdentifier, isJob) ### Description Creates a personal transaction record. ### Parameters #### Path Parameters - **identifier** (string) - Required - The player's identifier (citizenid for qbcore, charid for esx). - **amount** (number) - Required - The transaction amount. - **memo** (string) - Required - A description for the transaction. - **type** (string) - Required - The type of transaction (deposit/withdraw/transfer). - **otherPlayerIdentifier** (string) - Optional - The identifier of the other player if the type is transfer. - **isJob** (boolean) - Required - True if the transaction is to/from a job, false otherwise. ``` -------------------------------- ### IsAccountFlaggedForIdentifier Source: https://snipe-1.gitbook.io/product-docs/banking Checks if a player's account is flagged based on their identifier. Use citizenid for qbcore and charid for esx. ```APIDOC ## IsAccountFlaggedForIdentifier(playerIdentifier) ### Description Returns true if the player's account is flagged. ### Parameters #### Path Parameters - **playerIdentifier** (string) - Required - The player's identifier (citizenid for qbcore, charid for esx). ``` -------------------------------- ### IsAccountFlaggedForPlayerId Source: https://snipe-1.gitbook.io/product-docs/banking Checks if a player's account is flagged. Requires the player's source ID. ```APIDOC ## IsAccountFlaggedForPlayerId(playerId) ### Description Returns true if the player's account is flagged. ### Parameters #### Path Parameters - **playerId** (number) - Required - The player's source ID. ``` -------------------------------- ### Add Snipe Banking Export to esx_multicharacter Source: https://snipe-1.gitbook.io/product-docs/banking If using a custom `esx_multicharacter` script, integrate the `exports["snipe-banking"]:DeleteCharacter(identifier)` line within the `DeleteCharacter` function. This ensures character deletion also removes associated banking data. ```lua local function DeleteCharacter(source, charid) local identifier = ('%s%s:%s'):format(PREFIX, charid, GetIdentifier(source)) exports["snipe-banking"]:DeleteCharacter(identifier) --added local query = 'DELETE FROM %s WHERE %s = ?' local queries = {} local count = 0 for table, column in pairs(DB_TABLES) do count = count + 1 queries[count] = {query = query:format(table, column), values = {identifier}} end MySQL.transaction(queries, function(result) if result then print(('[^2INFO^7] Player ^5%s %s^7 has deleted a character ^5(%s)^7'):format(GetPlayerName(source), source, identifier)) Wait(50) SetupCharacters(source) else error('\n^1Transaction failed while trying to delete '..identifier..'^0') end end) end ``` -------------------------------- ### Check if Player Account is Flagged Source: https://snipe-1.gitbook.io/product-docs/banking Returns true if the player's bank account has been flagged. This can be used to implement restrictions or checks within your scripts. ```lua IsAccountFlagged() ``` -------------------------------- ### Modify QBCore Player DeleteCharacter function Source: https://snipe-1.gitbook.io/product-docs/banking Replace the existing QBCore.Player.DeleteCharacter function in qb-core/server/player.lua with this version to integrate snipe-banking's character deletion. ```lua function QBCore.Player.DeleteCharacter(source, citizenid) exports["snipe-banking"]:DeleteCharacter(citizenid) --added local license = QBCore.Functions.GetIdentifier(source, 'license') local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid }) if license == result then local query = "DELETE FROM %s WHERE citizenid = ?" local tableCount = #playertables local queries = table.create(tableCount, 0) for i = 1, tableCount do local v = playertables[i] queries[i] = {query = query:format(v.table), values = { citizenid }} end MySQL.transaction(queries, function(result2) if result2 then TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Character Deleted', 'red', '**' .. GetPlayerName(source) .. '** ' .. license .. ' deleted **' .. citizenid .. '**..') end end) else DropPlayer(source, Lang:t("info.exploit_dropped")) TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'white', GetPlayerName(source) .. ' Has Been Dropped For Character Deletion Exploit', true) end end ``` -------------------------------- ### IsAccountFlagged Source: https://snipe-1.gitbook.io/product-docs/banking Checks if a player's bank account is flagged. ```APIDOC ## IsAccountFlagged() ### Description Returns a boolean indicating whether the player's bank account is flagged. ### Returns - **boolean** - True if the account is flagged, false otherwise. ``` -------------------------------- ### Check if Player Account is Frozen Source: https://snipe-1.gitbook.io/product-docs/banking Returns true if the player's bank account is currently frozen. This is useful for preventing transactions or access to funds for frozen accounts. ```lua IsAccountFrozen() ``` -------------------------------- ### RemoveMoneyFromAccount Source: https://snipe-1.gitbook.io/product-docs/banking Removes money from the job/gang account. This function does not register the transaction; you need to use other exports to create a transaction for UI display. ```APIDOC ## RemoveMoneyFromAccount(job/gang, amount) ### Description Removes money from the job/gang account. ### Parameters #### Path Parameters - **job/gang** (string) - Required - The name of the job or gang account. - **amount** (number) - Required - The amount of money to remove. ``` -------------------------------- ### DeleteCharacter Source: https://snipe-1.gitbook.io/product-docs/banking Should be triggered when a character is deleted. Requires the character's citizenid. ```APIDOC ## DeleteCharacter(citizenid) ### Description Deletes a character associated with the provided citizenid. ### Parameters #### Path Parameters - **citizenid** (string) - Required - The citizen ID of the character to delete. ``` -------------------------------- ### DeleteCharacter Source: https://snipe-1.gitbook.io/product-docs/banking.md Deletes a character. Should be triggered from the place where the character is deleted. ```APIDOC ## DeleteCharacter(citizenid) ### Description Deletes a character associated with the given citizen ID. ### Method Not applicable (function call) ### Parameters #### Path Parameters - **citizenid** (string) - Required - The citizen ID of the character to delete. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.