> 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-mining.md).

# Igris Mining

<figure><img src="https://2862342791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFnkzyjlqOP6UGw1GyN62%2Fuploads%2FB3sA1anFOaWxDj1z4d4S%2Fmining.png?alt=media&amp;token=fd1a4604-5e53-4b5b-b623-80abc408bd9c" alt=""><figcaption></figcaption></figure>

Mining script for **VORP Core** (RedM): precise mining spots, job restriction, progress bar, pickaxe durability, random loot and Discord logs.

***

### 📦 Dependencies

Make sure these resources are installed and **started before** `igris_mining`:

| Resource          | Link                                             |
| ----------------- | ------------------------------------------------ |
| vorp\_core        | <https://github.com/VORPCORE/vorp-core-lua>      |
| vorp\_inventory   | <https://github.com/VORPCORE/vorp_inventory-lua> |
| vorp\_progressbar | <https://github.com/VORPCORE/vorp_progressbar>   |
| oxmysql           | <https://github.com/overextended/oxmysql>        |

### 🔧 Installation

1. Download `igris_mining` from your [Cfx.re Portal](https://portal.cfx.re/assets/granted-assets).
2. Drop the `igris_mining` folder into your `resources` directory.
3. Import `Mining.sql` into your database (see Items).
4. Add the resource to your `server.cfg` **after** the VORP resources:

cfg

```cfg
ensure vorp_core
ensure vorp_inventory
ensure vorp_progressbar
ensure igris_mining
```

5. Configure `config.lua` (job, spots, loot, Discord webhook).
6. Restart your server.

> ⚠️ Do not rename the resource folder. The script is escrow-protected; only `config.lua` is editable.

***

### 🎒 Items

`Mining.sql` adds the following items to the `items` table:

| Item name  | Default label    | Role                    |
| ---------- | ---------------- | ----------------------- |
| `pickaxe`  | Pioche           | Required tool (limit 1) |
| `charbon`  | Charbon          | Guaranteed reward       |
| `pcuivre`  | Pepite de Cuivre | Bonus ore               |
| `pfer`     | Pepite de Fer    | Bonus ore               |
| `psel`     | Sel              | Bonus ore               |
| `pzinc`    | Pepite de Zinc   | Bonus ore               |
| `pdiament` | Diamant Brut     | Bonus ore (rare)        |

Labels are in French by default. If your server is in English, use this version instead:

sql

```sql
INSERT IGNORE INTO items (`item`, `label`, `limit`, `can_remove`, `type`, `usable`) VALUES
  ('charbon',  'Coal',          50, 1, 'item_standard', 0),
  ('pcuivre',  'Copper Nugget', 50, 1, 'item_standard', 0),
  ('pfer',     'Iron Nugget',   50, 1, 'item_standard', 0),
  ('psel',     'Salt',          50, 1, 'item_standard', 0),
  ('pzinc',    'Zinc Nugget',   50, 1, 'item_standard', 0),
  ('pdiament', 'Raw Diamond',   50, 1, 'item_standard', 0),
  ('pickaxe',  'Pickaxe',        1, 1, 'item_standard', 0);
```

> 💡 Also update the `label` fields in `Config.Coal` and `Config.Items` — they are used in notifications and Discord logs.

***

### 🎮 How it works

1. The player (with an allowed job) goes to a mining spot — visible on the map with a blip.
2. A **"Mine"** prompt appears: **hold SPACE** to start a session.
3. The server checks the job, the position, the spot cooldown and the pickaxe.
4. The player equips the pickaxe and plays the mining animation with a progress bar.
5. At the end of each hit:
   * the pickaxe loses **1 durability point**,
   * the player receives the **guaranteed coal**,
   * each bonus ore is rolled **independently** (several ores can drop on the same hit).
6. Hold **SPACE** again for the next hit. A session lasts a random number of hits (between `MinHits` and `MaxHits`).
7. When the session ends, the spot goes on **cooldown** and a **Discord log** is sent.

Walking away from the spot cancels the session automatically. When the pickaxe reaches 0 durability it breaks and is removed from the inventory.

***

### ⚙️ Configuration

All settings are in `config.lua`.

#### Language

lua

```lua
Config.Lang = "en" -- "fr" / "en"
```

All texts (prompts, notifications, webhook) are in `Config.Text`. To add a language, copy the `en` block, rename it (e.g. `de`) and translate it, then set `Config.Lang = "de"`.

#### Job restriction

lua

```lua
Config.Job = {
  Enabled = true, -- false = everyone can mine
  Allowed = {
    mineus = true,
    mineur = true,
  }
}
```

| Option    | Description                                                                   |
| --------- | ----------------------------------------------------------------------------- |
| `Enabled` | `true` = only the listed jobs can mine and see the blips. `false` = everyone. |
| `Allowed` | List of job names (as stored in VORP) allowed to mine.                        |

#### Pickaxe

lua

```lua
Config.Pickaxe = {
  Item = "pickaxe",
  MaxUses = 20,
  NotifyEachHit = true,
}
```

| Option          | Description                                                                                                           |
| --------------- | --------------------------------------------------------------------------------------------------------------------- |
| `Item`          | Item name of the pickaxe.                                                                                             |
| `MaxUses`       | Number of hits before the pickaxe breaks. Stored in the item metadata (`usesLeft`) and shown in the item description. |
| `NotifyEachHit` | Show "Durability: x/20" after every hit.                                                                              |

#### Key

lua

```lua
Config.Keys = {
  StartMine = 0xD9D0E1C0, -- SPACE
}
```

The prompt is a **hold** prompt (0.5 s). Replace the hash to use another key.

#### Mining settings

lua

```lua
Config.Mining = {
  MinHits = 1,
  MaxHits = 3,
  HitDurationMs = 8000,
  InteractDistance = 1.8,
  SpotCooldownSeconds = 30,
}
```

| Option                | Description                                                                                                |
| --------------------- | ---------------------------------------------------------------------------------------------------------- |
| `MinHits` / `MaxHits` | A session lasts a random number of hits between these two values.                                          |
| `HitDurationMs`       | Duration of one hit (animation + progress bar), in milliseconds.                                           |
| `InteractDistance`    | Maximum distance (meters) from the spot to mine.                                                           |
| `SpotCooldownSeconds` | Cooldown of a spot after a session ends, in seconds. The cooldown applies to the spot for **all players**. |

#### Rewards

**Guaranteed reward** — given on every successful hit:

lua

```lua
Config.Coal = {
  name = "charbon",
  label = "Charbon",
  amount = 5, -- positive whole number
}
```

**Bonus rewards** — each item is rolled independently on every hit:

lua

```lua
Config.Items = {
  { name = "pcuivre",  label = "Pepite de Cuivre", chance = 45, amount = 4 },
  { name = "pfer",     label = "Pepite de Fer",    chance = 35, amount = 2 },
  { name = "psel",     label = "Sel",              chance = 10, amount = 5 },
  { name = "pzinc",    label = "Pepite de Zinc",   chance = 5,  amount = 2 },
  { name = "pdiament", label = "Diamant Brut",     chance = 1,  amount = 1 },
}
```

| Field    | Description                                   |
| -------- | --------------------------------------------- |
| `name`   | Item name in the database.                    |
| `label`  | Name shown in notifications and Discord logs. |
| `chance` | Drop chance in % (0–100).                     |
| `amount` | Exact quantity given when the item drops.     |

You can add as many items as you want — just make sure they exist in your `items` table.

> 🎒 If the player cannot carry an item, they get a "Bag full" notification and nothing is lost. If they cannot carry the coal, no bonus is rolled for that hit.

#### Mining spots

lua

```lua
Config.Spots = {
  {
    id = "annesburg_mine_1",
    name = "Mine Annesburg - Point #1",
    coords = vector3(2761.0, 1310.9, 70.0),
    blip = { enabled = true, sprite = -1633216922, scale = 0.2 }
  },
  -- add as many spots as you want
}
```

| Field          | Description                                                |
| -------------- | ---------------------------------------------------------- |
| `id`           | **Unique** identifier of the spot (used for the cooldown). |
| `name`         | Name shown on the blip and in the Discord logs.            |
| `coords`       | Exact position of the mining point.                        |
| `blip.enabled` | Show a blip on the map (only for allowed jobs).            |
| `blip.sprite`  | Blip sprite hash.                                          |
| `blip.scale`   | Blip size.                                                 |

7 spots are preconfigured inside the **Annesburg mine**.

> 💡 Tip: stand where you want the player to mine, get your coordinates (e.g. with a coords command) and paste them into `coords`.

#### Discord logs

lua

```lua
Config.Discord = {
  Enabled = true,
  WebhookUrl = "URL_Webhook",
  Color = 16753920,
  Logo = "",
  FooterLogo = "",
  Avatar = ""
}
```

| Option                           | Description                        |
| -------------------------------- | ---------------------------------- |
| `Enabled`                        | Enable or disable the logs.        |
| `WebhookUrl`                     | Your Discord webhook URL.          |
| `Color`                          | Embed color (decimal).             |
| `Logo` / `FooterLogo` / `Avatar` | Optional image URLs for the embed. |

A log is sent at the end of each session with the character's name, the spot, the number of hits and the total loot.

***

### 🛡️ Security

Every action is validated **server-side**:

* the player's job,
* the player's real distance to the spot,
* the spot cooldown,
* the presence and durability of the pickaxe,
* the inventory space before giving any item.

A player cannot trigger rewards without actually being at the spot with a valid pickaxe.

***

### ❓ FAQ

**The prompt does not appear.** Check that your character has one of the jobs in `Config.Job.Allowed` (or set `Enabled = false`) and that you are within `InteractDistance` of the spot.

**I don't see any blips.** Blips are only shown to allowed jobs. They refresh automatically when your job changes.

**"You don't have a pickaxe."** Give yourself the `pickaxe` item and make sure it exists in the `items` table.

**"This spot is on cooldown."** Another session just ended on this spot. Wait `SpotCooldownSeconds` or use another spot.

**No Discord logs.** Check that `Enabled = true` and that `WebhookUrl` contains a valid webhook URL.

***

### 💬 Support

Need help? Open a ticket on our Discord.
