All resources

rsg-mining – Developer Docs (v3.2.0)#

Framework usage (ox_lib free)#

rsg-mining has no ox_lib dependency. Everything runs on rsg-core and rsg-target.

FeatureAPI used
Locales@rsg-core/shared/locale.lua + locale(key, ...); language from setr rsg:locale <lang> (falls back to ox:locale, then en)
UI locale bundlelocale() with no key returns every string; the client sends the ui_* / status_* keys to the NUI
Notify (client)RSGCore.Functions.Notify({ title, description, type, duration, icon, position })
Notify (server)TriggerClientEvent('RSGCore:Client:Notify', src, data)
Callbacksserver RSGCore.Functions.CreateCallback (wrapped by registerCallback, so handlers keep return style); client RSGCore.Functions.AwaitCallback(name, nil, ...)
Model loadingRSGCore.Functions.RequestModel(model, 10000)
Proximity spawningpoints.new({...}) from @rsg-core/client/points.lua
Targetingexports['rsg-target']:addLocalEntity / removeLocalEntity
Lease purchase confirmthe resource's own NUI confirm box (confirm NUI message → confirmAnswer NUI callback)

Server callbacks#

All re-validate lease holder, distance and cooldown server-side.

  • rsg-mining:server:getMineData(mineId) → { data }, { noLease, price, hours, label } or { error }
  • rsg-mining:server:buyLease(mineId) → bool
  • rsg-mining:server:renewLease / hire(key) / fire(workerId) / addWages(amount) / withdrawWages(amount) / deposit(key, amount) / collect(item) → updated ledger data or false

NUI messages#

  • open { data, locales }, update { data }, close
  • confirm { title, text, locales } – lease purchase prompt; answered with POST confirmAnswer { ok }

Locale keys added in the migration#

ui_confirm_buy, ui_cancel (all 11 languages).

rsg-skills integration#

Config.Skills = { Enabled, Skill, CollectXP, MaxXPPerCollect }. After the server has handed over the ore in rsg-mining:server:collect, it calls exports['rsg-skills']:AddXP(src, 'mining', xp, 'mining collect') with xp = min(items collected * CollectXP, MaxXPPerCollect). The amount comes from config. Skipped when rsg-skills is not started.

With Config.Skills.ExtraYield = true, collectItem also reads GetPerk(src, 'mining', 'extra_yield') and rolls once per ore type collected: on success one extra item is given (after CanAddItem) and shown in the item box and the notification. The extra item is not taken from the mine's storage. The rare_chance perk is not used by this script.

rsg-reputation integration#

Config.Reputation = { Enabled, StandingPerCollect, Cooldown }, and a region on every entry of Config.Mines (an id from rsg-reputation's Config.Regions: annesburg, new_austin for Gaptooth, ambarino for Grizzlies). After a successful rsg-mining:server:collect the server calls exports['rsg-reputation']:AddStanding(src, region, StandingPerCollect, 'mining collect'), at most once per player and region every Cooldown seconds. Honor is not changed. Skipped when rsg-reputation is not started or the mine has no region.

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-mining 3.1.0. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, rsg-target, oxmysql, rsg-inventory

Database#

Tables: rsg_mining, rsg_mining_workers.

Tables are created automatically on start while Config.AutoDatabase = true (default). Nothing is ever dropped or overwritten. For a manual install set Config.AutoDatabase = false and import installation/rsg-mining.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.AutoDatabasetruebuild the database tables automatically on start (set false and import the SQL file for a manual install)
Config.ForemanModel'u_m_m_bht_mineforeman'
Config.SpawnDistance50.0foreman ped spawns when player is within this range
Config.TargetDistance2.5
Config.ManageDistance10.0server-side: max distance from the foreman to use the ledger
Config.ActionCooldown500ms between foreman actions per player (anti-spam)
Config.MoneyType'cash'cash | bank
Config.NotifyPosition'top-right'
Config.ImagePath'nui://rsg-inventory/html/images/'where item images live
Config.LeaseDurationHours72real-time hours a lease lasts
Config.AllowRenewtruelease holder can extend from the foreman UI
Config.MaxLeaseHours336cap on total remaining time when renewing
Config.Suppliestable
Config.WorkInterval10minutes between work cycles
Config.FoodDrain25food lost per cycle (0-100)
Config.WaterDrain34water lost per cycle (0-100)
Config.PickaxeWear20durability lost per cycle (0-100)
Config.BreadRestore100food restored by 1 bread
Config.WaterRestore100water restored by 1 water
Config.MinSkill1
Config.MaxSkill10
Config.SkillGainPerCycle0.05workers improve slowly on the job
Config.SkillChanceBonus0.08+8% ore chance per skill level above 1
Config.SkillAmountBonus0.5extra ore per skill level (floored)
Config.WageBase2base pay per shift
Config.WagePerSkill0.5extra pay per skill level (wage is rounded up)
Config.MaxPayroll5000most money the payroll fund can hold
Config.AllowWithdrawtruelease holder can take unused wages back out
Config.CandidateCount5hiring
Config.CandidateRefresh30minutes before the hiring board refreshes
Config.HireBaseCost10
Config.HireCostPerSkill8cost = base + skill * this
Config.CandidateSkillMax7best skill a fresh hire can have
Config.FirstNames{ 'Amos','Bill','Cyrus','Eli','Silas','Jeb','Otis','Hank','Walt','Clem
Config.LastNames{ 'Hollis','Carver','Dunn','Pruitt','Mosby','Hale','Riggs','Tate','Boo
Config.Minestable
Config.Skillstablersg-skills integration (optional). Needs the rsg-skills resource; does nothing when it is not started.
Config.Enabledtrue
Config.Skill'mining'
Config.CollectXP1
Config.MaxXPPerCollect50

Callbacks#

CallbackSideArgumentsFile
rsg-mining:server:getMineDataserversrc, idserver/server.lua
rsg-mining:server:buyLeaseserversrc, idserver/server.lua
rsg-mining:server:renewLeaseserversrc, idserver/server.lua
rsg-mining:server:hireserversrc, id, keyserver/server.lua
rsg-mining:server:fireserversrc, id, widserver/server.lua
rsg-mining:server:addWagesserversrc, id, amountserver/server.lua
rsg-mining:server:withdrawWagesserversrc, id, amountserver/server.lua
rsg-mining:server:depositserversrc, id, key, amountserver/server.lua
rsg-mining:server:collectserversrc, id, itemserver/server.lua
-- client side
RSGCore.Functions.TriggerCallback('rsg-mining:server:getMineData', function(result)
    -- use result
end)

Commands#

CommandNotesFile
/rsgmining_webhooktestserver/sv_webhooks.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->