Events and hooks

Events other scripts can listen to, and the files you can edit in place.

In-development version. These docs cover the testing build of Prescriptions. The official release is still documented on the GitBook linked in its README.

Server events

Listen with AddEventHandler. These are local server events, not network events.

EventArgumentsFired when
MrNewbPrescriptions:MedicationConsumedsrc, payloadA dose is taken. payload has itemName, drugKey, metadata, medicaldata, and slot
MrNewbPrescriptions:MedicationTreatmentsrc, targetSrc, treatmentType, contextTriggerMedicationTreatment is called. Ambulance bridges use this to heal or revive
AddEventHandler('MrNewbPrescriptions:MedicationConsumed', function(src, payload)
    print(src, payload.drugKey, payload.metadata.uses)
end)

Anything else that starts with MrNewbPrescriptions: is internal. Do not build on it.

Open files

These stay readable after escrow, so you can edit them.

FileWhat it is for
resource/open/server/medication_hooks.luaCanUseMedication, OnMedicationConsumed, OnMedicationTreat. Only run when Medication hooks is turned on in the panel
resource/open/server/utility.luaCreateLog(data). Connect your logger here
resource/open/server/addiction_relief.luaLowers the addiction score from other scripts' events
resource/open/server/custom_effects.lua and resource/open/client/custom_effects.luaCustom effect ids, labels, and handlers
resource/open/client/medication_history.lua and resource/open/client/forgery.luaGate functions that can block the chart, sharing, the forgery entrance, or the forge desk
resource/open/bridge/insurance/Insurance provider: builtin, m-insurance, or custom
resource/open/bridge/banking/society_banking.luaSociety account adapters for pharmacy payouts
resource/open/bridge/ambulancejobs/Ambulance job adapters

Block a medication under a condition

With Medication hooks turned on in the panel, in medication_hooks.lua:

function CanUseMedication(src, payload)
    return not Player(src).state.isCuffed
end

Build your own insurance

Set the insurance provider to custom in the panel, then fill in ExternalInsuranceStatus, ExternalInsuranceCopay, and ExternalInsuranceSummary in insurance_custom.lua. Copy insurance_minsurance.lua as a starting point if that is easier.

On this page