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, and a medic's Treat overdose uses it too
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 Other scripts can hook a dose is turned on in the panel. The events above fire either way
resource/open/server/utility.luaCreateLog(data). Every line goes to ox_lib logging and the Discord webhook from the panel. Add your own logger here
resource/open/server/custom_effects.lua and resource/open/client/custom_effects.luaCustom effect ids, labels, and handlers
resource/open/client/forgery.luaOpenCanEnterForgery and OpenCanUseForgeryStation. Return false (and an optional reason) to block the entrance or the forge desk
resource/open/bridge/insurance/The insurance bridge files for Another script: insurance_minsurance.lua and insurance_custom.lua
resource/open/bridge/ambulancejobs/Ambulance job adapters, including the overdose-clearing listeners for MrNewb_Medical and Wasabi
resource/open/shared/job_checks.luaHow on-duty is read for a job, if your framework or duty system reports it differently

Block a medication under a condition

With Other scripts can hook a dose turned on in the panel, in medication_hooks.lua:

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

Build your own insurance

On the Plans page set Who handles the policy to Another script, 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