> For the complete documentation index, see [llms.txt](https://tyrix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tyrix.gitbook.io/docs/script-resources/tyrix-business/home-delivery.md).

# Home Delivery

Mission-based delivery flow tied to crafting stations. Admins place delivery missions; workers accept them at the start point, craft the order, and hand it off to a randomly-selected destination ped.

## Admin: creating a mission

From the Business Manager's Home Delivery tab, place one or more **delivery missions** per business. Each mission has:

* **Start point** - the placeable target zone workers interact with.
* **Payout per item** - flat rate; the mission's total payout scales with the order size.
* **Item / quantity ranges** - min / max item count and per-item quantity range. Every mission spawn rolls within these ranges.
* **Crafting stations** - the pool of stations whose crafted outputs are eligible for this mission. Only recipes from these stations appear in the order.

## Worker flow

1. Interact with a mission start point → **Start Home Delivery**.
2. The **DeliveryPanel** opens and lists the order. Per-item counts (`n / N`) update live as items enter the worker's inventory.
3. Craft (or otherwise acquire) the ordered items.
4. Once every row shows `N / N`, the start-point target grows a **Drop Off Delivery** option.
5. Drop Off pins a destination on the GPS. Drive there.
6. The handover ped spawns when you get within `Config.Delivery.PedSpawnDistance` (default 30 m).
7. Interact with the ped → **Hand Over Delivery**. A brief progress-bar animation plays. Server consumes the items + pays out atomically.

## Live inventory tracking

The panel tracks each ordered item via `ox_inventory:updateInventory` (instant update whenever the local inventory changes) with a **2-second backstop poller** in case an event tick is dropped. The polling thread only runs while a delivery is active — no idle loops when nothing's going on.

**Items packed inside a `business_box` count.** Big orders that would exceed the inventory weight limit can be packed into a carried box; the server sums loose inventory + every carried box stash when computing per-item totals. See `getCarriedBoxes` on the [Sibling Integration](/docs/script-resources/tyrix-business/integration.md) page.

## Server-side gating

Every step re-validates on the server:

* **Drop Off** - client UI blocks the prompt unless every item is acquired, but server also re-checks. A modded client can't skip ahead.
* **Handover** - the ped's target option runs a distance check + full inventory re-verify before consuming items.
* **Payout** - money moves either to the worker or the business account based on `Config.Delivery.Payment.Recipient`.

## Concurrency + cooldown

* **Per-player cooldown** - `Config.Delivery.Cooldown` seconds between successful deliveries (default 60 s).
* **Per-business cap** - `Config.Delivery.MaxConcurrentPerBusiness` limits how many workers of the same business can have active deliveries simultaneously (default 2).

## Config

```lua
Config.Delivery = {
    Cooldown                 = 60,   -- per-player seconds between successful deliveries
    MaxConcurrentPerBusiness = 2,
    HandoverDistance         = 3.0,
    PedSpawnDistance         = 30.0,
    Payment = {
        Recipient       = 'employee',  -- 'employee' or 'business'
        EmployeeAccount = 'cash',      -- 'cash' or 'bank'
    },
    DeliveryLocations = { --[[ vec4(x, y, z, w) entries ]] },
    DeliveryPedModels = { --[[ ped hash names ]] },
}
```

## Driving the panel from a sibling resource

Other resources (e.g. `tyrix_droply`) can drive the same DeliveryPanel via client exports without touching tyrix\_business's own delivery flow. See [Sibling Integration → Client exports](/docs/script-resources/tyrix-business/integration.md).
