π»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
endServer
Last updated