> For the complete documentation index, see [llms.txt](https://docs.t1ger.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.t1ger.net/resources/t1ger-money-wash/developer/hooks.md).

# Hooks

Server-sided hooks in server/hooks.lua

Each hook is an empty function in `server/hooks.lua`. The script calls it when something happens, and you add your own code inside it, for example to log to Discord, reward a player or trigger another resource. A hook that errors only prints a message to the console and never interrupts the script.

***

## OnBusinessPurchased

Called when a player successfully buys a business.

```lua
function OnBusinessPurchased(identifier, businessType, locationId, price)
end
```

**Parameters**

* `identifier` – `string` – The identifier of the new owner.
* `businessType` – `string` – The business type, for example `"coffee_shop"`.
* `locationId` – `integer` – The ID of the business's location.
* `price` – `integer` – The amount paid.

***

## OnBusinessAbandoned

Called when a player abandons their business. The owner gets no refund and all progress is lost.

```lua
function OnBusinessAbandoned(identifier, businessId, businessType, locationId)
end
```

**Parameters**

* `identifier` – `string` – The identifier of the former owner.
* `businessId` – `integer` – The business ID.
* `businessType` – `string` – The business type.
* `locationId` – `integer` – The ID of the business's location.

***

## OnBusinessTransferred

Called when a business is successfully transferred to another player.

```lua
function OnBusinessTransferred(fromIdentifier, toIdentifier, businessId, businessType, locationId)
end
```

**Parameters**

* `fromIdentifier` – `string` – The identifier of the previous owner.
* `toIdentifier` – `string` – The identifier of the new owner.
* `businessId` – `integer` – The business ID.
* `businessType` – `string` – The business type.
* `locationId` – `integer` – The ID of the business's location.

***

## OnStockOrderCompleted

Called when a stock delivery mission is completed successfully.

```lua
function OnStockOrderCompleted(identifier, businessId, businessType, unitsOrdered, unitsDelivered, cost)
end
```

**Parameters**

* `identifier` – `string` – The identifier of the business owner.
* `businessId` – `integer` – The business ID.
* `businessType` – `string` – The business type.
* `unitsOrdered` – `integer` – The units that were originally paid for.
* `unitsDelivered` – `integer` – The units actually delivered, after any cargo damage.
* `cost` – `integer` – The amount paid for the order.

***

## OnMoneyLaundered

Called when dirty cash has been laundered into a business's Safe. It never fires for a failed or retried save.

```lua
function OnMoneyLaundered(identifier, businessId, businessType, amount, coveredAmount, exposedAmount)
end
```

**Parameters**

* `identifier` – `string` – The identifier of the business owner.
* `businessId` – `integer` – The business ID.
* `businessType` – `string` – The business type.
* `amount` – `integer` – The gross dirty cash that was laundered.
* `coveredAmount` – `integer` – The part that landed as covered funds (backed by stock, safe from raids).
* `exposedAmount` – `integer` – The part that landed as exposed funds (can be seized in a raid).

***

## OnCashBagCreated

Called when the owner finishes counting a withdrawal and receives a cash bag.

```lua
function OnCashBagCreated(ownerIdentifier, bagId, businessId, amount, exposed)
end
```

**Parameters**

* `ownerIdentifier` – `string` – The identifier of the player who withdrew the bag.
* `bagId` – `integer` – The cash bag ID.
* `businessId` – `integer` – The business the money came from.
* `amount` – `integer` – The gross amount taken from the Safe.
* `exposed` – `integer` – The part of the amount that was exposed cash, which decides the chance of the deposit being flagged.

***

## OnCashBagDeposited

Called when a deposited cash bag clears into the depositor's bank.

```lua
function OnCashBagDeposited(depositorIdentifier, ownerIdentifier, businessId, gross, net, bagId)
end
```

**Parameters**

* `depositorIdentifier` – `string` – The identifier of the player who deposited the bag and got the money.
* `ownerIdentifier` – `string` – The identifier of the player who withdrew the bag (the same player, unless the bag was stolen).
* `businessId` – `integer` – The business the money came from.
* `gross` – `integer` – The amount taken from the Safe.
* `net` – `integer` – The amount paid into the bank after tax.
* `bagId` – `integer` – The cash bag ID.

***

## OnCashBagConfiscated

Called when police confiscate a flagged cash bag deposit. The money is gone, so this is only a notification point, for example to reward the officer or log to Discord.

```lua
function OnCashBagConfiscated(officerIdentifier, depositorIdentifier, ownerIdentifier, businessId, amount, bagId)
end
```

**Parameters**

* `officerIdentifier` – `string` – The identifier of the officer.
* `depositorIdentifier` – `string` – The identifier of the player who made the deposit.
* `ownerIdentifier` – `string` – The identifier of the player who withdrew the bag.
* `businessId` – `integer` – The business the money came from.
* `amount` – `integer` – The gross amount that was seized.
* `bagId` – `integer` – The cash bag ID.

***

## OnCashBagLost

Called for each cash bag that was still being deposited when the server restarted. The bag is gone and the money was not paid out. The row stays in `moneywash_cashbags` with the state `lost`, so you can log it or refund the depositor yourself.

```lua
function OnCashBagLost(depositorIdentifier, ownerIdentifier, businessId, amount, bagId)
end
```

**Parameters**

* `depositorIdentifier` – `string` – The identifier of the player who deposited the bag.
* `ownerIdentifier` – `string` – The identifier of the player who withdrew the bag.
* `businessId` – `integer` – The business the money came from.
* `amount` – `integer` – The gross amount.
* `bagId` – `integer` – The cash bag ID.

***

## OnBusinessRaided

Called when a raid finishes and the exposed cash in the Safe has been seized. The money is gone, so this is only a notification point, for example to reward the officer or log to Discord.

```lua
function OnBusinessRaided(officerIdentifier, ownerIdentifier, businessId, seizedAmount)
end
```

**Parameters**

* `officerIdentifier` – `string` – The identifier of the officer.
* `ownerIdentifier` – `string` – The identifier of the business owner.
* `businessId` – `integer` – The business ID.
* `seizedAmount` – `integer` – The exposed cash that was seized.

***

## OnBusinessBooksReviewed

Called when an owner delivers a sealed review folder and the accountant applies it. It only fires on a completed delivery, never on a cancel or a timeout.

```lua
function OnBusinessBooksReviewed(identifier, businessId, reduction, fee, suspicionBefore, suspicionAfter, receiptsUsed)
end
```

**Parameters**

* `identifier` – `string` – The identifier of the business owner.
* `businessId` – `integer` – The business ID.
* `reduction` – `number` – The suspicion points removed.
* `fee` – `integer` – The fee paid from the bank.
* `suspicionBefore` – `number` – The suspicion before the review.
* `suspicionAfter` – `number` – The suspicion after the review.
* `receiptsUsed` – `integer` – The number of receipts consumed.

***

## OnContractShiftEnded

Called when a launder contract shift ends, for any reason.

```lua
function OnContractShiftEnded(identifier, reason, handovers, cleaned, paid)
end
```

**Parameters**

* `identifier` – `string` – The player's identifier.
* `reason` – `string` – Why the shift ended: `"player"` (the player ended it), `"died"`, `"dropped"` (the player disconnected), `"stopped"` (the resource stopped), `"missed"` (a contact was kept waiting), `"no_dirty_cash"` or `"switched"` (another character is now on the source).
* `handovers` – `integer` – The completed handovers.
* `cleaned` – `integer` – The dirty cash handed over.
* `paid` – `integer` – The clean money paid out.

***

## OnContractHandover

Called when a launder contract handover is completed and paid.

```lua
function OnContractHandover(identifier, dirtyAmount, paidAmount, handovers)
end
```

**Parameters**

* `identifier` – `string` – The player's identifier.
* `dirtyAmount` – `integer` – The dirty cash handed over.
* `paidAmount` – `integer` – The clean money paid out, after the contact's cut.
* `handovers` – `integer` – The completed handovers this shift, including this one.

***

## OnContractBetrayed

Called when a launder contract contact betrays the player and keeps the cash. The player can still recover the cash until the betrayal time is up.

```lua
function OnContractBetrayed(identifier, dirtyAmount)
end
```

**Parameters**

* `identifier` – `string` – The player's identifier.
* `dirtyAmount` – `integer` – The dirty cash the contact ran off with.
