Server exports

Server exports for Prescriptions. src is a player server id.

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

Call them as exports.MrNewbPrescriptions:Name(...) from a server script. src is a player server id.

Prescriptions

ExportReturnsNotes
CreatePrescription(src, { uses = n }, drugKey)booleanGives src a ready-to-use medication item. GivePlayerMedication is the same function. drugKey must exist in the catalog
WritePrescription(props)Rx number or nilWrites a paper script into the doctor record, pharmacy history, and the writer's inventory. See below
LookupPrescriptionByRx(rxNumber)row or nilThe doctor record for that Rx number
RevokePrescription(rxNumber, revokedBy)booleanRevokes it so it can no longer be filled
SearchDoctorRecords(term, { flaggedOnly = false })table[]Matches patient, doctor, medication, Rx, and note
SearchPharmacyAudit(jobName, term, limit)table[]Audit events for a pharmacy. limit is 1 to 100, default 50
GetPatientMedicationHistory(src)tableBottles on hand, unfilled scripts, and doctor history
RegisterPrescription(id, prescription)booleanAdds a catalog medication at runtime. name is required. See Medications and effects
RegisterEffect(id, label, handler?)Adds a custom effect label. See Medications and effects

WritePrescription takes src, drugKey, targetSrc, doses, and note, and optionally patientName, dob, patientIdentifier, refillsAllowed, expiresAt, time, gender, and rxNumber. With targetSrc, the patient name, date of birth, and identifier are filled in from that player. It returns nil if the doses are out of range, the name or date of birth is empty, or the paper cannot be carried.

Pharmacy stock

ExportReturnsNotes
GetPharmacyStock(jobName){ [item] = count }The job's stock room
AddPharmacyStock(jobName, item, count)true, newCountAdds stock
ConsumePharmacyStock(jobName, itemOrDrug, count)booleanRemoves stock. Pass a medication key to remove its whole recipe

Insurance

ExportReturnsNotes
GetInsurance(src)row or falseThe active coverage row
GetInsuranceStatus(src)booleanWhether they have active coverage
GetInsuranceCard(src)table or nilData for the insurance card view
ReturnInsuredRate(src, amount)numberWhat the patient pays after their copay. Returns amount unchanged when uninsured
PurchaseInsurance(src, tier)booleanBuys or switches plan. tier is a plan key from the Plans page. Charges full price, or only the difference on an upgrade. Notifies the player and returns false on failure
CancelInsurance(src)booleanEnds coverage

Addiction and overdose

ExportReturnsNotes
GetPlayerAddiction(src, item?)tableA snapshot, optionally for one item. Empty when untracked
ReducePlayerAddiction(src, amount, item?)booleanLowers the score. false when addiction is disabled
GetPlayerOverdoseState(src){ overdosing, withdrawing }Two booleans
ReverseOverdose(src, targetSrc?)booleanClears an overdose on targetSrc (or src) and applies the Narkhan score reduction
TriggerMedicationTreatment(src, targetSrc, treatmentType, context)booleanFires MrNewbPrescriptions:MedicationTreatment so ambulance bridges can heal or revive. treatmentType is an effect id such as clearinjuries, clearbleeds, health, or revive

Other scripts can also read Player(src).state.ndrugaddiction.

Examples

-- charge a patient their insured price
local pay = exports.MrNewbPrescriptions:ReturnInsuredRate(source, 500)

-- write a prescription for a nearby patient
local rx = exports.MrNewbPrescriptions:WritePrescription({
    src = doctorSrc,
    targetSrc = patientSrc,
    drugKey = 'mollis',
    doses = 3,
    note = 'One tablet daily.',
})
if not rx then print('could not write prescription') end

-- revoke one
exports.MrNewbPrescriptions:RevokePrescription('1234567890', 'Dr. Smith')

-- stock a pharmacy from another script
exports.MrNewbPrescriptions:AddPharmacyStock('pharmacy', 'emptybottle', 20)

-- bring someone back
local state = exports.MrNewbPrescriptions:GetPlayerOverdoseState(source)
if state.overdosing then
    exports.MrNewbPrescriptions:ReverseOverdose(source)
end

Client exports: Client exports. Events and hooks: Events and hooks.

On this page