Skip to content

API Reference

Artmines edited this page Nov 6, 2025 · 2 revisions

API Reference

Complete reference for all events and exports available to developers.


Client Events

Wound Management

-- Receive updated wounds from server
RegisterNetEvent('QC-AdvancedMedic:client:SyncWoundData')

-- Load wounds on spawn
RegisterNetEvent('QC-AdvancedMedic:client:LoadWounds')

-- Admin command clear
RegisterNetEvent('QC-AdvancedMedic:client:ClearAllWounds')

Treatment Management

-- Server tells client to apply bandage
RegisterNetEvent('QC-AdvancedMedic:client:ApplyBandage')

-- Server tells client to apply tourniquet
RegisterNetEvent('QC-AdvancedMedic:client:ApplyTourniquet')

-- Server tells client to give medicine
RegisterNetEvent('QC-AdvancedMedic:client:AdministreMedicine')

-- Server tells client to give injection
RegisterNetEvent('QC-AdvancedMedic:client:GiveInjection')

-- Remove specific treatment
RegisterNetEvent('QC-AdvancedMedic:client:RemoveTreatment')

-- Load treatments on spawn
RegisterNetEvent('QC-AdvancedMedic:client:LoadTreatments')

Infection Management

-- Load infections on spawn
RegisterNetEvent('QC-AdvancedMedic:client:LoadInfections')

-- Apply infection cure
RegisterNetEvent('QC-AdvancedMedic:client:TreatInfection')

-- Sync infection data
RegisterNetEvent('QC-AdvancedMedic:client:SyncInfectionData')

Death & Revival

-- Activate death camera
RegisterNetEvent('QC-AdvancedMedic:client:DeathCam')

-- Player respawn
RegisterNetEvent('QC-AdvancedMedic:client:revive')

-- Admin revive
RegisterNetEvent('QC-AdvancedMedic:client:adminRevive')

-- Medic revive
RegisterNetEvent('QC-AdvancedMedic:client:playerRevive')

Inspection

-- Show medic inspection UI
RegisterNetEvent('QC-AdvancedMedic:client:ShowInspectionPanel')

-- Hide inspection UI
RegisterNetEvent('QC-AdvancedMedic:client:HideInspectionPanel')

Doctor Bag Tools (v0.2.9+)

-- Tool usage result from server (success/failure with inventory validation)
RegisterNetEvent('QC-AdvancedMedic:client:ToolUsageResult')

-- Updated medic inventory after tool usage
RegisterNetEvent('QC-AdvancedMedic:client:UpdateMedicInventory')

NUI Callback:

-- Client-side callback for NUI doctor bag tool usage
RegisterNUICallback('medical-action', function(data, cb)
    -- data.action = 'use-tool'
    -- data.target = tool action (e.g., 'smelling-salts', 'stethoscope', 'laudanum')
    -- data.playerId = target patient ID
    cb({status = 'pending', message = 'Processing...'})
end)

Tool Actions:

  • smelling-saltsrevive_unconscious (consumable)
  • stethoscopecheck_heart_lungs (non-consumable)
  • thermometercheck_temperature (non-consumable)
  • field-kitemergency_surgery (consumable)
  • laudanummedicine_laudanum (consumable, routes through medicine system)
  • whiskeymedicine_whiskey (consumable, routes through medicine system)

Server Events

Data Synchronization

-- Client sends wound changes
RegisterNetEvent('QC-AdvancedMedic:server:UpdateWoundData')

-- Client sends treatment changes
RegisterNetEvent('QC-AdvancedMedic:server:UpdateTreatmentData')

-- Client sends infection changes
RegisterNetEvent('QC-AdvancedMedic:server:UpdateInfectionData')

-- Client requests all medical data
RegisterNetEvent('QC-AdvancedMedic:server:LoadMedicalData')

Treatment Application

-- Medic treats patient
RegisterNetEvent('QC-AdvancedMedic:server:ApplyTreatment')

-- Log treatment removal
RegisterNetEvent('QC-AdvancedMedic:server:TreatmentRemoved')

-- Medic treats infection
RegisterNetEvent('QC-AdvancedMedic:server:TreatInfection')

Medical Inspection

-- Medic starts inspection
RegisterNetEvent('QC-AdvancedMedic:server:StartMedicalInspection')

-- Medic finishes inspection
RegisterNetEvent('QC-AdvancedMedic:server:CompleteMedicalInspection')

-- Request vitals data
RegisterNetEvent('QC-AdvancedMedic:server:CheckVitals')

Admin Actions

-- Revive command
RegisterNetEvent('QC-AdvancedMedic:server:RevivePlayer')

-- Set player health
RegisterNetEvent('QC-AdvancedMedic:server:SetHealth')

-- Death inventory wipe
RegisterNetEvent('QC-AdvancedMedic:server:deathactions')

Doctor Bag Tools (v0.2.9+)

-- Use doctor bag tool (validates inventory, removes item if consumable)
RegisterNetEvent('QC-AdvancedMedic:server:UseDoctorBagTool')
-- Parameters: toolAction (string), targetPlayerId (string)
-- Triggers: QC-AdvancedMedic:client:ToolUsageResult on success/failure

-- Refresh medic's inventory after item usage
RegisterNetEvent('QC-AdvancedMedic:server:RefreshMedicInventory')
-- Sends updated inventory to client via UpdateMedicInventory event

Flow:

  1. Medic opens doctor bag (inventory checked when /inspect command runs)
  2. Medic clicks tool → medical-action NUI callback → UseDoctorBagTool server event
  3. Server validates inventory:
    • Consumable items: Attempts RemoveItem(), returns failure if not in inventory
    • Non-consumable items: Checks GetItemByName(), returns failure if missing
    • Medicine items: Routes to existing medicine system after inventory check
  4. Server returns result via ToolUsageResult event
  5. Client displays notification (success/failure message)
  6. If inventory changed, client triggers RefreshMedicInventory to update NUI

Client Exports

Wound Management

-- Get all wounds
local wounds = exports['QC-AdvancedMedic']:GetPlayerWounds()

-- Get total bleeding level
local bleeding = exports['QC-AdvancedMedic']:GetBleedingLevel()

-- Add a wound manually
exports['QC-AdvancedMedic']:AddWound(bodyPart, pain, bleed, weapon)

-- Remove a wound
exports['QC-AdvancedMedic']:RemoveWound(bodyPart)

-- Clear all wounds
exports['QC-AdvancedMedic']:ClearAllWounds()

Example:

-- Check if player is bleeding
local bleeding = exports['QC-AdvancedMedic']:GetBleedingLevel()
if bleeding > 5 then
    print("Player is severely bleeding!")
end

-- Get all wounds
local wounds = exports['QC-AdvancedMedic']:GetPlayerWounds()
for bodyPart, wound in pairs(wounds) do
    if not wound.isScar then
        print(string.format("%s: Pain %d, Bleeding %d",
            bodyPart, wound.painLevel, wound.bleedingLevel))
    end
end

Treatment Application

-- Apply bandage
exports['QC-AdvancedMedic']:ApplyBandage(bodyPart, type, appliedBy)

-- Apply tourniquet
exports['QC-AdvancedMedic']:ApplyTourniquet(bodyPart, type, appliedBy)

-- Give medicine
exports['QC-AdvancedMedic']:AdministreMedicine(medicineType, appliedBy)

-- Give injection
exports['QC-AdvancedMedic']:GiveInjection(injectionType, appliedBy)

Example:

-- Apply cotton bandage to head
exports['QC-AdvancedMedic']:ApplyBandage('HEAD', 'cotton', GetPlayerServerId(PlayerId()))

-- Give morphine
exports['QC-AdvancedMedic']:AdministreMedicine('medicine_morphine', GetPlayerServerId(PlayerId()))

Infection Management

-- Get infection data for body part
local infection = exports['QC-AdvancedMedic']:GetInfectionData(bodyPart)

-- Treat infection
exports['QC-AdvancedMedic']:TreatInfection(bodyPart, item)

-- Get cure progress
local progress = exports['QC-AdvancedMedic']:GetCureProgress(bodyPart)

Example:

-- Check if body part is infected
local infection = exports['QC-AdvancedMedic']:GetInfectionData('LARM')
if infection then
    print(string.format("Infection Stage: %d", infection.stage))
    print(string.format("Cure Progress: %d%%", infection.metadata.cureProgress or 0))
end

Healing

-- Trigger healing check manually
exports['QC-AdvancedMedic']:ProcessWoundHealing()

-- Get healing timers
local timers = exports['QC-AdvancedMedic']:GetHealingTimers()

Server Exports

Database Operations

-- Save wound data (UPSERT)
exports['QC-AdvancedMedic']:SaveWoundData(citizenid, woundData)

-- Load wound data
local wounds = exports['QC-AdvancedMedic']:LoadWoundData(citizenid)

-- Save treatment data
exports['QC-AdvancedMedic']:SaveTreatmentData(citizenid, treatmentData)

-- Save infection data
exports['QC-AdvancedMedic']:SaveInfectionData(citizenid, infectionData)

-- Get complete medical profile
local profile = exports['QC-AdvancedMedic']:GetCompleteMedicalProfile(citizenid)

Example:

-- Get complete medical profile
local profile = exports['QC-AdvancedMedic']:GetCompleteMedicalProfile(citizenid)
print(json.encode(profile.wounds))
print(json.encode(profile.treatments))
print(json.encode(profile.infections))
print(json.encode(profile.fractures))
print(json.encode(profile.history))

Medical History

-- Log medical event
exports['QC-AdvancedMedic']:LogMedicalEvent(citizenid, eventType, bodyPart, details, performedBy)

-- Get medical history
local history = exports['QC-AdvancedMedic']:GetMedicalHistory(citizenid)

Event Types:

  • wound_created
  • wound_scarred
  • treatment_applied
  • treatment_removed
  • infection_started
  • infection_cured
  • medical_inspection
  • admin_clear_wounds
  • fracture_created
  • fracture_healed

Example:

-- Log a custom medical event
exports['QC-AdvancedMedic']:LogMedicalEvent(
    citizenid,
    'treatment_applied',
    'HEAD',
    json.encode({
        treatmentType = 'bandage',
        itemType = 'cotton',
        appliedBy = medicCitizenid
    }),
    medicCitizenid
)

Scar System

-- Create a scar
exports['QC-AdvancedMedic']:CreateScar(citizenid, bodyPart, scarData)

-- Get player scars
local scars = exports['QC-AdvancedMedic']:GetPlayerScars(citizenid)

Example:

-- Get all scars for player
local scars = exports['QC-AdvancedMedic']:GetPlayerScars(citizenid)
for bodyPart, scar in pairs(scars) do
    print(string.format("%s: %s", bodyPart, scar.metadata.description))
end

Job Validation

-- Check if job is a medic job
local isMedic = IsMedicJob(jobName)

Example:

local Player = RSGCore.Functions.GetPlayer(source)
if IsMedicJob(Player.PlayerData.job.name) then
    print("Player is a medic!")
end

Usage Examples

External Resource: Check Injuries

-- In your external resource
RegisterCommand('checkinjury', function()
    local wounds = exports['QC-AdvancedMedic']:GetPlayerWounds()
    local bleeding = exports['QC-AdvancedMedic']:GetBleedingLevel()

    if bleeding > 3 then
        print("You're bleeding badly!")
    end

    for bodyPart, wound in pairs(wounds) do
        if not wound.isScar then
            print(string.format("%s: Pain %d, Bleeding %d",
                bodyPart, wound.painLevel, wound.bleedingLevel))
        end
    end
end)

External Resource: Apply Treatment

-- In your custom medic script
RegisterCommand('quickheal', function()
    local playerId = PlayerId()
    local serverId = GetPlayerServerId(playerId)

    -- Apply bandage to head
    exports['QC-AdvancedMedic']:ApplyBandage('HEAD', 'sterile', serverId)

    -- Give morphine for pain
    exports['QC-AdvancedMedic']:AdministreMedicine('medicine_morphine', serverId)
end)

External Resource: Monitor Infection

-- In your survival script
CreateThread(function()
    while true do
        Wait(60000) -- Check every minute

        local wounds = exports['QC-AdvancedMedic']:GetPlayerWounds()
        for bodyPart, wound in pairs(wounds) do
            local infection = exports['QC-AdvancedMedic']:GetInfectionData(bodyPart)
            if infection and infection.stage >= 3 then
                -- Trigger fever effects, hallucinations, etc.
                print(string.format("Severe infection in %s!", bodyPart))
            end
        end
    end
end)

Server-Side: Custom Medical Report

-- In your admin panel
RegisterCommand('medreport', function(source, args)
    local targetId = tonumber(args[1])
    if not targetId then return end

    local Player = RSGCore.Functions.GetPlayer(targetId)
    if not Player then return end

    local profile = exports['QC-AdvancedMedic']:GetCompleteMedicalProfile(Player.PlayerData.citizenid)

    -- Count wounds
    local woundCount = 0
    for _ in pairs(profile.wounds or {}) do
        woundCount = woundCount + 1
    end

    -- Count infections
    local infectionCount = 0
    for _ in pairs(profile.infections or {}) do
        infectionCount = infectionCount + 1
    end

    TriggerClientEvent('chat:addMessage', source, {
        args = {
            'Medical Report',
            string.format('Wounds: %d | Infections: %d', woundCount, infectionCount)
        }
    })
end, true) -- Admin only

← Configuration | Next: Extending the System →

📖 QC-AdvancedMedic

🏠 Home


📚 Documentation

  1. Architecture
  2. Client Systems
  3. Server Systems
  4. Database Schema

⚙️ Configuration

  1. Configuration
  2. Translation System
  3. API Reference

🛠️ Development

  1. Extending the System
  2. Performance Optimization

⚠️ Support

  1. Known Issues

🔗 Links


v0.3.1-alpha

Clone this wiki locally