RedM documentation

Murphy's Doctor

Developers

Callbacks


murphy_doctor carries a small request/response helper in shared/Callbacks.lua. The client uses it to ask the server for data (patient health, treatment drafts, invoices...) and to submit doctor actions that need an answer.

Every callback is internal. The helper is a global table inside murphy_doctor's own Lua state: another resource cannot call Callback.triggerServer of murphy_doctor, and calling the transport events by hand would collide with the script's own request ids. To read or change data from another resource, use the server exports and client exports. This page explains how the system works so you can read the client files, and lists what each callback does.

How it works

The table Callback exposes three functions:

Function Side Description
Callback.register(name, fn) both Registers a handler. On the server, fn(src, ...) receives the calling player first. A name can be registered once.
Callback.triggerServer(name, cb, ...) client Sends the request; cb(result) runs when the server answers.
Callback.triggerClient(name, src, cb, ...) server Asks a client (no server code uses it in this version).

Transport: the client fires the network event murphy_doctor:triggerCallback with (name, requestId, resourceName, ...); the server runs the handler and answers with murphy_doctor:responseCallback (requestId, resourceName, result). Request ids are a counter from 0 to 65535 that wraps around.

Callbacks registered from a resource are dropped when that resource stops.

Flood guard

On the server, a player can call one callback at most 20 times per second. Past that, the call answers nil without running the handler (most callbacks read the database). A request whose name is not a string also answers nil.

Validation

A callback is a network event any client can fire, so every server handler validates its caller: doctor status, distance to the patient or to the bench, one-shot tokens for multi-step actions (surgery, injection, craft, autopsy), staff group for admin views, and value clamps. A client that is not allowed gets nil or { ok = false, error = ... }.

Waiting for an answer in a client file

The client files wrap the callback in a small wait loop when they need a synchronous answer:

lua
local function await(name, ...)
local done, result = false, nil
Callback.triggerServer(name, function(res) result = res; done = true end, ...)
local waited = 0
while not done and waited < 5000 do Wait(50); waited = waited + 50 end
return result
end

Registered callbacks

All names carry the murphy_doctor: prefix. The "Caller" column says who is accepted on the server.

Server callbacks

Callback Arguments Caller Purpose
isDoctor none anyone Doctor status of the caller (used by the client IsPlayerDoctor)
hasCharacter none anyone Whether the caller has a loaded character (character-ready probe)
getOwnHealth none anyone Caller's own health, diseases annotated with symptomatic
getSavedHealth charid (optional) self, or a doctor for someone else Cached health of a character
getMetabolismLayout none anyone Saved HUD positions of the caller
getPatientHealth targetServerId doctor, near the patient Examination data
getPatientComaStatus targetServerId doctor, near the patient Coma status of a patient
getTreatmentData targetServerId doctor Data of the treatment screen
getAvailableMedications none doctor Medications the doctor carries
trySignTreatment treatment data doctor Checks and consumes the prescribed items, applies the care, files the report
getSurgeryTargets targetServerId doctor Operable wounds of a patient
startSurgery { target, bodyPart, anesthesia } doctor Starts an operation, returns a one-shot token
finishSurgery { token, ... } the doctor holding the token Validates the result of the operation
startInjection targetServerId doctor Starts the syringe game, returns a token
finishInjection { token, ... } the doctor holding the token Validates the injection
autopsyFindings { kind, target or coords, ... } doctor, near the body Findings of an autopsy, returns a token
signCertificate { token, name, notes, signature } the doctor holding the token Writes the death certificate and its report
getMedicalFile { patientId } doctor or staff Medical file of a character
saveMedicalFile { patientId, bloodType, allergies, conditions, notes } doctor Saves the doctors' notes of a medical file
getDispensaryData dispensaryId anyone (members see more) Dispensary board data
isDoctorMember none anyone Whether the caller is a dispensary member
getArchivePatients { search, page, pageSize, dispensaryId } doctor Archive list, paginated
getArchivePatientsAll { search, page, pageSize } staff Archive list across every dispensary
getDiseases none anyone Disease list of the config
issueInvoice { patientServerId, amount, reason } doctor Bills a patient
getMyInvoices none anyone Caller's unpaid invoices
payInvoice { id } the billed patient Pays one invoice in cash
boardWithdraw { dispensaryId, amount } dispensary chief, at the board Withdrawal from the board
getTreasuryStatus none anyone Dispensaries the caller belongs to, and whether they are chief there
getTreasuryBalance { dispensaryId } member, on site Balance of a dispensary treasury
withdrawTreasury { dispensaryId, amount } chief (any member when Config.Nurse.Treasury.WithdrawChiefOnly = false), on site Withdrawal at the treasury point
toggleDuty { dispensaryId } member, near the duty point Clock in or out
collectPay { dispensaryId } member, near the duty point Collects the duty pay
getDutyStatus none anyone Caller's duty status
openCallBoard none available doctor Opens the help call board
closeCallBoard none anyone Stops sending board updates to the caller
callAction { id, action } available doctor Take, release or close a help call
getCraftRecipes benchIndex near the bench Recipes of an apothecary bench
startCraft { bench, id } near the bench Starts a preparation, returns a token
finishCraft { token, ... } the player holding the token Completes the preparation
transport { action, ... } depends on the action Carry, stretcher and bed actions

Callbacks of a disabled module are not registered (for example the billing callbacks without Config.Billing.Enabled). A call to an unregistered callback answers nil.

Client callbacks

Callback Purpose
getLocalHealthData Returns the local health table with live health, heart rate and state flags

Last updated: November 20, 2026