Drugs Creator
Configuration
Every option of nv_drugscreator with its default value. The files stay open (not escrowed), so you can edit them freely; restart nv_drugscreator after a change.
Preview: the script is not released yet, so options can still change. This page is updated with every release.
Framework, inventory, target, dispatch, notifications and progress bar are not set here: nv_bridge detects them for all Nivo scripts at once. Database tables are created automatically by nv_bridge on first start (sql/001_tables.sql, no manual import). Texts come from locales/<language>.json (English is the default); set Config.Locale to switch.
config.lua
-- ════════════════════════════════════════════════════════════════════
-- nv_drugscreator (harvest) – shared settings. The harvests themselves (places, drop, prop, time) are set up in the `/drugs` UI
-- and stored in the DB (table nv_harvest_spots), so nothing is tuned through commits.
-- A harvest = a zone with one or more locations; each location holds `count` props scattered within `radius`.
-- ════════════════════════════════════════════════════════════════════
Config = {}
-- ── General ──────────────────────────────────────────────────────────
Config.Locale = 'en' -- 'en', 'cs', 'de', 'fr', 'es', 'pt', 'tr', 'pl', 'it' or 'nl' (files in locales/), add your own language by copying en.json
-- Config.OnAlert = function(alert) return true end -- optional: handle alerts yourself (framework, inventory, target and dispatch are set in nv_bridge/config.lua): alert = { jobs, code, title, message, coords, priority, blip, src }
Config.Admin = { group = 'group.admin' } -- principal allowed to use /drugs and the admin UI (ox_lib adds the ACE command.drugs for it)
-- ── Selling to NPCs (works on any pedestrian in the city, for a fixed price) ──
-- Switched off automatically when nv_drugs-selling runs (it has its own, richer street selling). Prices are per piece, paid in cash or as dirty money.
Config.Sell = {
Enabled = true,
Account = 'money', -- 'money' (cash) | 'dirty' (black_money on ESX, the item from nv_drugs-selling's Config.DirtyMoney elsewhere)
Items = { -- item = what the player sells, label = shown name, price = $ per piece
{ item = 'weed_ak47', label = 'AK-47', price = 280 },
{ item = 'weed_banana', label = 'Banana Kush', price = 300 },
{ item = 'weed_purple', label = 'Purple Haze', price = 300 },
{ item = 'weed_widow', label = 'White Widow', price = 320 },
{ item = 'coke_bag', label = 'Cocaine (bag)', price = 220 },
{ item = 'opium_raw', label = 'Opium', price = 270 },
},
Amount = { 1, 3 }, -- how many pieces one NPC buys (random, limited by what the player has)
RefuseChance = 10, -- % that the NPC refuses (nothing is sold, short cooldown)
CooldownS = 8, -- seconds between two sales of the same player
Ms = 3500, -- duration of one sale
Distance = 2.0, -- target distance
PoliceJobs = { 'police' },
MinPolice = 0, -- how many police officers must be online to allow selling. 0 = off
PoliceChance = 15, -- % chance per sale that the police get an alert
Dispatch = { code = '10-14', priority = 2, title = _L('suspected_drug_dealing'), message = _L('a_citizen_reported_a_suspicious'), blip = { sprite = 51, color = 1, scale = 0.9 } },
}
-- Animations while harvesting (chosen in the UI). dict + clip, or scenario.
Config.Anims = {
plant = { label = _L('picking_plants_bending_over'), dict = 'amb@world_human_gardener_plant@male@base', clip = 'base' },
pickup = { label = _L('pick_up_from_the_ground'), dict = 'pickup_object', clip = 'pickup_low' },
search = { label = _L('digging_through_a_bin'), dict = 'amb@prop_human_bum_bin@idle_a', clip = 'idle_a' },
scenario_garden = { label = _L('gardening_scenario'), scenario = 'WORLD_HUMAN_GARDENER_PLANT' },
scenario_kneel = { label = _L('kneeling_and_searching_scenario'), scenario = 'CODE_HUMAN_MEDIC_KNEEL' },
scenario_clipboard = { label = _L('clipboard_scenario'), scenario = 'WORLD_HUMAN_CLIPBOARD' },
}
Config.DefaultAnim = 'plant'
-- Ready-made GTA props for quick selection. Any model can also be entered manually in the UI.
Config.Props = {
{ label = _L('cannabis_bush'), model = 'prop_weed_01' },
{ label = _L('cannabis_small'), model = 'prop_weed_02' },
{ label = _L('cabbage'), model = 'prop_veg_crop_03_cab' },
{ label = _L('pumpkin'), model = 'prop_veg_crop_03_pump' },
{ label = _L('oranges'), model = 'prop_veg_crop_orange' },
{ label = 'Rostlina', model = 'prop_plant_01a' },
{ label = _L('wooden_crate'), model = 'prop_box_wood02a_pl' },
{ label = 'Sud', model = 'prop_barrel_02a' },
}
Config.DefaultProp = 'prop_weed_01'
-- Target icons (Font Awesome without the fa-solid fa- prefix)
Config.Icons = { 'hand', 'leaf', 'seedling', 'cannabis', 'mortar-pestle', 'magnifying-glass', 'box-open', 'hand-holding' }
Config.StreamDistance = 80.0 -- distance up to which props are created
-- Police alert while harvesting (jobs, code and texts; sent through Bridge.Alert according to the dispatch set in nv_bridge/config.lua)
Config.Dispatch = { jobs = { 'police' }, code = '10-91', priority = 3, title = _L('suspicious_harvesting'), message = _L('a_suspicious_person_was_reported') }
--- Prop scatter in a location: the same result on the server and on the client (fixed seed from the zone and location).
--- loc = { x, y, radius, count }; radius 0 = a single prop exactly on the point.
---@return { x: number, y: number }[]
local function inPoly(px, py, poly)
local inside, j = false, #poly
for i = 1, #poly do
local a, b = poly[i], poly[j]
if (a.y > py) ~= (b.y > py) and px < (b.x - a.x) * (py - a.y) / (b.y - a.y) + a.x then inside = not inside end
j = i
end
return inside
end
PointInPoly = inPoly -- shared: growing areas shaped as a polygon (server/plants.lua)
local function scatterRaw(zoneId, idx, loc)
local radius = tonumber(loc.radius) or 0
local n = math.max(1, math.floor(tonumber(loc.count) or 1))
local s = (zoneId * 7919 + idx * 104729) % 2147483646 + 1
if loc.poly and #loc.poly >= 3 then -- shape drawn on the map: props inside the polygon (attempts are repeated, fixed seed)
local minx, maxx, miny, maxy = math.huge, -math.huge, math.huge, -math.huge
for _, p in ipairs(loc.poly) do minx, maxx, miny, maxy = math.min(minx, p.x), math.max(maxx, p.x), math.min(miny, p.y), math.max(maxy, p.y) end
local pts, tries = {}, 0
while #pts < n and tries < n * 40 do
tries = tries + 1
s = s * 48271 % 2147483647
local x = minx + s / 2147483647 * (maxx - minx)
s = s * 48271 % 2147483647
local y = miny + s / 2147483647 * (maxy - miny)
if inPoly(x, y, loc.poly) then pts[#pts + 1] = { x = x, y = y } end
end
if #pts == 0 then pts[1] = { x = loc.x, y = loc.y } end
return pts
end
if radius <= 0 then return { { x = loc.x, y = loc.y } } end
local out = {}
for i = 1, n do
s = s * 48271 % 2147483647
local a = s / 2147483647 * 6.2831853
s = s * 48271 % 2147483647
local r = math.sqrt(s / 2147483647) * radius
out[i] = { x = loc.x + math.cos(a) * r, y = loc.y + math.sin(a) * r }
end
return out
end
-- The result is fixed (seed), but the client requests it every 1.5 s for each nearby zone and for a map shape the computation is expensive
-- (up to 60 props × 40 attempts × point in polygon). Cached by zone and location shape; returned points must not be modified.
local scatterCache = {}
function Scatter(zoneId, idx, loc)
local poly = loc.poly
local sum = 0
for i, p in ipairs(poly or {}) do sum = sum + p.x * i + p.y * (i + 1) end -- changing any point of the shape changes the signature
local sig = ('%s:%s:%s:%s:%s:%s'):format(loc.x, loc.y, loc.radius, loc.count, poly and #poly or 0, sum)
local key = zoneId .. ':' .. idx
local c = scatterCache[key]
if c and c.sig == sig then return c.pts end
local pts = scatterRaw(zoneId, idx, loc)
scatterCache[key] = { sig = sig, pts = pts }
return pts
end
plants_config.lua
-- ════════════════════════════════════════════════════════════════════
-- nv_drugscreator (growing) – shared settings. The plants themselves (seed, harvest, growth stages, water, fertilizer, limits)
-- are set up in the `/drugs` UI (Growing tab) and stored in the DB (nv_plants_types), so nothing is tuned through commits.
-- ════════════════════════════════════════════════════════════════════
PConfig = {}
PConfig.WaterItem = 'water' -- default item for watering a new plant
PConfig.FertilizerItem = 'fertilizer' -- default item for fertilizing
PConfig.AddWater = 35 -- by how many % watering raises the water level
PConfig.AddFertilizer = 30 -- o kolik % zvedne hnojivo
PConfig.StartWater = 50
PConfig.StartFertilizer = 50
PConfig.ActionMs = 5000 -- duration of watering, fertilizing and harvesting
PConfig.PlantAnim = { dict = 'amb@world_human_gardener_plant@male@base', clip = 'base' }
PConfig.WaterAnim = { dict = 'timetable@gardener@filling_can', clip = 'gar_ig_5_filling_can' }
PConfig.TargetDistance = 2.0
PConfig.StreamDistance = 60.0
PConfig.TickSec = 60 -- how often the server advances growth and drains water/fertilizer
PConfig.SaveSec = 300 -- how often the state is saved to the DB (and when the resource stops)
-- ── processing (workbenches): the weed table item (weed_table), public workbenches placed by admins (/drugbench) and the bags (empty_bag) ──
-- A recipe takes `need` pieces of `input` (+ `extra` = { item, count }) and gives `outCount` of `output`.
-- strain recipes (weed) are chosen per strain and carry the strain and the average quality of the used pieces;
-- noStrain = true: one plain recipe without metadata; inv = true: also available by using an empty bag from the inventory (no bench needed).
-- Add or change recipes here, the menu follows PConfig.TableOrder.
PConfig.MaxTables = 3 -- how many tables one player may have placed
PConfig.TableModel = 'prop_tool_bench02'
PConfig.Strains = { -- weed strains from the labs (metadata.strain)
{ id = 'ak47', label = 'AK-47' }, { id = 'banana', label = 'Banana Kush' },
{ id = 'purple', label = 'Purple Haze' }, { id = 'widow', label = 'White Widow' },
}
PConfig.TableOrder = { 'dry', 'trim', 'pack', 'coke', 'opium' }
PConfig.TableRecipes = {
dry = { label = _L('dry_weed'), icon = 'fa-solid fa-sun', title = _L('drying_weed'), input = 'weed_wet', need = 4, output = 'weed_dry', outCount = 4, keepStrain = true, ms = 8000,
anim = { dict = 'amb@prop_human_bum_bin@base', clip = 'base', flag = 1 } },
trim = { label = _L('trim_weed'), icon = 'fa-solid fa-scissors', title = _L('trimming_weed'), input = 'weed_dry', need = 4, output = 'weed_bud', outCount = 3, keepStrain = true, ms = 7000,
anim = { dict = 'amb@prop_human_bum_bin@base', clip = 'base', flag = 1 } },
pack = { label = _L('pack_weed'), icon = 'fa-solid fa-box', title = _L('packing_weed'), input = 'weed_bud', need = 3, extra = { 'empty_bag', 1 }, outCount = 1, ms = 3500, inv = true, -- output weed_<strain>
anim = { dict = 'mp_common', clip = 'givetake1_a', flag = 49 } },
coke = { label = _L('pack_cocaine'), icon = 'fa-solid fa-snowflake', title = _L('packing_cocaine'), noStrain = true, input = 'coca_leaf', need = 10, extra = { 'empty_bag', 1 }, output = 'coke_bag', outCount = 1, ms = 6000, inv = true,
anim = { dict = 'mp_common', clip = 'givetake1_a', flag = 49 } },
opium = { label = _L('process_opium'), icon = 'fa-solid fa-seedling', title = _L('processing_opium'), noStrain = true, input = 'poppy_pod', need = 6, output = 'opium_raw', outCount = 1, ms = 7000,
anim = { dict = 'amb@prop_human_bum_bin@base', clip = 'base', flag = 1 } },
}
-- Surface materials treated as grass (the "Grass only" option on a plant).
PConfig.GrassMaterials = { -1595148316, 435688960, 223086562, 1333033863, -461750719, 1109728704, 951832588 }
-- ── wild weed from harvest spots (weed_wet): strain and quality, so it can go straight into the lab dryer ──
PConfig.WildWeedStrain = 'ak47'
PConfig.WildQuality = { 35, 65 }