> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/koja-lib/api-reference/server-api/money.md).

# Money

Functions for reading and modifying a player's money on the server.

## getMoney

Get the amount of money a player has of a given type.

```lua
local amount = KOJA.Server.getMoney(source, mtype)
```

| Parameter | Type     | Description                                |
| --------- | -------- | ------------------------------------------ |
| `source`  | `number` | Player server ID                           |
| `mtype`   | `string` | Money type — `"cash"`, `"bank"`, `"black"` |

**Returns** `number`

## addMoney

Add money to a player's account.

```lua
local ok = KOJA.Server.addMoney(source, amount, mtype, reason)
```

| Parameter | Type      | Description                                |
| --------- | --------- | ------------------------------------------ |
| `source`  | `number`  | Player server ID                           |
| `amount`  | `number`  | Amount to add                              |
| `mtype`   | `string`  | Money type — `"cash"`, `"bank"`, `"black"` |
| `reason`  | `string?` | Reason (logged by some frameworks)         |

**Returns** `boolean`

## removeMoney

Remove money from a player's account.

```lua
local ok = KOJA.Server.removeMoney(source, amount, mtype, reason)
```

Same parameters as `addMoney`.

**Returns** `boolean`

## Money Types

| Value     | ESX                   | QBCore              |
| --------- | --------------------- | ------------------- |
| `"cash"`  | `money` account       | `cash` money type   |
| `"bank"`  | `bank` account        | `bank` money type   |
| `"black"` | `black_money` account | `crypto` money type |

## Examples

```lua
-- Read balances
local cash = KOJA.Server.getMoney(source, 'cash')
local bank = KOJA.Server.getMoney(source, 'bank')
print(('Cash: $%d | Bank: $%d'):format(cash, bank))

-- Pay out a reward
KOJA.Server.addMoney(source, 500, 'cash', 'job_reward')

-- Charge for a service
local price = 250
if KOJA.Server.getMoney(source, 'bank') < price then
    KOJA.Server.SendNotify({ source = source, type = 'error', desc = 'Not enough bank balance.' })
    return
end

KOJA.Server.removeMoney(source, price, 'bank', 'shop_purchase')
KOJA.Server.addInventoryItem(source, 'burger', 1)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.kojascripts.eu/koja-lib/api-reference/server-api/money.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.
