# mack-goldclaim
A full gold claim system for RedM (rsg-core). Players can place gold rockers, process paydirt and water into gold nuggets, manage licensed/unlicensed claims, and sell or smelt their findings at Gold Agent NPCs.
## Features
- **Placeable Gold Rocker** — Place `p_goldcradlestand01x` anywhere (or restricted areas). Persists across restarts.
- **Licensed & Unlicensed Claims** — Players with a `goldclaimlicense` item get a licensed claim with a named zone, blip, and enter/leave notifications. Without a license the claim is flagged as illegal.
- **Claim Zones** — Licensed claims create a radius zone (default 20m) with map blips. Other players are warned when entering.
- **LEO Enforcement** — Law enforcement can destroy unlicensed claims and confiscate the rocker as evidence.
- **Async Processing** — Add paydirt and water to the rocker, start processing, and walk away. The server handles the timer and spawns a gold or paydirt output prop when done.
- **Weighted Nugget Drops** — Gold pickups give random nugget types (small/medium/large) with configurable weight distribution and amount ranges.
- **Gathering Tools** — Use a shovel in water to dig paydirt. Use a bucket in water to fill it.
- **Equipment Degradation** — Cron-based quality degradation. Equipment lost at 0% quality. Repair with 5x wood.
- **Gold Agent NPCs** — Smelt nuggets into gold bars and sell gold/silver bars at configurable NPC locations.
- **Rename Claims** — Licensed claim owners can rename their claim at any time.
- **bln_notify Notifications** — All notifications use the bln_notify system.
- **ox_target Integration** — All rocker interactions use ox_target.
## Dependencies
- [rsg-core](https://github.com/Starter-RSG/rsg-core)
- [ox_lib](https://github.com/overextended/ox_lib)
- [ox_target](https://github.com/overextended/ox_target)
- [oxmysql](https://github.com/overextended/oxmysql)
- [bln_notify](https://github.com/BLN-Scripts/bln_notify)
## Installation
1. **Database** — Run `mack-goldclaim.sql` in your database to create the `mack_goldrockers` table.
2. **Items** — Add the contents of `installation/shared_items.lua` to your `rsg-core/shared/items.lua`:
- `goldrocker` — Placeable gold rocker equipment
- `goldclaimlicense` — Grants a licensed claim on placement
- `bucket` / `fullbucket` — For collecting water
- `shovel` — For digging paydirt
- `paydirt` — Raw material for the rocker
- `smallnugget` / `mediumnugget` / `largenugget` — Gold nugget outputs
- `goldbar` — Smelted output
- `wood` — Used for repairs
3. **Images** — Copy any item images to your `rsg-inventory/html/images/` folder.
4. **Resource** — Add to your `server.cfg`:
```
ensure mack-goldclaim
```
## Configuration
### General Settings
```lua
Config.MaxGoldRockers = 4 -- max rockers per character
Config.DegradeChance = 5 -- % chance of degradation per cron cycle
Config.CronJob = '*/30 * * * *' -- cron schedule (every 30 mins)
Config.RepairWoodAmount = 5 -- wood needed to repair
Config.ClaimZoneRadius = 20.0 -- licensed claim zone radius (meters)
```
### Processing
```lua
Config.ProcessingTime = 60000 -- processing time (ms)
Config.GoldChance = 50 -- % chance of gold vs paydirt return
Config.AddPaydirtTime = 10000 -- time to add paydirt (ms)
Config.AddWaterTime = 10000 -- time to add water (ms)
```
### Nugget Distribution
```lua
Config.NuggetWeights = {
small = 50, -- 50% chance
medium = 35, -- 35% chance
large = 15, -- 15% chance
}
Config.NuggetAmounts = {
small = { min = 1, max = 10 },
medium = { min = 1, max = 5 },
large = { min = 1, max = 3 },
}
```
### Gold Agent / Smelting
```lua
Config.SmallNuggetSmelt = 45 -- small nuggets per gold bar
Config.MediumNuggetSmelt = 30 -- medium nuggets per gold bar
Config.LargeNuggetSmelt = 15 -- large nuggets per gold bar
Config.GoldBarPrice = 500 -- sell price per gold bar
Config.SilverBarPrice = 400 -- sell price per silver bar
Config.SmeltTime = 30000 -- smelting time (ms)
```
### Gold Agent NPC Locations
Add or remove NPC locations in `Config.GoldAgentLocations`:
```lua
Config.GoldAgentLocations = {
{
name = 'Valentine Gold Agent',
prompt = 'val-goldagent',
coords = vector3(-303.14, 778.55, 118.70),
npcmodel = `s_m_m_bankclerk_01`,
npccoords = vector4(-303.14, 778.55, 118.70, 110.30),
showblip = true,
},
-- add more locations here
}
```
## Usage
### For Players
1. **Get a Gold Rocker** — Obtain a `goldrocker` item
2. **Optional: Get a License** — Having a `goldclaimlicense` in your inventory when placing creates a licensed claim
3. **Place the Rocker** — Use the gold rocker item, position it, and confirm placement
4. **Gather Materials** — Use a `shovel` while standing in water to dig paydirt. Use a `bucket` in water to fill it.
5. **Load the Rocker** — Add paydirt and water to the rocker via ox_target
6. **Process** — Start processing from the rocker menu. Walk away and wait for the output prop to appear.
7. **Collect** — Pick up the output prop (gold nuggets or paydirt)
8. **Repair** — Keep equipment maintained with 5x wood before it degrades to 0%
9. **Smelt & Sell** — Visit a Gold Agent NPC to smelt nuggets into bars and sell them
### For Law Enforcement
- Unlicensed claims trigger a server-wide alert
- LEO players can destroy illegal claims via the rocker menu or ox_target
- The confiscated rocker is added to the LEO's inventory as evidence
## Database Schema
```sql
CREATE TABLE `mack_goldrockers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(50) DEFAULT NULL,
`owner` varchar(50) DEFAULT NULL,
`properties` text NOT NULL,
`propid` int(11) NOT NULL,
`proptype` varchar(50) DEFAULT NULL,
`licensed` tinyint(1) NOT NULL DEFAULT 0,
`claimname` varchar(100) DEFAULT NULL,
`paydirt` int(3) NOT NULL DEFAULT 0,
`water` int(3) NOT NULL DEFAULT 0,
`quality` int(3) NOT NULL DEFAULT 100,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;