Checks & Listeners (Client)
Quality of life scripts for your FiveM server. Performance optimized resources that install in minutes, with free updates and support that actually answers.
bridge/client/main.lua
lua
--- Dead Check
---@return boolean
function IsDead()
local player = PlayerPedId()
return Config.DisallowDead and (LocalPlayer.state.isDead or IsEntityDead(player))
end
--- Carry Checks (if true then person being carried will be back on their feet / carry will be cancelled)
---@return boolean
function ChecksCarry()
local player = PlayerPedId()
return IsDead() or LocalPlayer.state.intrunk
end
--- InTrunk Checks (if true then the person will be thrown out of trunk)
---@param player number Player ped id
---@param vehicle number Vehicle entity id
---@return boolean
function ChecksInTrunk(player, vehicle)
local c1 = GetEntityCoords(player)
local c2 = GetEntityCoords(vehicle)
return #(c1 - c2) > 8 or GetVehicleEngineHealth(vehicle) < 100.0 or IsDead()
end
--- Check If trunk is full
---@param vehicle number Vehicle entity id
---@return boolean
function IsTrunkFull(vehicle, forceValue)
if Config.AllowMultipleInTrunk then
return forceValue
end
return Entity(vehicle).state.isintrunk
end
--- Get vehicle lock status
---@param vehicle number Vehicle entity id
---@return boolean
function IsVehicleLocked(vehicle)
if Config.CheckVehicleLocked then
local lockStatus = GetVehicleDoorLockStatus(vehicle)
return (lockStatus ~= 0) and (lockStatus ~= 1)
else
return false
end
end
--- This function is triggered when controls disabled loop is started (ref: Config.DisableControls)
function OnControlsDisabled()
-- Add your code here
end
--- This function is triggered when controls disabled loop is ended (ref: Config.DisableControls)
function OnControlsEnabled()
-- Add your code here
end
-- This function is triggered to fade in screen
function ScreenFadeIn()
if Config.EnableScreenFade then
DoScreenFadeIn(500)
end
end
-- This function is triggered to fade out screen
function ScreenFadeOut()
if Config.EnableScreenFade then
DoScreenFadeOut(500)
while IsScreenFadedOut() do
Wait(500)
end
end
end
local showingText = nil
--- Help Notification
---@param text string Text you want to show
function ShowText(text)
if Config.TextUI == 'ox_lib' then
if showingText ~= text then
showingText = text
lib.showTextUI(text, {
position = 'bottom-center',
style = {
backgroundColor = '#000000',
color = '#ffffff'
}
})
end
else
SetTextScale(0.5, 0.5)
SetTextFont(4)
SetTextRightJustify(true)
AddTextEntry('cadHelpNotification', text)
BeginTextCommandDisplayHelp('cadHelpNotification')
EndTextCommandDisplayHelp(0, false, true, -1)
end
end
--- Hide Notification (Only if you are using UI for notifications like lib.showTextUI)
function HideText()
if Config.TextUI == 'ox_lib' then
if showingText ~= nil then
lib.hideTextUI()
showingText = nil
end
end
end
--- Notification Event (To be triggered from server side files)
---@param text string Text you want to show
RegisterNetEvent('cad-carry:notify', function(text)
if Config.TextUI == 'ox_lib' then
lib.notify({ description = text })
else
ShowText(text)
end
end)
