Electus LogoElectus Documentation

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)
ParameterTypeRequiredDescription
sourcenumberYesPlayer server ID
substancestringNoSubstance 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)
ParameterTypeRequiredDescription
sourcenumberYesPlayer server ID
substancestringYesSubstance ID
levelnumberYesNew 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")
ParameterTypeRequiredDescription
sourcenumberYesPlayer server ID
amountnumberYesPoints to remove
substancestringNoSubstance 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 },
})
FieldTypeRequiredDescription
itemstringYesInventory item name
labelstringNoName shown in the dialog. Defaults to the item name.
pricenumberYesPrice per unit at full quality
maxnumberNoMost 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.

ExportUse
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)
FieldTypeDescription
itemstringInventory item name
labelstringItem label
countnumberUnits sold
totalnumberTotal payment
qualitynumberSold quality, from 0 to 100
personastringBuyer type
coordsvector3Deal 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 bagDescription
Player(source).state.drugAddictionWhole percentages by substance, for HUDs and other resources
GlobalState.electusDrugsStreetSellingtrue 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