> For the complete documentation index, see [llms.txt](https://tgiann.gitbook.io/tgiann/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tgiann.gitbook.io/tgiann/scripts/tgiann-bank/exports.md).

# Exports

{% hint style="info" %}
Every `reason`, `name` and `note` that ends up in a history row accepts plain text or one text per language: `{ en = "Salary", tr = "Maaş" }`. Each player sees the text of their own language, falling back to `en` and then to the first text given.
{% endhint %}

## Server

### GetAccountData

Plain account table without class functions. With `viewerCid` the `perms` and `hideBalance` fields are filled for that character.

```lua
local account = exports["tgiann-bank"]:GetAccountData(iban, viewerCid)
```

#### Parameters

* **iban**: `string`
* **viewerCid?**: `string` character the data is built for

#### Returns

* `table?` `{ id, iban, type, owner, name, balance, cardColor, frozen, notifications, perms?, hideBalance? }`, nil when the account does not exist

***

### AccountExists

```lua
local exists = exports["tgiann-bank"]:AccountExists(iban)
```

#### Parameters

* **iban**: `string`

#### Returns

* `boolean`

***

### GetAccountBalance

Balance of any account. For a player's main account the framework bank balance is returned.

```lua
local balance = exports["tgiann-bank"]:GetAccountBalance(iban)
```

#### Parameters

* **iban**: `string`

#### Returns

* `number` `0` when the account does not exist

***

### AddMoney

Adds money to an account. When `reason` is given an `income` history row is written with that name and channel.

```lua
local newBalance = exports["tgiann-bank"]:AddMoney(iban, amount, reason, note, channel)

-- one text per language
exports["tgiann-bank"]:AddMoney(iban, 2500, { en = "Salary", tr = "Maaş" }, nil, "salary")
```

#### Parameters

* **iban**: `string`
* **amount**: `number`
* **reason?**: `string | table<string, string>` name shown in the history row (max 50 chars)
* **note?**: `string | table<string, string>` note shown in the history row (max 60 chars)
* **channel?**: `string` history channel from `configHistoryChannels.lua` or `RegisterHistoryChannel`, default `"system"`

#### Returns

* `number|false` new balance, `false` when the account does not exist or the amount is invalid

***

### RemoveMoney

Removes money from an account. When `reason` is given an `outcome` history row is written with that name and channel. Fails when the balance is too low.

```lua
local newBalance = exports["tgiann-bank"]:RemoveMoney(iban, amount, reason, note, channel)
```

#### Parameters

* **iban**: `string`
* **amount**: `number`
* **reason?**: `string | table<string, string>` name shown in the history row (max 50 chars)
* **note?**: `string | table<string, string>` note shown in the history row (max 60 chars)
* **channel?**: `string` history channel, default `"system"`

#### Returns

* `number|false` new balance, `false` when it could not be removed

***

### SetMoney

Sets the balance of a job, gang, shared or business account. Not available for a player's main account.

```lua
local newBalance = exports["tgiann-bank"]:SetMoney(iban, amount)
```

#### Parameters

* **iban**: `string`
* **amount**: `number`

#### Returns

* `number|false`

***

### TransferMoney

Script-to-script transfer between two accounts. No player permission check, frozen accounts still refuse. Both sides get a history row on the `transfer` channel with the other account's name, and the `transfer` / `balanceChanged` hooks fire as usual.

```lua
local success, message = exports["tgiann-bank"]:TransferMoney(fromIban, toIban, amount, name, note)
```

#### Parameters

* **fromIban**: `string`
* **toIban**: `string`
* **amount**: `number`
* **name?**: `string | table<string, string>` actor shown in both history rows (max 50 chars)
* **note?**: `string | table<string, string>` note shown in both history rows (max 60 chars)

#### Returns

* `boolean` success
* `string` lang key: `TRANSFER_SUCCESS`, `NO_ACCOUNT`, `SAME_IBAN`, `ACCOUNT_FROZEN`, `TARGET_ACCOUNT_FROZEN`, `INVALID_AMOUNT`, `NO_MONEY_ACCOUNT`, `NO_PERMISSION` (cancelled by a hook)

***

### AddHistory

Writes a history row without moving money (salary logs, fees paid elsewhere).

```lua
local success = exports["tgiann-bank"]:AddHistory(iban, historyType, amount, name, note, targetIban, channel)
```

#### Parameters

* **iban**: `string`
* **historyType**: `"deposit" | "withdraw" | "income" | "outcome"`
* **amount**: `number`
* **name?**: `string | table<string, string>`
* **note?**: `string | table<string, string>`
* **targetIban?**: `string`
* **channel?**: `string` history channel, default `"system"`

#### Returns

* `boolean`

***

### RegisterHistoryChannel

Adds a history channel (or replaces one with the same name) at runtime. History rows written with this channel show its icon and label on the receipt, in the ATM and in the tgiann-phone Bank app. Players that are online get it right away. Call it again when the bank restarts.

```lua
exports["tgiann-bank"]:RegisterHistoryChannel("lottery", {
    label = { en = "Lottery", tr = "Piyango" },
    icon = "gift",
    color = "#F5A524",
})

exports["tgiann-bank"]:AddMoney(iban, 500, { en = "Lottery win", tr = "Piyango kazancı" }, nil, "lottery")
```

#### Parameters

* **name**: `string` max 16 chars, letters, numbers, `_` and `-`
* **data**: `table`
  * **label**: `string | table<string, string>` lang key, plain text or one text per language (max 40 chars)
  * **icon?**: `string` one of `atm`, `transfer`, `invoice`, `system`, `salary`, `government`, `tax`, `fine`, `police`, `hospital`, `shop`, `vehicle`, `fuel`, `house`, `mechanic`, `casino`, `business`, `refund`, `food`, `taxi`, `gift`, `phone`, `job`, `crypto`
  * **color?**: `string` `#RRGGBB` icon color

#### Returns

* `boolean` `false` when the name or label is invalid

***

### GetHistoryChannels

Every history channel, config and registered ones. Lang key labels are expanded to one text per language, so other resources can show them in their own UI.

```lua
local channels = exports["tgiann-bank"]:GetHistoryChannels()
```

#### Returns

* `table<string, { label: string | table<string, string>, icon?: string, color?: string }>`

***

### IsAccountFrozen

```lua
local frozen = exports["tgiann-bank"]:IsAccountFrozen(iban)
```

#### Parameters

* **iban**: `string`

#### Returns

* `boolean`

***

### SetFrozen

Freezes or unfreezes an account. A frozen account refuses deposits, withdrawals, transfers and money requests in both directions. The card shows a frozen badge.

```lua
local result = exports["tgiann-bank"]:SetFrozen(iban, frozen)
```

#### Parameters

* **iban**: `string`
* **frozen**: `boolean`

#### Returns

* `table` `{ success: boolean, message: string, params?: table }`

***

### AdminSetBalance

Sets the balance of any account, including a player's main account (the difference is moved through the framework).

```lua
local result = exports["tgiann-bank"]:AdminSetBalance(iban, amount)
```

#### Parameters

* **iban**: `string`
* **amount**: `number`

#### Returns

* `table` `{ success: boolean, message: string, params?: table }`

***

### AdminAddMoney

Adds (positive) or removes (negative) money on any account.

```lua
local result = exports["tgiann-bank"]:AdminAddMoney(iban, amount)
```

#### Parameters

* **iban**: `string`
* **amount**: `number` negative removes

#### Returns

* `table` `{ success: boolean, message: string, params?: table }`

***

### AdminFindAccounts

Accounts of a character, or one account by IBAN.

```lua
local accounts = exports["tgiann-bank"]:AdminFindAccounts(query)
```

#### Parameters

* **query**: `string` citizen id or IBAN

#### Returns

* `table[]` account tables, empty when nothing matched

***

### HasAccountAccess

```lua
local hasAccess = exports["tgiann-bank"]:HasAccountAccess(citizenid, iban)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string`

#### Returns

* `boolean` whether the character can see the account

***

### GetPlayerAccounts

Every account the character can see (owner first). Business (player ownable) memberships are refreshed from tgiann-core on each call.

```lua
local accounts = exports["tgiann-bank"]:GetPlayerAccounts(citizenid)
```

#### Parameters

* **citizenid**: `string`

#### Returns

* `table[]` account tables with `perms` and `hideBalance` filled for that character

***

### GetMainIban

```lua
local iban = exports["tgiann-bank"]:GetMainIban(citizenid)
```

#### Parameters

* **citizenid**: `string`

#### Returns

* `string?` IBAN of the character's main account

***

### CanViewBalance

Whether the character is allowed to see the balance of the account (`can_view_balance` grade permission, business employees never can).

```lua
local canView = exports["tgiann-bank"]:CanViewBalance(citizenid, iban)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string`

#### Returns

* `boolean`

***

### ResolveIban

Turns what a player typed into an IBAN: an existing IBAN stays, a phone number resolves to the main account of the character whose phone last used that number (tgiann-phone).

```lua
local iban = exports["tgiann-bank"]:ResolveIban(target)
```

#### Parameters

* **target**: `string` IBAN or phone number

#### Returns

* `string?`

***

### GetHistory

History rows of an account for the character. Returns an empty list when the character may not see the balance.

```lua
local history = exports["tgiann-bank"]:GetHistory(citizenid, iban, period)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string`
* **period**: `"day" | "week" | "month" | "all"`

#### Returns

* `table[]?` nil without access. Each row:
  * **id**, **accountid**: `number`
  * **type**: `"deposit" | "withdraw" | "income" | "outcome"`
  * **amount**: `number`
  * **timestamp**: `number`
  * **targetIban?**: `string` other account
  * **targetName?**: `string` readable name of the other account
  * **name?**, **note?**: `string` text in the server language
  * **i18n?**: `string` JSON `{ name?, note? }` with one text per language when a script sent translations
  * **actor?**: `string` citizen id of the player who made the movement
  * **channel?**: `string` history channel
  * **location?**: `string` ATM label for ATM movements
  * **fee?**: `number` government tax and ATM company fee
  * **balance?**: `number` account balance right after the movement

***

### GetAccountNotifications

```lua
local notifications = exports["tgiann-bank"]:GetAccountNotifications(citizenid, iban)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string`

#### Returns

* `table[]?` pending money requests and bills of the account

***

### Transfer

Transfer as a character (permission, frozen and hook checks apply).

```lua
local result = exports["tgiann-bank"]:Transfer(citizenid, iban, target, amount, note)
```

#### Parameters

* **citizenid**: `string` acting character
* **iban**: `string` source account
* **target**: `string` IBAN or phone number
* **amount**: `number`
* **note?**: `string` max 60 chars, shown in both history rows

#### Returns

* `table` `{ success: boolean, message: string, params?: table, targetIban?: string }`

***

### AskMoney

Creates a money request from the character's account to another account.

```lua
local result = exports["tgiann-bank"]:AskMoney(citizenid, iban, target, amount)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string` account that should receive the money
* **target**: `string` IBAN or phone number of the account that should pay
* **amount**: `number`

#### Returns

* `table` `{ success: boolean, message: string, params?: table }`

***

### HandleNotification

Resolves a money request or bill.

```lua
local result = exports["tgiann-bank"]:HandleNotification(citizenid, id, action)
```

#### Parameters

* **citizenid**: `string`
* **id**: `number` notification id
* **action**: `"sendMoney" | "cancelWantsMoneyRequest" | "cancelAsk" | "payBill"`

#### Returns

* `table` `{ success: boolean, message: string, params?: table }`

***

### CreateAccount

Creates a new shared account for the character (limited by `config.playerMaxAccountLimit`, job / gang / business accounts do not count).

```lua
local result = exports["tgiann-bank"]:CreateAccount(citizenid)
```

#### Parameters

* **citizenid**: `string`

#### Returns

* `table` `{ success: boolean, message?: string, account?: table }`

***

### DeleteAccount

```lua
local result = exports["tgiann-bank"]:DeleteAccount(citizenid, iban)
```

#### Parameters

* **citizenid**: `string` must be the owner
* **iban**: `string`

#### Returns

* `table` `{ success: boolean, message: string }`

***

### LeaveSharedAccount

```lua
local result = exports["tgiann-bank"]:LeaveSharedAccount(citizenid, iban)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string`

#### Returns

* `table` `{ success: boolean, message: string }`

***

### RenameAccount

```lua
local result = exports["tgiann-bank"]:RenameAccount(citizenid, iban, name)
```

#### Parameters

* **citizenid**: `string` must be the owner
* **iban**: `string`
* **name**: `string` 3 to 20 chars

#### Returns

* `table` `{ success: boolean, message: string }`

***

### SetCardColor

Changes the card color of a player account. Job, gang and business cards take their color from the config or from their name.

```lua
local result = exports["tgiann-bank"]:SetCardColor(citizenid, iban, color)
```

#### Parameters

* **citizenid**: `string` must be the owner
* **iban**: `string`
* **color?**: `string` `#RRGGBB`, nil or `""` restores the default card

#### Returns

* `table` `{ success: boolean, message: string }`

***

### GetSharedUsers

```lua
local users = exports["tgiann-bank"]:GetSharedUsers(citizenid, iban)
```

#### Parameters

* **citizenid**: `string`
* **iban**: `string`

#### Returns

* `table[]?` `{ citizenid, name, perm }[]`

***

### AddSharedUser

Adds the owner of `target` (IBAN or phone number) as a shared user of the account.

```lua
local result = exports["tgiann-bank"]:AddSharedUser(citizenid, iban, target)
```

#### Parameters

* **citizenid**: `string` must be the owner
* **iban**: `string`
* **target**: `string` IBAN or phone number

#### Returns

* `table` `{ success: boolean, message: string, user?: table }`

***

### RemoveSharedUser

```lua
local result = exports["tgiann-bank"]:RemoveSharedUser(citizenid, iban, targetCitizenid)
```

#### Parameters

* **citizenid**: `string` must be the owner
* **iban**: `string`
* **targetCitizenid**: `string`

#### Returns

* `table` `{ success: boolean, message: string }`

***

### SetSharedUserPerm

```lua
local result = exports["tgiann-bank"]:SetSharedUserPerm(citizenid, iban, targetCitizenid, perm, value)
```

#### Parameters

* **citizenid**: `string` must be the owner
* **iban**: `string`
* **targetCitizenid**: `string`
* **perm**: `"can_withdraw" | "can_deposit" | "can_transfer" | "can_ask"`
* **value**: `boolean`

#### Returns

* `table` `{ success: boolean, message: string }`

***

### CreatePlayerAccount

Creates a shared account for a player by source.

```lua
local iban, account = exports["tgiann-bank"]:CreatePlayerAccount(source, iban, accountBalance, name)
```

#### Parameters

* **source**: `number`
* **iban?**: `string` generated when nil
* **accountBalance?**: `number` default `0`
* **name?**: `string`

#### Returns

* `string|false` new IBAN, `false` when the player or an account with that IBAN already exists
* `table?` account class

***

### CreateJobAccount

Registers a job account at runtime (same shape as `configJobAccounts.lua`).

```lua
exports["tgiann-bank"]:CreateJobAccount(jobName, accountBalance, iban, gradePerms, name, cardColor)
```

#### Parameters

* **jobName**: `string`
* **accountBalance**: `number`
* **iban?**: `string` defaults to the job name
* **gradePerms?**: `table<number, table<string, boolean>>` keys `can_withdraw`, `can_deposit`, `can_transfer`, `can_ask`, `can_view_balance`
* **name?**: `string` account name shown on the card
* **cardColor?**: `string` `#RRGGBB`

#### Returns

* `boolean`

***

### CreateGangAccount

Same as `CreateJobAccount` for gangs.

```lua
exports["tgiann-bank"]:CreateGangAccount(gangName, accountBalance, iban, gradePerms, name, cardColor)
```

#### Parameters

* **gangName**: `string`
* **accountBalance**: `number`
* **iban?**: `string`
* **gradePerms?**: `table<number, table<string, boolean>>`
* **name?**: `string`
* **cardColor?**: `string`

#### Returns

* `boolean`

***

### GetJobIbanFromName

```lua
local iban = exports["tgiann-bank"]:GetJobIbanFromName(jobName)
```

#### Parameters

* **jobName**: `string`

#### Returns

* `string|false`

***

### GetGangIbanFromName

```lua
local iban = exports["tgiann-bank"]:GetGangIbanFromName(gangName)
```

#### Parameters

* **gangName**: `string`

#### Returns

* `string|false`

***

### AddJobMoney / RemoveJobMoney / SetJobMoney / GetJobAccountBalance

Job helpers, resolve the IBAN from the job name and call the account function with the same name.

```lua
local newBalance = exports["tgiann-bank"]:AddJobMoney(jobName, amount)
local newBalance = exports["tgiann-bank"]:RemoveJobMoney(jobName, amount)
local newBalance = exports["tgiann-bank"]:SetJobMoney(jobName, amount)
local balance = exports["tgiann-bank"]:GetJobAccountBalance(jobName)
```

#### Parameters

* **jobName**: `string`
* **amount**: `number`

#### Returns

* `number|false` new balance, `false` when the job has no account

***

### AddGangMoney / RemoveGangMoney / SetGangMoney / GetGangAccountBalance

Gang helpers, same as the job helpers.

```lua
local newBalance = exports["tgiann-bank"]:AddGangMoney(gangName, amount)
local newBalance = exports["tgiann-bank"]:RemoveGangMoney(gangName, amount)
local newBalance = exports["tgiann-bank"]:SetGangMoney(gangName, amount)
local balance = exports["tgiann-bank"]:GetGangAccountBalance(gangName)
```

#### Parameters

* **gangName**: `string`
* **amount**: `number`

#### Returns

* `number|false`

***

### GetOwnableIban

IBAN of the bank account of a player ownable business (tgiann-core control panel `keyName`). Business accounts are created automatically for every bought business, see `config.ownableAccounts`.

```lua
local iban = exports["tgiann-bank"]:GetOwnableIban(keyName)
```

#### Parameters

* **keyName**: `string` control panel key name

#### Returns

* `string?` nil when the business is not bought, ignored by `config.ownableAccounts.ignoreResources` or the feature is off

***

### GetOwnableAccountBalance / AddOwnableMoney / RemoveOwnableMoney

Business helpers, same as the job helpers. `reason`, `note` and `channel` write a history row like `AddMoney` / `RemoveMoney`.

```lua
local balance = exports["tgiann-bank"]:GetOwnableAccountBalance(keyName)
local newBalance = exports["tgiann-bank"]:AddOwnableMoney(keyName, amount, reason, note, channel)
local newBalance = exports["tgiann-bank"]:RemoveOwnableMoney(keyName, amount, reason, note, channel)
```

#### Parameters

* **keyName**: `string`
* **amount**: `number`
* **reason?**: `string | table<string, string>`
* **note?**: `string | table<string, string>`
* **channel?**: `string` history channel, default `"system"`

#### Returns

* `number|false`

***

### GetAtmCooldown

Remaining ATM cooldown of a player, set by `SetAtmCooldown` (card hacking, robberies). A player on cooldown can not open ATMs.

```lua
local seconds = exports["tgiann-bank"]:GetAtmCooldown(source)
```

#### Parameters

* **source**: `number`

#### Returns

* `number` seconds, `0` when there is none

***

### SetAtmCooldown

Blocks the player from opening ATMs for the given time. Stored server-side, survives a relog.

```lua
exports["tgiann-bank"]:SetAtmCooldown(source, seconds)
```

#### Parameters

* **source**: `number`
* **seconds**: `number`

***

### RegisterHook / RemoveHooks

Event hooks, see the Hooks page.

## Client

### IsBankOpen

```lua
local isOpen = exports["tgiann-bank"]:IsBankOpen()
```

#### Returns

* `boolean` whether the ATM UI is open for the local player

***

### GetNearestAtmCoords

Coordinates of the closest ATM (props from `config.atmObject` and `config.atmCoords`).

```lua
local coords = exports["tgiann-bank"]:GetNearestAtmCoords()
```

#### Returns

* `vector3?` nil when no ATM is known yet

***

### GetAtmCooldown

```lua
local seconds = exports["tgiann-bank"]:GetAtmCooldown()
```

#### Returns

* `number` remaining seconds, `0` when there is none

***

### SetAtmCooldown

Asks the server to put the local player on ATM cooldown.

```lua
exports["tgiann-bank"]:SetAtmCooldown(seconds)
```

#### Parameters

* **seconds**: `number`

***

### BlipsIsOn

```lua
local isOn = exports["tgiann-bank"]:BlipsIsOn()
```

#### Returns

* `boolean`

***

### CreateAtmBlips

```lua
exports["tgiann-bank"]:CreateAtmBlips()
```

***

### DeleteAtmBlips

```lua
exports["tgiann-bank"]:DeleteAtmBlips()
```

***

### ToggleAtmBlips

```lua
exports["tgiann-bank"]:ToggleAtmBlips(showNotif)
```

#### Parameters

* **showNotif?**: `boolean` notify the player about the new state
