All resources

rsg-drugs – Docs (v3.1.3)#

Contents#

  1. Files
  2. How it works
  3. Configuration
  4. Exports, events and commands
  5. Database
  6. Discord logs
  7. Security
  8. Server owner how-tos
  9. Troubleshooting

1. Files#

FilePurpose
fxmanifest.luaManifest; depends on rsg-core, rsg-inventory, rsg-target, oxmysql
shared/config.luaLab: NPC, items, packing, roles, hiring, XP
shared/config_addiction.luaAddiction: substances, rehab, NPC selling
shared/config_export.luaBrick export market
client/client.lua, html/index.html, html/script.js, html/style.cssLab NUI
client/export.lua, html/export.*Brick export NUI
client/addiction.lua, html/addiction.*Addiction HUD and rehab countdown
client/addiction_npc.luaNPC addicts: inspect, rehab, sell
client/utils.luaNPC spawning helpers
server/server.luaLabs, crew, work loop
server/export.luaBrick market
server/addiction.luaDependency, craving, rehab, commands
server/xp.luaDrug reputation
server/discord.lua, server/config_discord.luaDiscord logs (server-only config)
server/versionchecker.luaGitHub version check
installation/install.sqlDatabase install
installation/shared_items.luaItems to add to rsg-core/shared/items.lua
locales/*.jsonen, de, el, es, fr, ja, nl, pl, pt-br, ro, ru

2. How it works#

Cannabis lab#

  • Talk to the processing NPC (rsg-target) to open the lab NUI. Bring fresh weed.
  • Hire a crew (up to MaxEmployees): dryers (weed → weed_dried), processors (weed_dried → weed_processed) and packers (weed_processed → weed_bag or weed_brick). Employees need food and water.
  • Work runs in shifts every TickSeconds. A packer adds their skill rate in work points each shift; a unit needs Config.Packing[x].work points and uses uses processed weed.
  • Dryers have a SeedChance (2%) to find a seedweed, collected from Supplies.
  • Stock held at the lab is capped by MaxStorage.

Brick export (demand market)#

  • Players at Distributor or higher (Config.Export.MinLevel) sell weed_brick to a buyer NPC (Talk business).
  • Price follows supply: an empty market pays MaxPrice, sliding to MinPrice as buyer stock nears Saturation. Stock drains over time and demand drifts between DemandMin and DemandMax.
  • The market is shared by all players and saved in the rsg_drugs_state table (no resource KVP, so no server db folder).
  • Move the default buyer coords (Config.Export.NPC.coords) to your own location.

Reputation (XP)#

  • Stored as rsg-core rep drugs. Production gives the lab owner XP per finished unit (bag 1, brick 50); each bag sold to an NPC gives 2 XP; each exported brick gives 60 XP.
  • Levels: Street Kid → Peddler → Dealer → Supplier → Distributor → Kingpin (Config.XP.Levels).
  • Brick packing needs the owner at XP.BrickMinLevel (5 = Distributor) or higher.
  • Starting an rsg-prison sentence resets drug XP (XP.ResetOnJail).

Addiction and rehab (alcohol and weed)#

  • Dependency (0–100) rises each time a configured item is used. Past the substance's threshold the player is hooked.
  • While hooked, craving grows every TickInterval seconds and causes withdrawal effects unless the player feeds the habit. Using the substance resets craving but raises dependency.
  • Not hooked: dependency decays by decay per tick.
  • The cure is rehab (jail-style stint at Sisika): belongings are confiscated and returned on release; weapons are removed and re-equipped.
  • Lawmen (AllowedJobTypes), medics (AllowedJobs) and admins can send players to rehab; players can also check in voluntarily. Officers earn a bonus per admission (Reward).
  • NPC addicts can be inspected, sent to rehab or sold to (Config.Addiction.Selling).

3. Configuration#

shared/config.lua:

OptionMeaning
NPCProcessing NPC: coords, model, spawnDistance, interactDistance, targetDistance
Itemsraw, dried, processed, brick, bag, seed item names
SeedChance% per fresh weed dried
Packingbag / brick: uses, work
Food, WaterItems employees can be given
TickSeconds, MaxEmployees, MaxStorageWork loop
Rolesdryer, processor, packer
HireFee, CandidateCount, CandidateRefreshMinutesHiring
XPEnabled, BrickMinLevel, Levels, per-item XP, ResetOnJail

shared/config_addiction.lua: Config.Addiction with TickInterval, UseCooldown, Substances (alcohol, weed: items, threshold, decay, cravingRate, scenarios), Rehab (DefaultMinutes, MaxMinutes, VoluntaryMinutes, Centre, Spawns, Release, AllowedJobTypes, AllowedJobs, AdminPermission, MaxAdmitDistance, Reward, Confiscate) and Selling.

shared/config_export.lua: Config.Export (MinLevel, NPC, MaxPrice, MinPrice, Saturation, TickMinutes, DrainPerHour, DemandMin, DemandMax, MaxPerSale, Cooldown).

4. Exports, events and commands#

NameSideNotes
AddXP(src, amount, reason)server exportAdd drug XP; add a xp_reason_<reason> locale key for a label
GetXP(src)server export{ xp, level, label, from, to }
ResetXP(src)server exportReturns XP removed
AddUse(...)server exportRegister a substance use
GetAddiction(src)server exportAddiction state
IsInRehab(src)server exportbool
ReturnRehabItems(src)server exportReturn confiscated items
DiscordLog(category, title, src, fields, description)server exportWrite to the drug log channels
NpcSoldWeedBag(ped)client exportTell the addiction system an NPC bought a bag
rsg-drugs:client:open / exportOpen / openUIclient eventsOpen lab, export or addiction UI
rsg-drugs:server:consumedserver event(itemName) from rsg-consume
rsg-drugs:server:npcRehabserver event(netId)
CommandWhoWhat
/addictioneveryoneShow your addiction status
/rehab [id] [minutes]lawmen, medics, adminsSend a player to rehab
/clearaddiction [id]adminClear a player's addiction
/setaddiction [id] [substance] [level]adminSet a dependency level

Example, reward XP from a delivery script:

exports['rsg-drugs']:AddXP(src, 25, 'delivery')

5. Database#

rsg_drugs_labs: citizenid (primary key), data (LONGTEXT JSON for the lab). rsg_drugs_state: key (primary key, currently market), value (LONGTEXT JSON of the export market: stock, demand, price history).

Both tables are created automatically (Config.AutoDatabase). To install manually set it to false, import installation/install.sql, and add installation/shared_items.lua to your items file. Addiction and XP live in player metadata; the export market lives in rsg_drugs_state.

6. Discord logs#

Set URLs in server/config_discord.lua (ConfigDiscord.Webhooks per category, or ConfigDiscord.Default for one channel; false turns a category off). Categories: lab, sales, export, xp, rehab, admin, security. Logs are queued and batched (up to 10 embeds per message every FlushSeconds) with back-off on Discord rate limits. MinDeposit / MinWithdraw filter small transactions.

7. Security#

All XP, payouts and prices come from config on the server; clients can't send amounts. Every NUI action checks distance to the NPC. Export sales check buyer distance, level, item count and cooldown. Officers can't send their own customers to rehab for the bonus (logged under security).

8. How-tos#

  • Start: ensure rsg-drugs after rsg-core, rsg-inventory, rsg-target; run install.sql; add the items.
  • Optional integrations: rsg-consume (alcohol), rsg-hud (stress relief), rsg-weapons (re-equip after rehab), rsg-farming (weed seeds).
  • Language: setr rsg:locale "de" in server.cfg; config labels use cfg_* locale keys.

9. Troubleshooting#

ProblemFix
Can't switch packers to bricksOwner level is below BrickMinLevel
No export optionPlayer below Export.MinLevel or the buyer NPC isn't where you expect
Items missingAdd installation/shared_items.lua to your items
Rehab bonus not paidJob must be in AllowedJobTypes/AllowedJobs; NPC rewards have a cooldown

Support the Project : https://rexshack.tebex.store/

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

Technical reference#

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

Dependencies#

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

Database#

Tables: rsg_drugs_labs.

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/install.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.NPCtable
Config.Itemstable
Config.SeedChance2.0chance (%) per fresh weed dried that a seed is found; collect them from the Supplies tab
Config.Packingtablea packer adds their skill rate in work points each shift (e.g. Skilled = 1.5 per shift)
Config.Food{ bread = 1, cooked_meat = 2 }food and drink employees can be given (item = how many 'meals' it gives)
Config.Water{ water = 1 }
Config.TickSeconds60one work shift tick
Config.MaxEmployees6
Config.MaxStorage5000max of each stock type held at the lab (must be >= a brick's uses)
Config.HungerDrain8per tick
Config.ThirstDrain12per tick
Config.MealRestore50hunger restored per food unit
Config.DrinkRestore50thirst restored per water unit
Config.AutoFeedBelow50staff eat/drink from the pantry under this value
Config.UnpaidStrikeTicks3missed paydays before going on strike
Config.Skilltableskill 1-5: production per tick and wage per tick
Config.Rolestable
Config.HireFee5.0one-off signing fee
Config.CandidateCount6
Config.CandidateRefreshMinutes30
Config.FirstNames{ 'Amos','Bill','Cyrus','Dutch','Eli','Floyd','Gus','Hattie','Ida','Je
Config.LastNames{ 'Barlow','Cobb','Dawes','Fenwick','Grady','Holt','Kincaid','Mercer',
Config.XPtable
Config.Enabledtrue
Config.RepName'drugs'
Config.Notifytrue
Config.BrickMinLevel5
Config.ResetOnJailtrue
Config.ProducetableIf the owner is offline it is banked and paid the next time they open the lab.
Config.SelltableXP per completed sale
Config.Levelstablelevel thresholds (total XP needed)
Config.Addiction{}
Config.Addiction.TickInterval60seconds between server addiction ticks (craving growth / natural decay)
Config.Addiction.UseCooldown5seconds, per player anti-spam on reported uses
Config.Addiction.Substancestable
Config.Addiction.ShakeName'DRUNK_SHAKE'
Config.Addiction.Stagestable
Config.Addiction.EffectInterval15000ms between stumble/stress rolls on the client
Config.Addiction.StumbleOnlyMovingtrue
Config.Addiction.Rehabtable
Config.Addiction.NPCtable
Config.Addiction.Sellingtable
Config.Exporttable

Exports#

Server

ExportArgumentsFile
AddUse``server/addiction.lua
GetAddictionsrcserver/addiction.lua
IsInRehabsrcserver/addiction.lua
ReturnRehabItemssrcserver/addiction.lua
DiscordLogcategory, title, src, fields, descriptionserver/discord.lua
AddXPsrc, amount, reasonserver/xp.lua
ResetXPsrcserver/xp.lua
GetXPsrcserver/xp.lua

Client

ExportArgumentsFile
NpcSoldWeedBag``client/addiction_npc.lua
-- example
local result = exports['rsg-drugs']:AddUse()

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-drugs:client:useSubstanceclientkeyclient/addiction.lua
rsg-consume:client:consumeclientitemNameclient/addiction.lua
rsg-drugs:client:teleportclientposclient/addiction.lua
rsg-drugs:client:disarmclient``client/addiction.lua
rsg-drugs:client:reequipclientlistclient/addiction.lua
rsg-drugs:client:openUIclient``client/addiction.lua
RSGCore:Client:OnPlayerUnloadclient``client/addiction.lua
RSGCore:Client:OnPlayerLoadedclient``client/addiction_npc.lua
RSGCore:Client:OnJobUpdateclientjobclient/addiction_npc.lua
RSGCore:Client:SetDutyclientonDutyclient/addiction_npc.lua
RSGCore:Player:SetPlayerDataclientdataclient/addiction_npc.lua
rsg-drugs:client:sellAlertclientcoordsclient/addiction_npc.lua
rsg-drugs:client:refreshclientdataclient/client.lua
rsg-drugs:server:consumedserveritemNameserver/addiction.lua
rsg-drugs:server:npcRehabservernetIdserver/addiction.lua
rsg-drugs:server:checkInserver``server/addiction.lua
rsg-drugs:server:closedserver``server/server.lua
rsg-prison:server:startSentenceserver``server/xp.lua
-- from a client script
TriggerServerEvent('rsg-drugs:server:consumed', itemName)
-- from a server script
TriggerClientEvent('rsg-drugs:client:useSubstance', source, key)

Commands#

CommandNotesFile
/addictionlocale('cmd_addiction')server/addiction.lua
/rehablocale('cmd_rehab')server/addiction.lua
/clearaddictionlocale('cmd_clear')server/addiction.lua
/setaddictionlocale('cmd_set')server/addiction.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 -->