RedM documentation

Murphy's Doctor

Developers

Developer guide


This section is for server developers who want to connect their own resources to murphy_doctor: read a player's health from a HUD, revive from an admin menu, bill from a shop, list death certificates in a law job, and so on. Nothing here requires editing the escrowed files.

Pages

Page Content
Server exports Every server export, grouped by system
Client exports Every client export, grouped by system
Events Events you can listen to or trigger, framework events the script reacts to, internal events
Callbacks The built-in callback system and the list of registered callbacks
State bags State bag keys the script writes or reads
NUI (user interface) The NUI contract: messages, callbacks, building and restyling the React UI
Extension points Where to plug your own code without touching escrowed files, with examples
Framework adapters The framework adapter contract (server and client)

Related pages: Configuration, Integrations, Notifications, Database, Localization, Commands.

What you can edit

Path Escrowed Notes
shared/ (configs, locales, injury tables, callback helper) no All configuration lives here
client/ (every client script) no Readable and editable, including the client adapters
server/adapters/ no Framework bridge: identifiers, money, items, usable items, dead flag
server/*.lua (everything else) yes Use the exports and events documented here
ui/build/ no Built UI: locales, config.js, images
ui_src/ not applicable React source of the UI, shipped with the open source package

Editing a client file is possible, but every edit has to be carried over by hand when you update the resource. Prefer exports, events and config functions whenever they cover your need.

Architecture

Each piece of state has one owner. Writing to it from the wrong side does nothing lasting, so check this table before choosing between a client and a server export.

State Owner Persisted in How others read it
Injuries (per body part) client of the player murphy_doctor_health.injuries (synced by the client) client GetLocalHealthData, events injuryAdded / injuryRemoved
Conditions (cold, hot, bleeding, poisoned...) client murphy_doctor_health.conditions client GetLocalHealthData
Coma screen, timer, camera client murphy_doctor_coma (written by the server from the client report) client IsInComa, state bag murphy_doctor:coma
Hunger, thirst client murphy_doctor_health client GetHunger / GetThirst
Body temperature client murphy_doctor_health.temperature client GetBodyTemperature
Alcohol level (drunkenness) client not persisted client GetAlcoholLevel
Diseases, incubation server murphy_doctor_health.diseases server GetMedicalFile, client GetLocalHealthData().diseases (pushed every 30 s)
Immunities (vaccines) server murphy_doctor_health.immunities server IsImmune, GetImmunityExpiry
Liver wear server murphy_doctor_health.alcohol_wear server GetLiverWear
Addictions server murphy_doctor_addictions server GetAddictions, client GetAddictionState
Invoices server murphy_doctor_invoices server GetUnpaidInvoices
Incidents (coma records) server murphy_doctor_incidents server GetIncidents, event incidentRecorded
Death certificates server murphy_doctor_certificates server GetDeathCertificates, event deathCertificate
Dispensary treasury, duty server dispensary tables server IsDoctorOnDuty, client event dutyChanged
Doctor status server (framework job, members table, whitelist) members table server IsPlayerDoctor, client IsPlayerDoctor (asks the server)
Transport (carried, stretcher, bed) server not persisted server GetTransportState, state bag murphy_doctor:moved

The client of each player detects damage, builds injuries, runs metabolism and temperature, and pushes the results to the server, which keeps a cache and saves it. This is why most "act on a player" exports are client exports: to add an injury to another player, trigger your own client event on that player and call the client export there.

The server owns everything that must not be forged: diseases, immunities, money, invoices, records, the coma timer (Config.Coma.ServerExitCheck) and every doctor action, which is re-validated server side (doctor status, distance, items, cooldowns).

Identifiers

Name in these pages Meaning
src, serverId, target The server id of a connected player
charid, identifier The character identifier returned by the adapter's GetCharIdentifier(src), as a string
Framework charid
REDEM:RP 2023 citizenid
VORP charIdentifier (converted to a string)
RSG citizenid

Every murphy_doctor_* table is keyed by charid. A player who has not selected a character yet has no charid: exports that need one return false, nil or an empty table.

Constants

Body parts: head, belly, left-arm, right-arm, left-leg, right-leg, left-foot, right-foot.

Injury types (InjuriesConfig.Types in shared/injuries_types.lua): bruised, blunt, cut, projectile, fractured, burned, bleeding, concussion, hypothermia, heatstroke, poisoned.

Severities: minor, moderate, severe.

Coma causes (Config.Coma.CauseCooldowns, labels in causes.* of the locale files): beaten, fall_minor, stabbed, slashed, animal, fall, shot, burned, explosion, drowned, poisoned, headshot, unknown.

Disease ids: the id of each entry of Config.Treatment.GrimoireEntries (shared/config_treatment.lua). Shipped ids: bruised, blunt, fractured, cut, projectile, poisoned, grippe, pneumonie, tuberculose, typhoide, fievre_jaune, cholera, paludisme, sepsis, tetanos, dysentery, rage, scorbut, intox_alcool, morsure_serpent, variole, syphilis, dehydration, cirrhosis. The staff command /doc:disease list prints the ids of your own config.

Addiction substances (keys of Config.Addiction.Substances): alcohol, tobacco, opiates.

Condition flags (LocalHealthData.conditions): cold, hot, bleeding, poisoned, dirty, heavy; the server also tracks fever.

Module guards

Optional systems live in their own files and stop at the top of the file when their module is disabled. Their exports are then not registered at all, and calling them raises a "No such export" error. The table lists every export that depends on a module switch.

Export(s) Side Registered only when
GetAddictions, ReduceAddiction server Config.Addiction.Enabled
GetAddictionState client Config.Addiction.Enabled
IsDoctorOnDuty server Config.Duty.Enabled
GetUnpaidInvoices server Config.Billing.Enabled
GetIncidents server Config.Incidents.Enabled
GetActiveOutbreaks, StartOutbreak, StopOutbreak server Config.Epidemics.Enabled
GetDeathCertificates server Config.Autopsy.Enabled is not false
GetMedicalFile server Config.Records.Enabled is not false
GetTransportState server Config.Transport.Enabled is not false
OpenCallBoard client Config.HelpCall.Board.Enabled is not false

Some exports are always registered but do nothing when their module is off: TryInfect and RollConsumableInfection return false without Config.Infection.Enabled, OnAlcoholConsumed is a no-op without Config.Alcohol.Enabled, StartSurgery returns without Config.Surgery.Enabled, OpenPoisonMenu returns without Config.Poison.Enabled, ShowMetabolismHUD returns without Config.Metabolism.Enabled, and the hunger / thirst setters ignore calls when Config.Metabolism.HungerThirstEnabled is false.

Load order

The manifest loads, in this order:

  1. shared/**/*.lua on both sides: configuration files, shared/framework.lua (resolves Config.framework into Config.FrameworkResolved), injury tables, locales and shared/Callbacks.lua.
  2. Client: client/**/*.lua. Files whose name starts with _ (_character.lua, _fx.lua, _vitals.lua) load before the modules that use them. Each adapter in client/adapters/ only runs when it matches Config.FrameworkResolved.
  3. Server: @oxmysql/lib/MySQL.lua, then server/**/*.lua, adapters included under the same rule.

The framework must be started before murphy_doctor, and murphy_doctor before any resource that calls its exports at start. Most tables are created automatically a few seconds after start; see Database.

Calling exports safely

Exports are synchronous calls into the resource. Two things can go wrong: the resource is not started, or the export is not registered because its module is disabled. Guard generic code:

lua
local function doctorRunning()
return GetResourceState("murphy_doctor") == "started"
end
-- Returns the value, or nil when the resource or the export is unavailable.
local function doctor(name, ...)
if not doctorRunning() then return nil end
local ok, result = pcall(function(...)
return exports.murphy_doctor[name](exports.murphy_doctor, ...)
end, ...)
if not ok then return nil end
return result
end
-- client
local inComa = doctor("IsInComa") == true
-- server
local invoices = doctor("GetUnpaidInvoices", charid) or {}

Things to keep in mind:

  • An export that returns several values (for example GetTransportState) loses the extra values through the helper above. Call it directly when you need them.
  • Some client exports wait for the server: IsPlayerDoctor blocks the calling thread up to 2 seconds when its 30 second cache is cold. Use IsLocalPlayerDoctorCached for per-frame or menu-visibility checks.
  • Several server exports run a synchronous database query (GetIncidents, GetDeathCertificates, GetMedicalFile, GetUnpaidInvoices). Call them from a thread, not from a tight loop.
  • Do not write into tables returned by exports such as GetLocalHealthData: they are the live tables of the script.

Server events from clients

Every murphy_doctor:* server event that a client can trigger is validated on the server (doctor status, distance, items, cooldowns, value clamps). These events are internal: their arguments change between versions and they assume the script's own client state. Use the exports instead. The full list is in Events.


Last updated: November 20, 2026