# qb-weed: plant growth and persistence

`qb-weed` manages persistent house plants, growth stages, feeding and harvesting. The implementation is pinned to [commit 318b5b1](https://github.com/qbcore-fivem/qb-weed/tree/318b5b1532191b8a6163f1ce53d4f8c28e7c0712).

## Install and data storage

- Start `qb-core`, `oxmysql` and any inventory/housing dependencies used by your installation before `qb-weed`.
- Import the official [`qb-weed.sql`](https://github.com/qbcore-fivem/qb-weed/blob/318b5b1532191b8a6163f1ce53d4f8c28e7c0712/qb-weed.sql) into a **backup/staging database** and check that `house_plants` exists.
- Verify house identifier and plant data consistency with your own housing resource. Do not treat client-reported building names as proof of access.

## Configuration uses `QBWeed`, not `Config`

The [upstream config](https://github.com/qbcore-fivem/qb-weed/blob/318b5b1532191b8a6163f1ce53d4f8c28e7c0712/config.lua) defines the top-level `QBWeed` table:

| Key | Meaning |
| --- | --- |
| `QBWeed.Progress.min` / `max` | Amount of growth progress per tick |
| `QBWeed.GrowthTick` | Minutes between growth updates (default `9.6`) |
| `QBWeed.FoodUsage` | Plant nutrition used per tick |
| `QBWeed.ShowStages` | Whether to display stage changes |
| `QBWeed.StageLabels` | Visible lifecycle labels |
| `QBWeed.DefaultProps` | GTA prop models for plant stages |
| `QBWeed.Plants` | Plant types including `ogkush` and `amnesia` |

~~~lua filename="config.lua"
QBWeed.Progress = { min = 1, max = 3 }
QBWeed.GrowthTick = 9.6
QBWeed.FoodUsage = 1
~~~

These are entries to modify in the original config, **not** a complete replacement file.

## Source event map

The [server source](https://github.com/qbcore-fivem/qb-weed/blob/318b5b1532191b8a6163f1ce53d4f8c28e7c0712/server.lua) registers callback `qb-weed:server:getBuildingPlants` plus events `placePlant`, `removeDeathPlant`, `removeSeed`, `harvestPlant` and `foodPlant` under the `qb-weed:server:` prefix.

These events are internal to the gameplay script. In particular, `placePlant` accepts client-supplied coordinates, plant type and building name and inserts a database row; it does not independently establish ownership of that house in the reviewed handler. Production usage needs a validated server-side placement and harvest authorization boundary.

## Troubleshooting

| Symptom | First check |
| --- | --- |
| Plants disappear on restart | Correct `house_plants` table and database connection |
| Growth never advances | Server timer, `QBWeed.GrowthTick` and plant stage data |
| Plant model doesn't appear | `DefaultProps` and client streaming errors |
| Plants appear in someone else's house | House identifier, caller authorization and client-submitted building |
| Missing seeds or harvest items | QBCore shared items, `qb-inventory` and event errors |

## Update checklist

1. Pin the source version and back up `house_plants` before any schema migration.
2. Test planting, growth, watering, harvest and reconnect with different house owners.
3. Enforce server-side house access, permitted item types, positions and cooldowns.
4. Validate failures and item removal/addition against your inventory version.

## Sources

[Repository](https://github.com/qbcore-fivem/qb-weed/tree/318b5b1532191b8a6163f1ce53d4f8c28e7c0712) · [SQL](https://github.com/qbcore-fivem/qb-weed/blob/318b5b1532191b8a6163f1ce53d4f8c28e7c0712/qb-weed.sql) · [Config](https://github.com/qbcore-fivem/qb-weed/blob/318b5b1532191b8a6163f1ce53d4f8c28e7c0712/config.lua) · [Server](https://github.com/qbcore-fivem/qb-weed/blob/318b5b1532191b8a6163f1ce53d4f8c28e7c0712/server.lua)
