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

# Igris Farming

<figure><img src="https://2862342791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFnkzyjlqOP6UGw1GyN62%2Fuploads%2FdfA0xzzB75Vt5gzury8w%2FFarming.png?alt=media&amp;token=d2ad8e3f-de1a-47b2-bc79-13b91b8d4819" alt=""><figcaption></figcaption></figure>

igris\_farming is a farming system for RedM VORP servers. Players plant seeds, water and fertilize them, then harvest the crops. 25 plants are configured out of the box, and plants are saved in the database so they survive restarts.

| Requirement                           | Status   | Notes                                           |
| ------------------------------------- | -------- | ----------------------------------------------- |
| RedM server (cerulean, rdr3, Lua 5.4) | Required |                                                 |
| vorp\_core                            | Required | Characters, jobs, notifications, callbacks      |
| vorp\_character                       | Required | Listed in the manifest dependencies             |
| vorp\_inventory                       | Required | Usable seeds, items, tool durability (metadata) |
| oxmysql                               | Required | Database access (`@oxmysql/lib/MySQL.lua`)      |
| Discord webhook URL                   | Optional | Planting and harvest logs                       |

`configs/*.lua` and `languages/*.lua` are left open (escrow\_ignore), so you can edit every setting and translation. The rest of the code is protected by Tebex escrow.

### Installation

Installation takes about ten minutes: copy the folder, import two SQL files, add the watering cans, then set your jobs and language.

1. Download the resource from your Tebex / CFX Portal account (Keymaster → Granted Assets).
2. Place the `igris_farming` folder in your `resources` directory. Do not rename it.
3. Import `sql/install.sql` into your database. It creates the `igris_farming` table that stores planted crops.
4. Import `sql/items.sql` once. It adds 55 items: the hoe, soil, 25 seeds, 25 harvest items and 3 fertilizers.
5. If some items already exist on your server, delete their lines before importing, or the import will fail on duplicates.
6. Labels are in French by default (for example `Graine - Ble`). Rename them in the file or in your `items` table if needed.
7. Default limits are 1 for the hoe and 50 for everything else. Adapt them to your economy.
8. Add the watering can items if your server does not have them yet. They are not included in `items.sql`:

```sql
INSERT INTO `items`(`item`, `label`, `limit`, `can_remove`, `type`, `usable`) VALUES ('wateringcan', 'Watering Can', 5, 1, 'item_standard', 0);
INSERT INTO `items`(`item`, `label`, `limit`, `can_remove`, `type`, `usable`) VALUES ('wateringcan_dirtywater', 'Watering Can (Dirty Water)', 5, 1, 'item_standard', 0);
INSERT INTO `items`(`item`, `label`, `limit`, `can_remove`, `type`, `usable`) VALUES ('wateringcan_empty', 'Empty Watering Can', 5, 1, 'item_standard', 0);
```

6. Open `configs/config.lua`:
7. Set `defaultlang` to `'en_lang'`, `'fr_lang'`, `'de_lang'` or `'ro_lang'` (default is French).
8. Paste your Discord webhook URLs in `Config.Webhooks.planting` and `Config.Webhooks.harvest`, or set `enabled = false`.
9. Open `configs/plants.lua` and replace the job names in each plant's `jobs` list with your server's farming jobs (see Jobs).
10. Add the resource to your `server.cfg` after its dependencies:

```
ensure oxmysql
ensure vorp_core
ensure vorp_character
ensure vorp_inventory
ensure igris_farming
```

9. Restart the server. The console prints `[igris_farming] Script créé par igris` when the resource starts.
10. Test in game: give yourself a hoe and a seed (for example `gble`), take an allowed job, and use the seed from your inventory.

### Jobs

igris\_farming reads the player's VORP job to decide who can plant each crop and who can smell illegal plants.

* In `configs/plants.lua`, put the exact job names of your server in each plant's `jobs` list (names are case-sensitive).
* With `jobLocked = true` (the default on all 25 plants), only those jobs can plant the seed.
* Put your sheriff and marshal jobs in `Config.smelling.jobs` so they can smell illegal crops.

```lua
jobs = {
    'ranchbw',   -- replace with your farm or ranch jobs
    'ranchval',
    'ranchrh'
},
```

The default jobs are `ranchbw`, `ranchval` and `ranchrh`, plus `tabacus` for tobacco and `cotonus` for cotton. Set `jobLocked = false` on a plant to let every player grow it.

### Gameplay and controls

A crop goes through five steps, and it only grows while it is watered.

1. **Plant**: use a seed from the inventory. The player needs the right job, a hoe (if `plantingToolRequired`), soil (if `soilRequired`), and must be outside towns and away from other plants. The hoe loses durability with each use and breaks at 0%.
2. **Fertilize**: if the player carries fertilizer, a prompt offers to use it. The strongest one in the inventory is used automatically (25%, 50% or 75% less growing time).
3. **Water**: hold the prompt with a full watering can. The growth timer only runs once the plant is watered. The can turns empty after `waterBucketUses` plants.
4. **Harvest**: when the timer reaches zero, hold the prompt to collect the rewards.
5. **Destroy**: a plant can be removed at any stage with the destroy prompt.

| Action         | Default key | Config key     |
| -------------- | ----------- | -------------- |
| Fertilize: yes | B (hold)    | `keys.fertYes` |
| Fertilize: no  | C (hold)    | `keys.fertNo`  |
| Water          | B (hold)    | `keys.water`   |
| Harvest        | B (hold)    | `keys.harvest` |
| Destroy        | R (hold)    | `keys.destroy` |

Lawmen with a job in `Config.smelling.jobs` get a notification and a short map blip near plants with `smelling = true`, within 50 m by default.

### Configuration reference

General settings live in `configs/config.lua`; each crop is one block in `configs/plants.lua`.

#### config.lua

| Setting                            | Default                                                       | What it does                                                |
| ---------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------- |
| defaultlang                        | `'fr_lang'`                                                   | Language file: `en_lang`, `fr_lang`, `de_lang`, `ro_lang`   |
| DevMode                            | `false`                                                       | Debug prints in consoles; keep off on a live server         |
| keys                               | B / C / R                                                     | Prompt keys (see Gameplay and controls)                     |
| fullWaterBucket / emptyWaterBucket | `wateringcan`, `wateringcan_dirtywater` / `wateringcan_empty` | Watering can item names                                     |
| waterBucketUses                    | `1`                                                           | Plants one full can can water                               |
| fertilizerSetup                    | 3 fertilizers                                                 | Item name and time reduction (0.25 = 25%)                   |
| plantSetup.maxPlants               | `30`                                                          | Maximum plants per character                                |
| plantSetup.lockedToPlanter         | `false`                                                       | Only the planter can harvest                                |
| plantSetup.requireHouseOwnership   | `false`                                                       | Keep on `false`                                             |
| smelling                           | 50 m, red blip 5 s                                            | Distance, blip, notification cooldown and jobs for smelling |
| townSetup.canPlantInTowns          | `false`                                                       | Block planting within 150 m of 8 towns                      |
| Webhooks                           | enabled                                                       | Discord URLs for planting and harvest logs, bot username    |

Webhook URLs are in a shared config file, so they are sent to clients. Use a dedicated log channel webhook.

#### plants.lua

25 crops are included: orange, apple, peach, hops, sugar cane, coffee, corn, wheat, potato, oats, barley, carrots, beans, cabbage, beets, tomatoes, squash, pumpkins, parsley, thyme, sage, red grapes, strawberries, tobacco and cotton.

| Key                                                     | Example                           | What it does                                    |
| ------------------------------------------------------- | --------------------------------- | ----------------------------------------------- |
| plantName / seedName                                    | `'Ble'` / `'gble'`                | Display name and seed item                      |
| seedAmount                                              | `1`                               | Seeds used per planting                         |
| plantProp                                               | `'p_tree_orange_01'`              | Prop spawned in the world                       |
| plantOffset                                             | `1`                               | Height offset if the prop floats or sinks       |
| timeToGrow                                              | `900`                             | Growing time in seconds (counted while watered) |
| plantingToolRequired / plantingTool / plantingToolUsage | `true` / `'hoe'` / `2`            | Tool needed and durability lost per use         |
| soilRequired / soilName / soilAmount                    | `false` / `'soil'` / `1`          | Soil needed to plant                            |
| plantingDistance                                        | `1.5`                             | Minimum distance between plants (m)             |
| jobLocked / jobs                                        | `true` / ranch jobs               | Jobs allowed to plant                           |
| smelling                                                | `false`                           | Lawmen can smell this plant                     |
| blips                                                   | disabled                          | Map blip for the planter                        |
| rewards                                                 | `{ itemName, itemLabel, amount }` | Items given on harvest; several allowed         |
| lockCoords / coordsLocks                                | `false`                           | Restrict planting to fixed spots                |

To add a crop, copy a block, give it a new `seedName` and rewards, and add the seed and reward items to your database. The seed becomes usable automatically.

### Troubleshooting

| Problem                                       | Fix                                                                                                           |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| Seed cannot be used from the inventory        | The seed item is missing from the `items` table, or its `seedName` in plants.lua does not match the item name |
| "You are not the correct job"                 | Add your job name to that plant's `jobs`, or set `jobLocked = false`                                          |
| "You need a planting tool"                    | Give the player a `hoe`, or set `plantingToolRequired = false`                                                |
| "Too close to a town"                         | Move away (150 m by default) or set `townSetup.canPlantInTowns = true`                                        |
| Plant never grows                             | It has not been watered: the timer only runs on watered plants                                                |
| No watering prompt                            | The player has no `wateringcan` or `wateringcan_dirtywater`; add these items (Installation, step 5)           |
| Texts show `Translation [...] does not exist` | `defaultlang` does not match a file in `languages/`                                                           |
| SQL import fails on duplicates                | Remove the lines for items your server already has                                                            |
| No Discord logs                               | `Config.Webhooks.enabled = true` and valid URLs instead of `url_webhooks`                                     |

Still stuck? Turn on `DevMode`, reproduce the issue, and open a ticket on our Discord with the server and F8 console logs.
