# Banking

A comprehensive banking system for FiveM servers supporting both ESX and QBCore frameworks.

## Features

* Personal banking accounts
* Business/Job accounts with role-based access
* ATM functionality with withdrawal limits
* Transaction history
* Bank transfers between players
* Business account transfers
* Multi-language support
* Configurable tax rates on transfers
* Database transaction logging
* Blips for banks and ATMs (optional)

## Dependencies

* ESX or QBCore framework
* MySQL-Async
* hate-notify

## Installation

1. Import the SQL file to your database:

```sql
-- Create bank transactions table
CREATE TABLE IF NOT EXISTS `bank_transactions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `identifier` varchar(60) NOT NULL,
  `trans_id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `amount` decimal(10,2) NOT NULL,
  `type` varchar(10) NOT NULL,
  `date` varchar(50) NOT NULL,
  `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `identifier` (`identifier`),
  KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Create job transactions table
CREATE TABLE IF NOT EXISTS `job_transactions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `account_name` varchar(50) NOT NULL,
  `account_type` varchar(10) NOT NULL,
  `identifier` varchar(60) NOT NULL,
  `source_name` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` varchar(255) NULL DEFAULT NULL,
  `amount` int(11) NOT NULL,
  `type` varchar(20) NOT NULL,
  `date` varchar(50) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `account_name` (`account_name`),
  KEY `account_type` (`account_type`),
  KEY `identifier` (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

2. Add to your resources folder
3. Add to server.cfg: `ensure hate-bank`

## Configuration

The script can be configured through config.lua:

```lua
Config = {
    Framework = "qbcore", -- "esx" or "qbcore"
    Language = "en", -- "tr" for Turkish, "en" for English
    ShowATMBlips = false,
    TransactionTax = 0.00, -- Transfer tax (0.01 = 1%)
    TransactionLog = true,
    SaveTransactionsToDatabase = true,
    ATMWithdrawLimit = 5000,
    ATMRefreshHours = 6
}
```

## Exports

### Server Exports

```lua
-- Function: AddBankMoney(playerId, amount, description)
-- Parameters:
--   playerId: The server ID of the player
--   amount: The amount of money to add (must be positive)
--   description: (Optional) A description of the transaction that will appear in bank history

-- Example:
exports['hate-bank']:AddBankMoney(1, 5000, "Race winnings")
```

```lua
-- Function: RemoveBankMoney(playerId, amount, description)
-- Parameters:
--   playerId: The server ID of the player
--   amount: The amount of money to remove (must be positive)
--   description: (Optional) A description of the transaction that will appear in bank history
-- Returns:
--   boolean: true if successful, false if failed (e.g., insufficient funds)

-- Example:
local success = exports['hate-bank']:RemoveBankMoney(1, 2500, "Car purchase")
```

```lua
-- Function: AddJobMoney(accountName, accountType, amount, description, sourceName)
-- Parameters:
--   accountName: The name of the account (usually the job name, e.g. "police")
--   accountType: The account type (usually "job")
--   amount: The amount of money to add (must be positive)
--   description: (Optional) A description of the transaction
--   sourceName: (Optional) The name that will appear as the source of the transaction
-- Returns:
--   boolean: true if successful, false if failed

-- Example:
exports['hate-bank']:AddJobMoney("police", "job", 10000, "Fine revenue", "Court System")
```

```lua
-- Function: RemoveJobMoney(accountName, accountType, amount, description, sourceName)
-- Parameters:
--   accountName: The name of the account (usually the job name, e.g. "police")
--   accountType: The account type (usually "job")
--   amount: The amount of money to remove (must be positive)
--   description: (Optional) A description of the transaction
--   sourceName: (Optional) The name that will appear as the source of the transaction
-- Returns:
--   boolean: true if successful, false if failed (e.g., insufficient funds)

-- Example:
local success = exports['hate-bank']:RemoveJobMoney("mechanic", "job", 5000, "Parts purchase", "Auto Parts Store")
```

```lua
-- Function: GetJobBalance(accountName, accountType)
-- Parameters:
--   accountName: The name of the account (usually the job name, e.g. "police")
--   accountType: The account type (usually "job")
-- Returns:
--   number: The current balance of the business account

-- Example:
local balance = exports['hate-bank']:GetJobBalance("hornys", "job")
```

```lua
-- Function: HasJobAccountAccess(playerId, jobName)
-- Parameters:
--   playerId: The server ID of the player
--   jobName: The job name (e.g. "police")
-- Returns:
--   boolean: true if the player has access, false otherwise

-- Example:
local hasAccess = exports['hate-bank']:HasJobAccountAccess(source, "hornys")
```

## Security Notice

This script is protected by FiveM's escrow system. The client and server-side code is encrypted and cannot be modified.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hate-development.gitbook.io/hate-development-docs/banking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
