⚙️ Exports & Events
Weed never sells anything itself: bags, joints and bricks are products for your own selling script, drug runs or gang economy. These exports give that script the reference value of every product, so prices stay in one place.
Server exports
GetProductValue
Lua
local value = exports.devhub_weed:GetProductValue('devhub_weed_bag_kush')
-- 358- Returns: the reference value of one unit of a weed product, or
nilfor any item that is not a weed product. - How it is calculated: the base value of the form times the multiplier of the strain, both editable in
/weedadmin. Changes in the panel apply straight away, the next call already returns the new value.
| Form | Item | Base value |
|---|---|---|
| Wet bud | devhub_weed_top_<strain> | 45 |
| Dried bud | devhub_weed_dry_<strain> | 110 |
| Joint | devhub_weed_joint_<strain> | 140 |
| Bag | devhub_weed_bag_<strain> | 320 |
| Brick | devhub_weed_brick_<strain> | 3900 |
| Strain | Multiplier |
|---|---|
| Base | 1.0 |
| Kush | 1.12 |
| Haze | 1.28 |
| Purple | 1.45 |
| Frost | 1.65 |
| Golden | 1.9 |
| Blue | 2.15 |
| Red | 2.45 |
| Albino | 2.8 |
A Kush bag is therefore 320 × 1.12 = 358.
Example: a selling script that pays the reference value with a random spread.
Lua
local value = exports.devhub_weed:GetProductValue(item)
if value then
local price = math.floor(value * math.random(85, 115) / 100)
Core.AddCash(source, price * amount)
endGetProducts
Lua
local products = exports.devhub_weed:GetProducts()
-- {
-- { item = 'devhub_weed_bag_kush', label = 'Kush Bag', variety = 'kush', form = 'bag', value = 358 },
-- ...
-- }- Returns: every product item (five forms for each of the nine strains) with its label, strain, form and reference value. Handy for building a buyer's menu or a price list on a phone app.
GetOutdoorPlantCount
Lua
local count = exports.devhub_weed:GetOutdoorPlantCount(source)- Returns: how many outdoor plants the player owns right now. Warehouse pots are not counted.
Server events
Listen to these from any server script with AddEventHandler. They are local server events: a client can never trigger them.
devhub_weed:server:plantHarvested
Lua
AddEventHandler('devhub_weed:server:plantHarvested', function(source, identifier, variety, amount, info)
-- info = { plantId, owner, stranger, warehouseId, bucket, coords }
end)- When: once per plant, when its last bud is picked.
- amount: wet buds the whole plant gave, from every player who picked it, perks included.
- info.warehouseId: set when the plant stood in a warehouse,
niloutdoors. - info.stranger:
truewhen the last picker is not the owner.
Made for gang and crime organisation scripts that credit production to a group.
devhub_weed:server:wildBushEmptied
Lua
AddEventHandler('devhub_weed:server:wildBushEmptied', function(source, identifier, variety, amount, info)
-- info = { bushId, zone }
end)- When: a wild bush is picked empty.
amountis everything it gave since it grew back.
devhub_weed:server:warehouseEntered / warehouseLeft
Lua
AddEventHandler('devhub_weed:server:warehouseEntered', function(warehouseId, source) end)
AddEventHandler('devhub_weed:server:warehouseLeft', function(warehouseId, source) end)- When: a player walks into or out of a warehouse. While inside, the player is in the warehouse's own routing bucket, so this is the place to pause anything of yours that should not run in an instance (for example a radio or a phone signal).
devhub_weed:server:warehouseRemoved
Lua
AddEventHandler('devhub_weed:server:warehouseRemoved', function(warehouseId) end)- When: a warehouse is sold or removed by an admin. Its pots and stations are already deleted; the stash and the workers are cleared on this same event.
Server hooks
For logging, anticheat alerts and quest progress, use the OpenServer functions in configs/server.lua instead. They receive more detail than the events above.