Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OpenRP.Framework is the open-source (LGPL v3) gameplay library behind Open Rolep
- [Accounts](features/accounts.md): register, log in, one login per account
- [AccountSettings](features/account-settings.md): chat toggles and `/settings`
- [Actors](features/actors.md): non-player characters in the world, created and edited in-game with `/editactors`
- [Banking](features/banking.md): banks, accounts with OBANs, AI bank tellers, `/bank` and `/editbanks`
- [Banking](features/banking.md): banks, accounts with OBANs, AI bank tellers, debit cards and ATMs, `/bank`, `/atm` and `/editbanks`
- [ActorConversations](features/actor-conversations.md): AI conversations between actors
- [ActorRoleplay](features/actor-roleplay.md): AI actors that answer players' /me, /do and /say
- [Admins](features/admins.md): admin and tester commands
Expand All @@ -48,6 +48,7 @@ OpenRP.Framework is the open-source (LGPL v3) gameplay library behind Open Rolep
- [Jurisdictions](features/jurisdictions.md): countries and cities with tags, currency, government, tax registrations and settings; `/editjurisdictions` and `/government`
- [MainMenu](features/main-menu.md): what you see after connecting
- [Maps](features/maps.md): saved maps of objects, built in-game with `/editmaps` and loaded at startup
- [Payments](features/payments.md): one way for features to take cash or card payments into a bank account
- [Permissions](features/permissions.md): see the Permissions guide
- [Phones](features/phones.md): 1992-style mobile phones: calls, texts, phone book, call log
- [Players](features/players.md): find a player's account and character
Expand Down
2 changes: 2 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ All player commands of the Framework, grouped as in `/help`. `[argument]` is req

| Command | Groups | Description | Feature |
|---|---|---|---|
| `/atm` | Default | Use the ATM you're standing at, with a debit card. | [Banking](features/banking/cards-and-atms.md) |
| `/bank` | Default | Open the bank menu at the teller you're standing at. | [Banking](features/banking.md) |

## Character
Expand Down Expand Up @@ -212,6 +213,7 @@ All player commands of the Framework, grouped as in `/help`. `[argument]` is req
| `/spawnveh [model] <first color> <second color>` | Admin, Tester | Spawn a vehicle. Use /spawnveh followed by the vehicle name or ID to generate a new vehicle for your use. | [Admins](features/admins.md) |
| `/spawnvehicle [model] <first color> <second color>` | Admin, Tester | Spawn a vehicle. Use /sv followed by the vehicle name or ID to generate a new vehicle for your use. | [Admins](features/admins.md) |
| `/sv [model] <first color> <second color>` | Admin, Tester | Spawn a vehicle. Use /sv followed by the vehicle name or ID to generate a new vehicle for your use. | [Admins](features/admins.md) |
| `/testpayment [amount] [OBAN]` | Admin, Tester | Ask yourself to pay an amount into a bank account, to test cash and card payments. | [Payments](features/payments.md) |

## Vehicles > General

Expand Down
9 changes: 6 additions & 3 deletions docs/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ See [Radios](features/radios.md).
| `Banks` (`BankModel`) | `Name` (32), `Code` (4, unique), `JurisdictionId` → jurisdictions (restrict), `RunByFactionId` → factions (set null), `MonthlyFee` decimal(18,2) | The code and the jurisdiction's tag are part of every OBAN |
| `BankAccounts` (`BankAccountModel`) | `Oban` (18, unique), `BankId` (restrict), `CurrencyId` (restrict), `Balance` decimal(18,2), `OwnerType` (Character, Faction, Property, Bank), `OwnerId`, `Name` (32), `ClosedAt`, `NextFeeAt` | The balance only changes through single updates. Owner type Bank is the bank's own account, without a fee |
| `BankAccountAccess` (`BankAccountAccessModel`) | `BankAccountId` (cascade), `CharacterId` (cascade), `Level` (View, Full) | Unique per account + character |
| `BankTransactions` (`BankTransactionModel`) | `BankAccountId` (cascade), `Amount` (signed), `BalanceAfter`, `Type`, `OtherOban`, `CharacterId` (set null), `CreatedOn` | An account's history |
| `BankTransactions` (`BankTransactionModel`) | `BankAccountId` (cascade), `Amount` (signed), `BalanceAfter`, `Type`, `OtherOban`, `CharacterId` (set null), `BankCardId` (set null), `Description` (64), `CreatedOn` | An account's history. `BankCardId` marks ATM and card use; the ATM limit adds up a card's withdrawals by it |
| `BankBranches` (`BankBranchModel`) | `BankId` (cascade), `PropertyId` (cascade, unique) | Tellers only work inside their bank's branches |
| `BankTellers` (`BankTellerModel`) | `ActorId` (cascade, unique), `BankId` (cascade) | |
| `BankCards` (`BankCardModel`) | `BankAccountId` (cascade), `CharacterId` (cascade), `Digits` (4), `Name` (32), `PinHash` (BCrypt), `WrongPinAttempts`, `BlockedAt`, `CancelledAt` | A [debit card](features/banking/cards-and-atms.md); its item stores `[BANK_CARD_ID=n]` |
| `BankPendingDeposits` (`BankPendingDepositModel`) | `BankAccountId` (restrict), `BankCardId` (set null), `CharacterId` (set null), `Amount`, `CreditAt`, `CreditedAt`, `AtmX`, `AtmY`, `AtmZ`, `AtmInterior`, `AtmVirtualWorld` | Cash put into an ATM, credited at `CreditAt`; the ATM's position says where the cash sits until then |

See [Banking](features/banking.md).

Expand Down Expand Up @@ -150,7 +152,7 @@ The item types (definitions), not the items players own.
| `KeepOnDeath`, `CanDrop`, `CanDestroy`, `Stackable` | bool | |
| `DropModelId` | int? | Object model shown when dropped |

The Framework seeds 67 items:
The Framework seeds 68 items:
- a uniform (skin);
- a wallet;
- the bills and coins of the San Andreas Dollar and the Caeroyna Ruble;
Expand All @@ -160,7 +162,8 @@ The Framework seeds 67 items:
- twelve fish species;
- a mobile phone (item 49, `UseType` Phone). Each phone item points to its row in `Phones` with `[PHONE_ID=x]`;
- a handheld radio (item 50, `UseType` Radio), pointing to its row in `Radios` with `[RADIO_ID=x]`, and a radio earpiece (item 51);
- fishing gear (rod 52, bait 53, net 54), junk (55 to 57), treasures (58 to 61), four net-only fish (62 to 65) and two small saltwater fish (66 and 67).
- fishing gear (rod 52, bait 53, net 54), junk (55 to 57), treasures (58 to 61), four net-only fish (62 to 65) and two small saltwater fish (66 and 67);
- a debit card (item 68, `UseType` BankCard), pointing to its row in `BankCards` with `[BANK_CARD_ID=x]`.

### `Inventories` (`InventoryModel`)
`Name`, `MaxWeight` (grams, null = unlimited). Seeded: "World Inventory", which holds items lying on the ground.
Expand Down
13 changes: 8 additions & 5 deletions docs/features/banking.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Banking

Banks hold accounts, and each account has its own OBAN (Open Bank Account Number), which others need to send it money. Players do their banking at a bank: they talk to an AI teller, who opens the right form for them, or use `/bank` at the counter.
Banks hold accounts, and each account has its own OBAN (Open Bank Account Number), which others need to send it money. Players do their banking at a bank: they talk to an AI teller, who opens the right form for them, or use `/bank` at the counter. Away from the bank, a [debit card](banking/cards-and-atms.md) works at ATMs and for [payments](payments.md).

## How to use it

| Command | Groups | Does |
|---|---|---|
| `/bank` | Default | Opens the bank menu at the teller you're standing at |
| `/atm` | Default | Uses the ATM you're standing at, with a debit card. See [Debit cards and ATMs](banking/cards-and-atms.md) |
| `/editbanks` | Admin | Banks, their fee, branches, tellers and property accounts, and looking up an OBAN. See [Tellers](banking/tellers.md) |

**Talking to a teller** opens the matching form:
Expand All @@ -19,6 +20,7 @@ Banks hold accounts, and each account has its own OBAN (Open Bank Account Number
| "I want to wire money to someone" | Transfer |
| "What's my balance?" | Your account, or the list when you have several |
| "My brother needs access" | Who has access |
| "I lost my card" | Debit card |
| "I want to close my account" | Close the account |
| "Show me everything" | The full bank menu |

Expand Down Expand Up @@ -54,7 +56,7 @@ A bank's city can be annexed or become independent ("Lies in" in `/editjurisdict

## Known limitations

- **No ATMs, cheques, cards, interest or loans.**
- **No cheques, interest or loans.**
- **Local currency only,** and no currency exchange.
- **Property accounts** are opened by admins, because properties have no owners yet.
- **No payroll** or automatic payments.
Expand All @@ -66,15 +68,16 @@ A bank's city can be annexed or become independent ("Lies in" in `/editjurisdict
- `IBankService`: banks, branches and tellers;
- `IBankAccountService`: access rules, opening and closing, house accounts per currency (`GetOrOpenHouseAccount`), access lists, history;
- `BankJurisdictionGuard`: keeps a bank's jurisdiction from being deleted (an `IJurisdictionDeletionGuard`);
- `IBankTransactionService`: deposit, withdraw, transfer and the monthly fees;
- `IBankTransactionService`: deposit, withdraw, transfer, card and cash payments, and the monthly fees;
- `IBankCardService` and `IAtmService`: see [Debit cards and ATMs](banking/cards-and-atms.md#deep-dive);
- `ITellerService`: whether a teller can serve a customer right now;
- `IBankEditorService`: `/editbanks`;
- `IBankDialogService`: the menus.
- **Database:** `IBankingDatabase` gives each operation a fresh database context. Reads use `AsNoTracking`, and money moves with `ExecuteUpdate` inside a transaction (`UPDATE … SET Balance = Balance - x WHERE … AND Balance - x >= 0`).
- **Database:** `IBankingDatabase` gives each operation a fresh database context. Every balance change goes through `Helpers/BankLedger` (`Credit`, `Debit`), which also writes the history line. Reads use `AsNoTracking`, and money moves with `ExecuteUpdate` inside a transaction (`UPDATE … SET Balance = Balance - x WHERE … AND Balance - x >= 0`).
- **Transactions** go through `UseInTransaction`, which runs them in EF's execution strategy. **Why:** a host whose connection retries on errors (`EnableRetryOnFailure`) refuses transactions opened directly; this way a dropped connection retries the whole transaction.
- **Deposits** take the cash first. If crediting fails for any reason, the cash is handed back.
- **The teller's actions:** registered with `AddActorAction` (see [ActorRoleplay](actor-roleplay.md#actions)), one per form, each needing its own actor permission.
- **Fees:** `BankingSystem` runs every hour. Each fee is claimed by moving the account's `NextFeeAt` in one statement, so two servers never charge it twice.
- **Tables:** [Banking](../database.md#banking).

Want more? → [Accounts](banking/accounts.md) · [Tellers](banking/tellers.md) · [Currencies](currencies.md)
Want more? → [Accounts](banking/accounts.md) · [Tellers](banking/tellers.md) · [Debit cards and ATMs](banking/cards-and-atms.md) · [Payments](payments.md) · [Currencies](currencies.md)
58 changes: 58 additions & 0 deletions docs/features/banking/cards-and-atms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Debit cards and ATMs

A debit card is an item that lets whoever holds it, and knows its 4-digit PIN, use one bank account: at ATMs and to [pay](../payments.md). The bank issues it at the teller.

## How to use it

| Where | What |
|---|---|
| Teller, account menu: **Debit card** | Order a card (an optional name, then the PIN twice), rename it, change the PIN, block it, unblock it, or order a new one |
| `/atm` within 2 units of an ATM | Choose a card if you carry several, type the PIN, then **Balance**, **Withdraw cash** or **Deposit cash** |
| Inventory, **Use** on a card | At an ATM: the ATM with that card. Elsewhere: the card's details and **Rename the card** |

**In the inventory** a card shows its bank, account and digits, so you can tell them apart: "SAB debit card: Savings ...4821". A named card puts its name first: "Groceries (SAB debit card: Savings ...4821)". "Blocked", "Cancelled" or "Account closed" shows under Extra Information.

## The rules

| Rule | Value |
|---|---|
| Cards per account per character | One working card; ordering a new one cancels the old one for good |
| Who can use a card | Whoever holds it and knows the PIN. The owner also needs full access to the account |
| Wrong PINs | 3 in a row block the card; the bank unblocks it |
| ATM withdrawals | At most 1,000 in the account's currency per card in any 24 hours |
| ATM deposits | The cash is taken at once and reaches the account **2 hours** later. At a teller it's there at once |
| Card names | Optional, at most 32 characters, no `{ }`, tabs or line breaks; anyone holding the card may rename it |

- **Why a card item with a PIN:** cards can be stolen and PINs overheard, which is roleplay. A stolen card still needs the PIN.
- **Why ATM deposits wait 2 hours:** like a 1990s envelope deposit, the money sits in the machine until the bank collects it. That gives cash in an ATM a place and a time, so ATMs can be robbed later.
- **Why a withdrawal limit:** a stolen card with an overheard PIN can't empty an account at once.
- **Taking someone's access away** blocks their cards for that account.
- **Closing an account** is refused while an ATM deposit is still on its way to it.

## ATMs

Every placed [map object](../maps.md) of model **2942** (`kmb_atm1`) is an ATM. Mappers place them with `/editmaps`; there's no ATM list to keep up.

**Why only placed objects:** GTA SA doesn't place `kmb_atm1` in the world itself, and its other ATM models (`kmb_atm2`, `kmb_atm3`) are broken variants. A separate list of ATMs would drift from the maps.

An ATM works in the object's interior and virtual world (or all of them, when the object is set to -1).

## Known limitations

- **ATMs belong to no bank,** so there's no fee for using another bank's ATM.
- **A stolen faction card:** when someone other than the owner uses a card, the owner's faction membership isn't checked, only that the card isn't blocked.
- **Cash and the bank aren't saved together:** the bank side is written at once, the wallet within 60 seconds, as at the teller.

## Deep dive

- **Services:**
- `IBankCardService`: issuing (the card row, then the item with `[BANK_CARD_ID=n]`, saved at once), PINs, blocking, names, `GetUseError`;
- `IAtmService`: finding ATMs, withdrawals within the limit, pending deposits, `CreditDueDeposits`;
- `BankCardNameProvider`: the card's inventory name (an `IInventoryItemNameProvider`, see [Inventories](../inventories.md#deep-dive));
- `AtmMapObjectSpawnHandler`: puts an `Atm` component on each spawned ATM object.
- **PINs** are hashed with BCrypt, like passwords. Hashing and checking run on a worker thread, so the server doesn't wait.
- **The limit** adds up the card's withdrawals of the last 24 hours (`BankTransactions.BankCardId`) in the same transaction as the debit. It locks the card row first, so two withdrawals with one card, even on two servers, can't both pass it.
- **Pending deposits:** `BankingSystem` runs every minute. Each due deposit is claimed by setting `CreditedAt` in the same transaction as the credit, so two servers never credit it twice. The row keeps the ATM's position, interior and world.
- **Tables:** [`BankCards`, `BankPendingDeposits`](../../database.md#banking).

Want more? → [Banking](../banking.md) · [Payments](../payments.md) · [Tellers](tellers.md)
1 change: 1 addition & 0 deletions docs/features/banking/tellers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ A teller is an AI actor that works for a bank, stands inside one of its branches
| `bank.withdraw` | pay out withdrawals |
| `bank.transfer` | make transfers |
| `bank.manage_access` | change who has access |
| `bank.cards` | issue, block and unblock [debit cards](cards-and-atms.md), and change their PIN |
| `bank.close_account` | close accounts |

An actor has no permissions by default.
Expand Down
2 changes: 1 addition & 1 deletion docs/features/currencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Money is physical: bills and coins, carried as items in your wallet, or loose in

## Known limitations

- **No card payments.** Bank accounts exist (see [Banking](banking.md)), but shops can't take payment from them yet.
- **Paying shops and fees** goes through [Payments](payments.md), with cash or a debit card; no feature uses it yet.
- **USD has no bills seeded,** so it can't be held.
- **Cancelling.** A payment is only cancelled by a disconnect or an error. Bills already handed over stay with the receiver.

Expand Down
3 changes: 2 additions & 1 deletion docs/features/inventories.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Picking an item offers, depending on the item:

1. **Weight.** An item's weight is its weight × amount, plus the contents if it holds an inventory. New characters get 10 kg. A stack can have its own weight, such as a caught fish. It keeps that weight and its remaining uses when it's moved or dropped.
2. **Stacking.** Stackable items join a matching stack when their extra data matches.
3. **Flags.** Each stack has extra data, such as `DEFAULT_WALLET` (where money goes), `WEARING` (the worn outfit) or the vehicle id of a key.
3. **Flags.** Each stack has extra data, such as `DEFAULT_WALLET` (where money goes), `WEARING` (the worn outfit), the vehicle id of a key or the card id of a debit card.

## Known limitations

Expand All @@ -38,6 +38,7 @@ Picking an item offers, depending on the item:
- `InventoryItem`: `Transfer`, `GetItemInventory`, `GetVehicleId`, `GetSkinModelId`, …;
- `InventoryOpened`, while the dialog is open.
- **Extra data:** `Helpers/ItemAdditionalData` parses and compares the key/value text. "Personalised" keys don't stop stacking.
- **Names of their own:** an `IInventoryItemNameProvider`, registered with `AddInventoryItemNameProvider<T>()`, gives the items it handles their own name and Extra Information in the inventory, such as a debit card showing its account. Other items show their item type's name. **Why:** the name can come from data another feature owns, such as an account name, which can't be stored in the item's extra data.
- **Services:**
- `IInventoryManager`: `CreateInventory` and `LoadInventory`;
- `IInventoryItemManager`;
Expand Down
6 changes: 4 additions & 2 deletions docs/features/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ The item types that everything in an [inventory](inventories.md) is made of, suc
| `Phone` | A [mobile phone](phones.md) |
| `Radio` | A [handheld radio](radios.md) |
| `RadioEarpiece` | Lets a radio's carrier listen without the people around them hearing it |
| `BankCard` | A [debit card](banking/cards-and-atms.md) for one bank account |

**Seeded items (67):**
**Seeded items (68):**
- a uniform;
- a wallet;
- the SAD and CRU bills and coins;
Expand All @@ -34,7 +35,8 @@ The item types that everything in an [inventory](inventories.md) is made of, suc
- [fishing](fishing.md) gear: a rod (52), bait (53) and a net (54);
- fishing junk (55 to 57) and treasures (58 to 61);
- four net-only fish (62 to 65);
- two small saltwater fish: a sardine (66) and a mackerel (67).
- two small saltwater fish: a sardine (66) and a mackerel (67);
- a debit card (68).

Some code uses these ids, so don't renumber them.

Expand Down
Loading
Loading