RedM documentation
Murphy's Doctor
Developers
Framework adapters
Everything murphy_doctor needs from a framework goes through a small set of global functions defined by an adapter: one file on the server (server/adapters/<Name>Adapter.lua) and one on the client (client/adapters/<Name>Adapter.lua). The rest of the script only calls these globals, never the framework directly.
Both adapter folders and shared/framework.lua are outside the escrow (escrow_ignore): premium and open source buyers can read, edit and add adapters. This page describes the contract and how to adapt the script to a forked or custom framework. For the behaviour of the shipped adapters on a live server, see Frameworks.
How an adapter is selected
shared/config.lualoads first and setsConfig.framework.shared/framework.lua(loaded next, on both sides) turns that value into one canonical key,Config.FrameworkResolved:"REDEMRP2k23","vorp"or"rsg". With"auto", it probes the resources listed inPROBESand takes the first one started. Explicit values go through theALIASEStable. It also definesIsFramework(key).Every adapter file is wrapped in a guard:
if Config.FrameworkResolved == "vorp" then -- functions endOnly the adapter whose key matches defines its functions.
The manifest loads shared/**/*.lua, client/**/*.lua and server/**/*.lua in alphabetical order: server/adapters/ loads before the other server files, and the client files whose name starts with _ load before client/adapters/. A new adapter file dropped in either folder is loaded without any manifest change.
The shipped files:
| Key | Server | Client |
|---|---|---|
REDEMRP2k23 |
server/adapters/REDEMRP2k23Adapter.lua |
client/adapters/REDEMRP2k23Adapter.lua |
vorp |
server/adapters/VORPAdapter.lua |
client/adapters/VORPAdapter.lua |
rsg |
server/adapters/RSGAdapter.lua |
client/adapters/RSGAdapter.lua |
Server adapter
src, targetID and targetSrc are always a player server id.
Required
Missing any of these is reported by doc_selftest as [FAIL] adapter functions missing: ....
| Function | Returns | Contract |
|---|---|---|
GetCharIdentifier(src) |
string or nil |
The character id, the key of every murphy_doctor_* row. nil while no character is loaded. Must stay the same for the whole life of that character (cache it per src if the lookup is costly, and clear the cache when the player drops or switches character) |
GetCharFirstname(src) |
string |
First name. Return "Unknown" when not found |
GetCharLastname(src) |
string |
Last name. Return "Unknown" when not found |
GetCharGroup(src) |
string or nil |
Staff group, compared with Config.AdminGroups |
GetCharJob(src) |
string or nil |
Job name, compared with Config.DoctorJobs, Config.Incidents.LawJobs and Config.Autopsy.LawJobs |
GetPlayerMoney(src) |
number |
Cash the player carries |
AddMoneyToPlayer(src, amount) |
boolean |
Give cash. true on success |
RemoveMoneyFromPlayer(src, amount) |
boolean |
Take cash. Must return false, without taking anything, when the player cannot afford it |
GiveItem(src, item, amount, meta) |
truthy / falsy | Add an item. meta is an optional metadata table (the poison payload, or { description = ... }) |
RemoveItem(src, item, amount, meta) |
truthy / falsy | Remove an item. When meta is given, remove from the stack carrying that metadata (a poisoned item), not from any stack |
GetItemAmount(src, item) |
number |
Total count of the item, every stack included (0 when none) |
FrameworkRegisterUsableItem(itemName, cb) |
- | Make the item usable. When the player uses it, call cb(src, usedItem) with usedItem = { name = itemName, meta = <metadata of the used stack, or nil> } |
Also called
These are called without an existence check by the script: implement them too.
| Function | Returns | Contract |
|---|---|---|
FrameworkCloseInventory(src) |
- | Close the player's inventory screen (an item that opens a menu or starts an animation) |
GetPlayerInventory(src) |
table (array) |
The items the player carries with a count above 0, each as { name, amount, quantity, label, image, metadata } (slot optional). image must be a URL the interface can load, such as nui://<inventory>/html/.... Used by the treatment form (medication stock) and the poison menu |
GetItemMeta(src, item) |
table or nil |
Metadata of a stack of that item. Used to read and write the poison mark |
getItemLabel(name) |
string |
Display label of an item, the item name as fallback |
Optional
Each call site checks that the function exists.
| Function | Returns | Used for |
|---|---|---|
GetCharJobDuty(src) |
boolean or nil |
On-duty flag of the job, for Config.Interactions.DoctorJobRequireDuty. Return false only when the player is known to be off duty. When the function does not exist and the option is on, a console line says the restriction is ignored |
FrameworkSetDead(src, isDead) |
- | Mirror the coma into the framework's own dead flag (called on coma entry, restore and exit) |
FrameworkIsDead(src) |
boolean or nil |
Read that flag back, for the debug command doc_frameworkdead |
FrameworkRefreshInventory(src) |
- | Resend the inventory to the client after a removal targeted by metadata, for inventories that do not do it themselves |
getItemDefs() |
table |
Item definitions keyed by name. doc_selftest uses it to check that the configured items exist; return {} if your inventory cannot list them |
Defined by the shipped adapters, not called
GetCharJobGrade(src), getItemPrice(name) and ResolveIdentifierByName(firstName, lastName) (and GetAllItemsOfName on REDEM:RP) exist in the shipped adapters but are not called by version 1.0.1. You may leave them out of a new adapter.
Framework events to handle in the server adapter
| Situation | What to do |
|---|---|
| The player switches character during a session | Clear any identifier cache for that src (the VORP adapter listens to vorp:SelectedCharacter, the RSG one to RSGCore:Server:OnPlayerLoaded) |
| The player drops | Clear the cache (playerDropped) |
| An admin or another script revives a player through the framework | Call AuthorizeComaExit(target) before that revive reaches the client, so the server accepts the early coma exit (Config.Coma.ServerExitCheck). The VORP adapter does it on vorp_core:Server:OnPlayerRevive, the RSG one on rsg-adminmenu:server:playerrevive after checking the admin's permission |
How the shipped adapters fill the contract
| Function | REDEM:RP | VORP | RSG |
|---|---|---|---|
GetCharIdentifier |
user.citizenid |
character.charIdentifier (as text) |
PlayerData.citizenid |
GetCharGroup |
user.group |
Account group if listed in Config.AdminGroups, else character group |
Permission probe, then the command ACE, else "user" |
GetCharJob |
user.job |
character.job |
PlayerData.job.name |
GetCharJobDuty |
not defined | always nil |
PlayerData.job.onduty |
| Money | user.money, addMoney, removeMoney |
character.money, addCurrency(0, ...), removeCurrency(0, ...) |
money.cash, AddMoney('cash', ...), RemoveMoney('cash', ...) |
| Items | redemrp_inventory item object (getItem, AddItem, RemoveItem) |
exports.vorp_inventory (addItem, subItem, getItemCount, getItem, getUserInventoryItems) |
exports['rsg-inventory'] (AddItem, RemoveItem, GetItemCount, GetItemByName) |
FrameworkRegisterUsableItem |
Local event RegisterUsableItem:<name> |
exports.vorp_inventory:registerUsableItem |
RSGCore.Functions.CreateUseableItem |
getItemDefs |
exports.redemrp_inventory:GetItemsList() |
Lookup table: Config.Items first, then exports.vorp_inventory:getItemDB(name) on access |
RSGCore.Shared.Items |
FrameworkSetDead |
no-op | character.setDead or the vorp:ImDead relay |
SetMetaData('isdead', ...) |
FrameworkRefreshInventory |
yes | not defined | not defined |
FrameworkIsDead |
not defined | character.isdead |
not defined |
Client adapter
| Function | Required | Contract |
|---|---|---|
FrameworkRevivePlayer() |
yes | Resurrect the local ped where it lies when the player gets up after the coma (or is revived by a doctor): NetworkResurrectLocalPlayer at the current position and heading, restore health and cores, clear tasks and blood. Do not teleport, do not reload the skin. Tell the framework the player is alive if it keeps a flag |
FrameworkNotifyLeft(title, message, dict, icon, duration) |
no | Show a notification with the framework's own system, used when Config.NotifyStyle = "framework". dict and icon are a texture dictionary and texture name of the game. Without it, the game's own notification is used |
The client adapter must also wire two framework signals:
Character loaded. Each time a character enters the world (first spawn and character switch), fire the local event
playerSpawnedormurphy_doctor:playerSpawned. The script then confirms with the server thatGetCharIdentifierreturns a value, loads that character's health and restores a saved coma. On REDEM:RP the character selection already firesplayerSpawned; the VORP adapter relaysvorp:SelectedCharacter, the RSG oneRSGCore:Client:OnPlayerLoaded.RegisterNetEvent("myframework:client:characterLoaded") AddEventHandler("myframework:client:characterLoaded", function() TriggerEvent("playerSpawned") end)Revived by something else. When the framework, an admin tool or another script revives the player, close the coma state:
RegisterNetEvent("myframework:client:revived") AddEventHandler("myframework:client:revived", function() if IsInComa and IsInComa() then CleanupComaState() end end)
Globals available to client adapters: Config, dbg(...), L(key, ...), IsInComa(), CleanupComaState(), NativeNotify(title, message, kind, duration). On the server: Config, dbg, L, MySQL (oxmysql) and AuthorizeComaExit(src).
Adapting the script
A fork with the same API under another resource name
If your framework is a fork of a supported one (same functions, but the core resource has another name), keep the existing key and only change names:
Set
Config.frameworkto the matching key ("vorp","rsg"or"REDEMRP2k23"), so the automatic probe is not needed. Or add your resource name toPROBESinshared/framework.lua, pointing to that key:local PROBES = { { resource = "redem_roleplay", key = "REDEMRP2k23" }, { resource = "vorp_core", key = "vorp" }, { resource = "my_vorp_fork", key = "vorp" }, { resource = "rsg-core", key = "rsg" }, }In the adapter of that key, replace the export names (
exports.vorp_core,exports.vorp_inventory,exports['rsg-core']...) and any event name that differs.
Keeping an existing key keeps every behaviour tied to it: the startup install check, and the cleanup of deleted characters, which reads the framework's own character table for the three shipped keys (characters.citizenid, characters.charidentifier, players.citizenid).
Another inventory
To use an inventory other than the framework's default one, edit only the inventory functions of your framework's server adapter: GiveItem, RemoveItem, GetItemAmount, GetItemMeta, GetPlayerInventory, FrameworkRegisterUsableItem, FrameworkCloseInventory, getItemLabel, getItemDefs (and FrameworkRefreshInventory if your inventory does not refresh itself). Keep the return formats of the tables above, in particular:
GetItemAmountcounts every stack, with or without metadata;RemoveItemwith ametatable removes from the stack carrying that metadata;- the
cbofFrameworkRegisterUsableItemreceives the metadata of the used stack, which is how a poisoned item is recognised.
Remove the usable item registrations of other scripts for the same item names, or both scripts react to the item.
A new framework
Key. In
shared/framework.lua, add your key toALIASES(lowercase config value to key) and toPROBES(resource to detect, key):local ALIASES = { -- existing entries... ["myframework"] = "myframework", } local PROBES = { -- existing entries... { resource = "my_core", key = "myframework" }, }Files. Copy the pair of adapters closest to your framework, for example
server/adapters/VORPAdapter.luatoserver/adapters/MyFrameworkAdapter.luaand the same on the client. Change the guard on the first line of each toif Config.FrameworkResolved == "myframework" then.Functions. Rewrite each function of the contract for your framework's API. Start with the required ones, then the "also called" ones.
Signals. In the client adapter, fire
playerSpawnedwhen a character loads and callCleanupComaState()on external revives. In the server adapter, callAuthorizeComaExiton framework revives, and clear identifier caches on character switch.Death handling. Turn off your framework's own death screen and respawn timer, as for the supported frameworks.
Test. Start the server with
Config.framework = "myframework"(or"auto") and rundoc_selftest <yourServerId>in the server console. It lists missing adapter functions, tables and item names, and shows your character id and staff status. Then check the startup lineUsable items registered ...and try a bandage, a revive and a treatment in game.
With a new key, the startup install check has nothing to test and the cleanup of deleted characters does not run (set Config.CleanDeletedCharacters = false to make that explicit). Everything else works the same.
Skeleton:
The names my_core, my_inventory and their functions are placeholders: replace them with your framework's real API.
Debug helpers
With Config.Debug = true, these staff commands help test an adapter from the server console (they need a staff group or the console):
| Command | Effect |
|---|---|
doc_giveitem <serverId> <item> [count] [description] |
Calls GiveItem (with a description metadata when given) and prints the result |
doc_itemcount <serverId> <item> |
Prints GetItemAmount |
doc_useitem <serverId> <item> |
Runs the consumable flow for that item, as if the player used it |
doc_frameworkdead <serverId> |
Prints FrameworkIsDead |
doc_selftest is available without Config.Debug.
Last updated: November 20, 2026