Electus Drugs Exports
Electus Drugs server exports, events and state bags for inventories and other resources.
All exports are server-side.
Addiction
Substance IDs are the keys of Config.Addiction.Substances. The defaults are weed, mushroom, mdma, cocaine and meth.
Get a player's addiction
local cocaine = exports.electus_drugs:GetAddiction(source, "cocaine")
local levels = exports.electus_drugs:GetAddiction(source)| Parameter | Type | Required | Description |
|---|---|---|---|
source | number | Yes | Player server ID |
substance | string | No | Substance ID |
Returns: number from 0 to 100 for one substance, or a table of levels by substance when substance is omitted.
Set a player's addiction
local success = exports.electus_drugs:SetAddiction(source, "meth", 25)| Parameter | Type | Required | Description |
|---|---|---|---|
source | number | Yes | Player server ID |
substance | string | Yes | Substance ID |
level | number | Yes | New level |
Returns: boolean success
Treat a player's addiction
Lowers one substance, or every substance, by amount. Use it for EMS, doctors or rehab items.
exports.electus_drugs:TreatAddiction(source, 50)
exports.electus_drugs:TreatAddiction(source, 25, "cocaine")| Parameter | Type | Required | Description |
|---|---|---|---|
source | number | Yes | Player server ID |
amount | number | Yes | Points to remove |
substance | string | No | Substance ID. Omit to treat every substance. |
Returns: boolean success
Street dealing
Add items to the street deal dialog
Lets another resource's drugs sell in the street deal dialog.
exports.electus_drugs:AddStreetSellItems({
{ item = "my_drug_bag", label = "My drug", price = 150, max = 5 },
})| Field | Type | Required | Description |
|---|---|---|---|
item | string | Yes | Inventory item name |
label | string | No | Name shown in the dialog. Defaults to the item name. |
price | number | Yes | Price per unit at full quality |
max | number | No | Most units per deal, from 1 to 20. Defaults to 3. |
Returns: boolean success
A new call replaces that resource's list, and its items are removed when the resource stops. Items already handled by Electus Drugs are ignored.
Inventory exports
Use these with inventories that call an export instead of framework usable items.
| Export | Use |
|---|---|
exports.electus_drugs:UseDrugItem(source, item) | Uses a drug item |
exports.electus_drugs:OpenCookbook(source, drug) | Opens a cookbook. drug is a key of Config.Cookbook.Books, such as weed or weed_full. |
exports.electus_drugs:UseSecurityItem(source, item) | Uses a keypad, door camera or reinforced door item |
exports.electus_drugs:UseTentItem(source, item) | Starts pitching a lab tent |
exports.electus_drugs:UseWaterCan(source) | Fills a water can |
Server events
These are server events for AddEventHandler. They are not net events.
electus_drugs:streetSale
Runs after each street sale.
AddEventHandler("electus_drugs:streetSale", function(source, sale)
print(("%s sold %dx %s for $%d"):format(source, sale.count, sale.label, sale.total))
end)| Field | Type | Description |
|---|---|---|
item | string | Inventory item name |
label | string | Item label |
count | number | Units sold |
total | number | Total payment |
quality | number | Sold quality, from 0 to 100 |
persona | string | Buyer type |
coords | vector3 | Deal location |
electus_drugs:withdrawal
Runs when a withdrawal wave hits a player.
AddEventHandler("electus_drugs:withdrawal", function(source, substance, level)
print(("%s is withdrawing from %s at %d%%"):format(source, substance, level))
end)State bags
| State bag | Description |
|---|---|
Player(source).state.drugAddiction | Whole percentages by substance, for HUDs and other resources |
GlobalState.electusDrugsStreetSelling | true while Electus Drugs runs street dealing |
Raid hook
Config.Raids.OnSeized in config/raids.lua runs on the server after a lab search:
Config.Raids.OnSeized = function(source, labId, report)
-- report holds counts: plants, beds, batches, cooks, gear, kinds
end