Randolio Development
  • 👤Welcome
  • 💰Paid Scripts
    • 🏥Medical
      • ❌DEPENDENCIES
      • ❗QBCore Installation
      • ❗QBOX Installation
      • ❗ESX Installation
      • 💻Event/Functions
      • 👨‍💻Exports
      • 🤓Configuration
    • 📱ATM Hacking
    • ⛅Weather Sync
    • 🏚️Stash Houses
    • 💄Female Bundles
      • 🤖Discord Bot
      • 💻Exports
      • ➕Items/Images
    • 🪄Witchcraft
    • 🔌Gun Plugs
    • 📹News Job
    • 🗒️Vehicle List
Powered by GitBook
On this page
  • Client
  • Server
  1. Paid Scripts
  2. Medical

Event/Functions

A lot of handlers/functions are available to you in cl_open.lua.

Client

function DisableControls()
    -- List of controls here: https://docs.fivem.net/docs/game-references/controls/
    DisableAllControlActions(0)
    EnableControlAction(0, 1, true)
    EnableControlAction(0, 2, true)
    EnableControlAction(0, 245, true)
    EnableControlAction(0, 0, true)
    EnableControlAction(0, 322, true)
    EnableControlAction(0, 288, true)
    EnableControlAction(0, 213, true)
    EnableControlAction(0, 249, true)
    EnableControlAction(0, 46, true)
    EnableControlAction(0, 47, true)
    EnableControlAction(0, 33, true)
    EnableControlAction(0, 32, true)
end

function DispatchAlert()
    -- Triggered when a player presses E to alert ems. Cooldown of 2 minutes between calls.
    local data = exports['cd_dispatch']:GetPlayerInfo()
    TriggerServerEvent('cd_dispatch:AddNotification', {
        job_table = {'police', 'ambulance'}, 
        coords = data.coords,
        title = 'Civilian Down',
        message = 'A '..data.sex..' is requesting medical at '..data.street, 
        flash = 1,
        unique_id = data.unique_id,
        sound = 1,
        blip = { sprite = 431, scale = 1.2, colour = 3, flashes = false, text = '911 - Civilian Down', time = 5, radius = 0, }
    })
end

function dropBlood(coords)
    -- I grabbed this from qb-ambulancejob incase people still needed it. Will get triggered everytime a blood splat is on the floor.
    -- If you don't want to use this function, you can just leave it empty.
    TriggerServerEvent('evidence:server:CreateBloodDrop', PlayerData.citizenid, PlayerData.metadata.bloodtype, coords)
end

function preventLogging()
    -- This function will be called and is used to prevent death logs. Use case as an example is if you're in pug-paintball or something. See below:
    -- You'll be returning a true value to cancel the logging.
    if exports["pug-paintball"]:IsInPaintball() then
        return true -- This is just an example. You can remove this, add your own but keep the return false at the bottom.
    end

    return false
end

AddEventHandler('randol_medical:onPlayerDeath', function()
    -- gets triggered on death.
    if not LocalPlayer.state.invBusy then
        LocalPlayer.state:set('invBusy', true, true)
    end
    if not LocalPlayer.state.inv_busy then
        LocalPlayer.state:set('inv_busy', true, false)
    end
end)

AddEventHandler('randol_medical:onPlayerLastStand', function()
    -- gets triggered on laststand
    if not LocalPlayer.state.invBusy then
        LocalPlayer.state:set('invBusy', true, true)
    end
    if not LocalPlayer.state.inv_busy then
        LocalPlayer.state:set('inv_busy', true, false)
    end
end)

AddEventHandler('randol_medical:onCheckIn', function()
    -- Triggered when a player checks in/third eyes a bed.
    TriggerEvent('police:client:DeEscort')
end)

AddEventHandler('randol_medical:onRevive', function()
    -- gets triggered on revive
    if LocalPlayer.state.invBusy then
        LocalPlayer.state:set('invBusy', false, true)
    end
    if LocalPlayer.state.inv_busy then
        LocalPlayer.state:set('inv_busy', false, false)
    end
    TriggerEvent('police:client:DeEscort')
    TriggerServerEvent('evidence:server:RemoveNetPedImpacts') -- R14 Evidence thingy.
end)

-- Local player states which can be called across resources
if LocalPlayer.state.dead then
    print('do something, player is dead')
end

if LocalPlayer.state.laststand then
    print('do something, player is in last stand')
end

if LocalPlayer.state.isInHospitalBed then
    print('player is in hospital bed')
end

if LocalPlayer.state.knockedOut then
    print('player is knocked tf out')
end

if LocalPlayer.state.bleeding > 0 then
    print(LocalPlayer.state.bleeding) -- Prints the player's bleed level
end

-- Event handlers if you wanna use radial menu.
AddEventHandler('randol_medical:reviveNearestPlayer', function()
    reviveNearestPlayer()
end)

AddEventHandler('randol_medical:healNearestPlayer', function()
    healNearestPlayer()
end)

AddEventHandler('randol_medical:viewInjuries', function()
    viewInjuries()
end)

AddEventHandler('randol_medical:toggleCheckins', function()
    toggleCheckins()
end)

AddEventHandler('randol_medical:forceWalkNear', function()
    forceWalkNear()
end)

AddEventHandler('randol_medical:aiMedicCalled', function()
    -- gets triggered when an ai medical is called.
end)

RegisterNetEvent('hospital:client:Revive', function() revivePlayer() end)
RegisterNetEvent('esx_ambulancejob:revive', function() revivePlayer() end)
RegisterNetEvent('qbx_medical:client:playerRevived', function() revivePlayer() end)

function allowBleeding()
    -- This function will be called and is used to prevent bleeding. Use case as an example is if you're in pug-paintball or something. See below:
    -- You'll be returning a false value to cancel the bleeding being set.
    if GetResourceState('pug-paintball') == 'started' and exports["pug-paintball"]:IsInPaintball() then
        return false -- This is just an example. You can remove this, add your own but keep the return true at the bottom.
    end

    -- If you want to disable bleeding everywhere, you can just return false and remove the above portion.
    return true -- return true otherwise.
end

function preventKnockout()
     -- Just an example. If you want to avoid knockouts happening whilst using third party scripts, you must define something in that script and call it here
     -- to return true
    if LocalPlayer.state.isBoxing then -- EXAMPLE.
        return true
    end

    return false
end

Server

-- This handles reviving from the txadmin menu (sv_open.lua)
AddEventHandler('txAdmin:events:healedPlayer', function(eventData)
    if GetInvokingResource() ~= 'monitor' or type(eventData) ~= 'table' or type(eventData.id) ~= 'number' then
        return
    end
    TriggerClientEvent('randol_medical:client:revivePlayer', eventData.id)
end)

function PayForRevive(src)
    -- You can use this to pay the player or send it to a business account.
    local player = GetPlayer(src)
    if not player then return end

    addMoney(player, 'bank', Server.PayPerRevive.amount)
    DoNotification(src, ('You received $%s for treating the patient.'):format(Server.PayPerRevive.amount))
end

RegisterNetEvent('prison:server:SetJailStatus', function(jailTime)
     -- [Experimental] Using this qb-prison server event to set player state for in prison so I can tell where to respawn them.
     -- May need to adapt to third party prison resources.

     -- Would recommend using exports.randol_medical:SetJailState(src, true) for entering instead 
     -- and exports.randol_medical:SetJailState(src, false) for exiting in your actual prison script.
     
    local src = source
    if jailTime > 0 then
        Player(src).state:set('jail', true, true)
    else
        Player(src).state:set('jail', false, true)
    end
end)

function AddSocietyFunds(amount, reason)
    if amount == 0 then return end

    if GetResourceState('Renewed-Banking') == 'started' then
        return exports['Renewed-Banking']:addAccountMoney('ambulance', amount)
    end

    if GetResourceState('qb-banking') == 'started' then
        return exports['qb-banking']:AddMoney('ambulance', amount, reason)
    end

    if GetResourceState('qb-management') == 'started' then
        return exports['qb-management']:AddMoney('ambulance', amount)
    end

    -- local society = exports.esx_society:GetSociety('ambulance')
    -- if society then
    --     TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
    --         account.addMoney(amount)
    --     end)
    -- end

    lib.print.error('You must add your society funds export for function "AddSocietyFunds".')
end

function AutoBillPlayer(id, job) -- Adjust this yourself, example below.
    if not Server.AutoBill.enable then return end

    local player = GetPlayer(id)
    if not player then return end

    RemoveMoney(player, 'bank', Server.AutoBill.amount)

    if GetResourceState('Renewed-Banking') == 'started' then
        return exports['Renewed-Banking']:addAccountMoney(job, Server.AutoBill.amount)
    end

    if GetResourceState('qb-banking') == 'started' then
        return exports['qb-banking']:AddMoney(job, Server.AutoBill.amount, 'ems-bill')
    end

    if GetResourceState('qb-management') == 'started' then
        return exports['qb-management']:AddMoney(job, Server.AutoBill.amount)
    end

    -- local society = exports.esx_society:GetSociety('ambulance')
    -- if society then
    --     TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
    --         account.addMoney(amount)
    --     end)
    -- end

    lib.print.error('You must add your society funds export for function "AutoBillPlayer".')
end

 -- This is the revive event that can only be invoked from server side.
TriggerClientEvent('randol_medical:client:revivePlayer', source)
-- I have put the old qb-ambulance revive event in cl_open ('hospital:client:Revive') for compatability although i'd prefer not to use it.

-- Player states:
if Player(source).state.dead then
    print('player is dead')
end
PreviousESX InstallationNextExports

Last updated 4 months ago

💰
🏥
💻