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.
end)
AddEventHandler('randol_medical:onPlayerLastStand', function()
-- gets triggered on last stand
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 when the player gets revived.
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/similar system.
AddEventHandler('randol_medical:reviveNearestPlayer', reviveNearestPlayer)
AddEventHandler('randol_medical:healNearestPlayer', healNearestPlayer)
AddEventHandler('randol_medical:viewInjuries', viewInjuries)
AddEventHandler('randol_medical:toggleCheckins', toggleCheckins)
AddEventHandler('randol_medical:forceWalkNear', forceWalkNear)
RegisterNetEvent('hospital:client:Revive', revivePlayer) -- Backwards compat for original qb-ambulance. Comment this out if you don't need it.
RegisterNetEvent('esx_ambulancejob:revive', revivePlayer) -- Backwards compat for ESX. Comment this out if you don't need it.
RegisterNetEvent('qbx_medical:client:playerRevived', revivePlayer) -- Backwards compat for QBX. Comment this out if you don't need it.
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
-- [Experimental] Using this qb-prison server event to set player state for in/out prison so I can tell where to respawn them.
-- May need to adapt to third party prison resources.
RegisterNetEvent('prison:server:SetJailStatus', function(jailTime)
local src = source
if jailTime > 0 then
Player(src).state:set('jail', true, true)
else
Player(src).state:set('jail', false, true)
end
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
Last updated