πSLEEK DEATH SCREEN
Here check the installation guide
This script is compatible with ESX and QB
Compatible with esx_ambulancejob, qb_ambulance, wasabi_ambulance and ars_ambulancejob.
INSTALLATION GUIDE
Download from KEYMASTER and Unzip the
sleek-death.pack.zip
and place this folder in your server's resource folder.Add the resource to your server start config:
ensure sleek-death
, the name of the folder must not be changed or the resource will not function correctly.
ensure es_extended -- or qb-core
ensure sleek-death
You must delete any other death screens you have. To delete the ESX default you must:
esx_ambulancejob/client/main.lua -> line 357
(This can vary depending on the version you have):
OnPlayerDeath()
Clear the cache of your server and also of your own FiveM.
Reboot the entire server with the forge script well ensured in your server.cfg.
Download from KEYMASTER and Unzip the
sleek-death.pack.zip
and place this folder in your server's resource folder.Add the resource to your server start config:
ensure sleek-death
, the name of the folder must not be changed or the resource will not function correctly.
ensure es_extended -- or qb-core
ensure sleek-death
You must delete any other death screens you have. From
qb-ambulancejob
, you need to remove the following lines fromdead.lua
, related to the laststand event:--[[ elseif InLaststand then sleep = 5 if LaststandTime > Config.MinimumRevive then DrawTxt(0.94, 1.44, 1.0, 1.0, 0.6, Lang:t('info.bleed_out', { time = math.ceil(LaststandTime) }), 255, 255, 255, 255) else DrawTxt(0.845, 1.44, 1.0, 1.0, 0.6, Lang:t('info.bleed_out_help', { time = math.ceil(LaststandTime) }), 255, 255, 255, 255) if not emsNotified then DrawTxt(0.91, 1.40, 1.0, 1.0, 0.6, Lang:t('info.request_help'), 255, 255, 255, 255) else DrawTxt(0.90, 1.40, 1.0, 1.0, 0.6, Lang:t('info.help_requested'), 255, 255, 255, 255) end end if IsControlJustPressed(0, 47) and not emsNotified then TriggerServerEvent('hospital:server:ambulanceAlert', Lang:t('info.civ_down')) emsNotified = true end end --]]
If you have any doubts, you can download a modified dead.lua
file here. However, be cautious as it might belong to an older version than yours! It's better to manually delete the event.
Clear the cache of your server and also of your own FiveM.
Reboot the entire server with the forge script well ensured in your server.cfg.
CONFIG
The following will explain all the settings, one of the most important things that I recommend you spend a few minutes to understand in order to offer your users the best possible experience.
Config = Config or {}
-- _____ _____ _ _ ______ _____ _____ _ _______ ___ _____ _____ _____ _ _
-- / __ \ _ | \ | || ___|_ _| __ \ | | | ___ \/ _ \_ _|_ _| _ | \ | |
-- | / \/ | | | \| || |_ | | | | \/ | | | |_/ / /_\ \| | | | | | | | \| |
-- | | | | | | . ` || _| | | | | __| | | | /| _ || | | | | | | | . ` |
-- | \__/\ \_/ / |\ || | _| |_| |_\ \ |_| | |\ \| | | || | _| |_\ \_/ / |\ |
-- \____/\___/\_| \_/\_| \___/ \____/\___/\_| \_\_| |_/\_/ \___/ \___/\_| \_/
Config.framework = 'ESX' -- Options: 'ESX', 'QB'
-- General configuration
Config.ArsAmbulance = false -- Set to true to use Ars AmbulanceJob integration
Config.OspAmbulance = false -- Set to true to use OSP AmbulanceJob integration
Config.Timer = 300 -- 300 seconds equals 5 minutes. Time to bleed out
Config.ReviveTimer = 100 -- The seconds until the "Revive" button appears on the screen
Config.UseExtraButton = true -- If you activate this, a third button will appear which will apply a function or command of your choice. In the client_open you can add the function
Config.LoseItemsOnSuicide = true -- true to lose items when you revive by pressing the revive button
Config.LoseItemsOnBleedingOut = true -- true to lose the items when you finish bleeding when the timer ends
Config.DisableVoiceChat = false -- If true, voice chat will be disabled while player is dead
Config.VoiceResource = 'pma-voice' -- Options: 'pma-voice', 'mumble-voip'
Config.UsePrison = false -- If you activate this, script will use the prison export to check if the player is in prison
Config.PrisonCoords = { -- When a player dead, if he is in prison, he will respawn to these coords. Only works if UsePrison is true
coords = {
x = 1775.3843, -- Coordinates where the player will be sent to prison
y = 2552.3630,
z = 45.5650
},
heading = 180.0,
}
-- Price charged for choosing to respawn early and the method of payment
Config.PriceForDeadEarly = {
amount = 1000, -- Amount in in-game currency
currencyType = "cash" -- 'cash' for cash payments, 'bank' for bank account deductions
}
-- Coordinates where players will respawn when they choose to respawn early
Config.RespawnCoords = {
coords = {
x = 298.7508, -- X coordinate
y = -1440.6846, -- Y coordinate
z = 29.7929 -- Z coordinate (altitude)
},
heading = 44.1302, -- Direction player faces upon respawning
}
-- Button configuration for death screen interactions
Config.Buttons = {
Suicide = {47, 'g'}, -- Button to trigger suicide
CallAmbulance = {38, 'e'}, -- Button to call an ambulance
Extra = { 303, 'u' } -- Button that you can customise its function in client_open
}
-- Text to be displayed in the UI when you die. Each time the UI comes out, one of them will come out.
Config.DeathMessages = {
{ top = 'You are almost dead #1', bottom = 'You\'ve just died because you tried to eat a clock. It was time-consuming #1' },
{ top = 'You are almost dead #2', bottom = 'You\'ve just died because you tried to eat a clock. It was time-consuming #2' },
{ top = 'You are almost dead #3', bottom = 'You\'ve just died because you tried to eat a clock. It was time-consuming #3' }
-- You can add as many as you want
}
-- User interface translations and notification messages
Config.Translation = {
UI = { -- UI text translations
Suicide = "Embrace to <span>death</span>",
Ambulance = "Notify <span>Ambulance</span>",
ExtraButton = 'Notify<span>NPC DOCTOR</span>',
ReviveAfter = 'You can revive after',
ReviveMessage = 'You can revive for <strong>$%s</strong> (you will lose all the items in inventory)'
},
Notifications = { -- Notifications and messages displayed to the user
MoneyRemoved = "You have been removed {money} for accepting to die early"
}
}
-- Main UI colour
Config.Colors = {
main = '#00b1d7'
}Config = Config or {}
-- _____ _____ _ _ ______ _____ _____ _ _______ ___ _____ _____ _____ _ _
-- / __ \ _ | \ | || ___|_ _| __ \ | | | ___ \/ _ \_ _|_ _| _ | \ | |
-- | / \/ | | | \| || |_ | | | | \/ | | | |_/ / /_\ \| | | | | | | | \| |
-- | | | | | | . ` || _| | | | | __| | | | /| _ || | | | | | | | . ` |
-- | \__/\ \_/ / |\ || | _| |_| |_\ \ |_| | |\ \| | | || | _| |_\ \_/ / |\ |
-- \____/\___/\_| \_/\_| \___/ \____/\___/\_| \_\_| |_/\_/ \___/ \___/\_| \_/
Config.framework = 'ESX' -- Options: 'ESX', 'QB'
-- General configuration
Config.ArsAmbulance = false -- Set to true to use Ars AmbulanceJob integration
Config.OspAmbulance = false -- Set to true to use OSP AmbulanceJob integration
Config.Timer = 300 -- 300 seconds equals 5 minutes. Time to bleed out
Config.ReviveTimer = 100 -- The seconds until the "Revive" button appears on the screen
Config.UseExtraButton = true -- If you activate this, a third button will appear which will apply a function or command of your choice. In the client_open you can add the function
Config.LoseItemsOnSuicide = true -- true to lose items when you revive by pressing the revive button
Config.LoseItemsOnBleedingOut = true -- true to lose the items when you finish bleeding when the timer ends
Config.DisableVoiceChat = false -- If true, voice chat will be disabled while player is dead
Config.VoiceResource = 'pma-voice' -- Options: 'pma-voice', 'mumble-voip'
Config.UsePrison = false -- If you activate this, script will use the prison export to check if the player is in prison
Config.PrisonCoords = { -- When a player dead, if he is in prison, he will respawn to these coords. Only works if UsePrison is true
coords = {
x = 1775.3843, -- Coordinates where the player will be sent to prison
y = 2552.3630,
z = 45.5650
},
heading = 180.0,
}
-- Price charged for choosing to respawn early and the method of payment
Config.PriceForDeadEarly = {
amount = 1000, -- Amount in in-game currency
currencyType = "cash" -- 'cash' for cash payments, 'bank' for bank account deductions
}
-- Coordinates where players will respawn when they choose to respawn early
Config.RespawnCoords = {
coords = {
x = 298.7508, -- X coordinate
y = -1440.6846, -- Y coordinate
z = 29.7929 -- Z coordinate (altitude)
},
heading = 44.1302, -- Direction player faces upon respawning
}
-- Button configuration for death screen interactions
Config.Buttons = {
Suicide = {47, 'g'}, -- Button to trigger suicide
CallAmbulance = {38, 'e'}, -- Button to call an ambulance
Extra = { 303, 'u' } -- Button that you can customise its function in client_open
}
-- Text to be displayed in the UI when you die. Each time the UI comes out, one of them will come out.
Config.DeathMessages = {
{ top = 'You are almost dead #1', bottom = 'You\'ve just died because you tried to eat a clock. It was time-consuming #1' },
{ top = 'You are almost dead #2', bottom = 'You\'ve just died because you tried to eat a clock. It was time-consuming #2' },
{ top = 'You are almost dead #3', bottom = 'You\'ve just died because you tried to eat a clock. It was time-consuming #3' }
-- You can add as many as you want
}
-- User interface translations and notification messages
Config.Translation = {
UI = { -- UI text translations
Suicide = "Embrace to <span>death</span>",
Ambulance = "Notify <span>Ambulance</span>",
ExtraButton = 'Notify<span>NPC DOCTOR</span>',
ReviveAfter = 'You can revive after',
ReviveMessage = 'You can revive for <strong>$%s</strong> (you will lose all the items in inventory)'
},
Notifications = { -- Notifications and messages displayed to the user
MoneyRemoved = "You have been removed {money} for accepting to die early"
}
}
-- Main UI colour
Config.Colors = {
main = '#00b1d7'
}
-- RegisterNetEvent('sleek-death:codesignAlert', function(coords)
-- local data = exports['cd_dispatch']:GetPlayerInfo()
-- TriggerServerEvent('cd_dispatch:AddNotification', {
-- job_table = { 'ambulance' },
-- coords = vector3(coords.x, coords.y, coords.z),
-- title = 'Ambulance Alert',
-- message = 'New ambulance alert',
-- flash = 0,
-- unique_id = data.unique_id,
-- sound = 1,
-- blip = {
-- sprite = 431,
-- scale = 1.2,
-- colour = 3,
-- flashes = false,
-- text = 'Ambulance Alert',
-- time = 5,
-- radius = 0
-- }
-- })
-- end)
-------------------------------------------------------
-- GLOBAL VARIABLES THAT NEED TO BE SHARED BETWEEN FILES
-------------------------------------------------------
dead = false
ambulanceCalled = false
canRespawn = false
isArsAmbulance = Config.ArsAmbulance
isOspAmbulance = Config.OspAmbulance
-------------------------------------------------------
-- DEATH SYSTEM EXPORTS AND FUNCTIONS
-------------------------------------------------------
-- Get if player is dead
-- @return boolean - True if player is dead, false otherwise
exports('IsPlayerDead', function()
return IsPlayerDead()
end)
-- Function to check if player is dead
-- Integration with ARS or OSP Ambulance or internal state
-- @return boolean - True if player is dead, false otherwise
function IsPlayerDead()
if Config.ArsAmbulance then
-- Use ARS Ambulance export to check death state
local arsIsDead = exports['ars_ambulancejob']:isDead()
return arsIsDead
elseif Config.OspAmbulance then
-- Use OSP Ambulance export to check death state (according to gitbook API documentation)
return exports['osp-ambulancejob']:isDead()
end
-- If not using external systems, use internal death state
return dead
end
-- Export the respawn function to allow external scripts to revive the player
-- @return none
exports('RevivePlayer', function()
Respawn()
end)
-- Function to revive player and handle different framework integrations
-- @return none
function Respawn()
local ped = PlayerPedId()
local spawnPoint = GetSpawnCoords()
-- If using OSP Ambulance integration
if Config.OspAmbulance then
-- Teleport player to spawn point
SetEntityCoordsNoOffset(ped, spawnPoint.coords.x, spawnPoint.coords.y, spawnPoint.coords.z, false, false, false)
-- Use OSP Ambulance revive method
exports['osp-ambulancejob']:RevivePlayer()
-- Short wait to ensure proper processing
Citizen.Wait(500)
-- Clean up player state
ClearPedBloodDamage(ped)
SetPlayerInvincible(ped, false)
-- Update death state
dead = false
-- Trigger appropriate events
TriggerEvent('sleek-death:client:onRespawn')
OnRespawn()
-- If using ARS Ambulance integration
elseif Config.ArsAmbulance then
-- Teleport player to spawn point
SetEntityCoordsNoOffset(ped, spawnPoint.coords.x, spawnPoint.coords.y, spawnPoint.coords.z, false, false, false)
-- Use ARS Ambulance healing/revival event
TriggerEvent('ars_ambulancejob:healPlayer', {revive = true})
-- Short wait to ensure proper processing
Citizen.Wait(500)
-- Clean up player state
ClearPedBloodDamage(ped)
SetPlayerInvincible(ped, false)
-- Update death state
LocalPlayer.state:set('dead', false, true)
dead = false
-- Trigger appropriate events
TriggerEvent('sleek-death:client:onRespawn')
OnRespawn()
-- ESX Framework handling
elseif Config.framework == "ESX" then
SetEntityCoordsNoOffset(ped, spawnPoint.coords.x, spawnPoint.coords.y, spawnPoint.coords.z, false, false, false)
NetworkResurrectLocalPlayer(spawnPoint.coords.x, spawnPoint.coords.y, spawnPoint.coords.z, spawnPoint.heading, true, false)
SetPlayerInvincible(ped, false)
ClearPedBloodDamage(ped)
TriggerEvent('esx_basicneeds:resetStatus')
TriggerServerEvent('esx:onPlayerSpawn')
TriggerEvent('esx:onPlayerSpawn')
TriggerEvent('playerSpawned')
-- QB Framework handling
elseif Config.framework == "QB" then
TriggerEvent("hospital:client:Revive")
SetEntityCoordsNoOffset(ped, spawnPoint.coords.x, spawnPoint.coords.y, spawnPoint.coords.z, false, false, false)
end
end
-- Export OnDead function to allow external scripts to set player as dead
-- @return none
exports('SetPlayerDead', function()
OnDead()
end)
-- Function to handle player death state
-- @return none
function OnDead()
dead = true
ambulanceCalled = false
canRespawn = false
SendNUIMessage({type = "ShowUI", texts = Config.DeathMessages[math.random(#Config.DeathMessages)]})
StartDeathCam()
TriggerEvent('sleek-death:client:onDeath')
if Config.ArsAmbulance then
-- Set player as dead in ARS Ambulance
LocalPlayer.state:set('dead', true, true)
elseif Config.OspAmbulance then
-- Set player as dead in OSP Ambulance
-- OSP may have different approach for setting death state
-- We'll let their system handle this through native events
end
end
-- Function to handle player respawn/revival state
-- @return none
function OnRespawn()
dead = false
SendNUIMessage({type = "HideUI"})
EndDeathCam()
TriggerEvent('sleek-death:client:onRespawn')
end
function IsPrisonerCheck()
-- For default, the player is not in prison
local isInPrison = false
if Config.UsePrison then
-- Check if the export exists
local success, result = pcall(function()
return exports['rcore_prison']:IsPrisoner()
end)
-- If the export exists, the player is in prison
if success then
isInPrison = result
end
end
return isInPrison
end
function GetSpawnCoords()
-- If the player is in prison, return the prison coordinates, otherwise return the respawn coordinates
if IsPrisonerCheck() then
return Config.PrisonCoords
else
return Config.RespawnCoords
end
end
function ExtraButtonPress()
ExecuteCommand('ambulance')
end
local voiceEnabled = true
-- Function to toggle voice chat
function ToggleVoiceChat(enabled)
if not Config.DisableVoiceChat then return end
if Config.VoiceResource == 'pma-voice' then
if enabled then
exports['pma-voice']:setVoiceEnabled(true)
voiceEnabled = true
else
exports['pma-voice']:setVoiceEnabled(false)
voiceEnabled = false
end
elseif Config.VoiceResource == 'mumble-voip' then
if enabled then
exports['mumble-voip']:SetMumbleProperty("radioEnabled", true)
exports['mumble-voip']:SetMumbleProperty("micEnabled", true)
voiceEnabled = true
else
exports['mumble-voip']:SetMumbleProperty("radioEnabled", false)
exports['mumble-voip']:SetMumbleProperty("micEnabled", false)
voiceEnabled = false
end
end
end
-- Listen for death/respawn events
RegisterNetEvent('sleek-death:client:onDeath')
AddEventHandler('sleek-death:client:onDeath', function()
ToggleVoiceChat(false)
end)
RegisterNetEvent('sleek-death:client:onRespawn')
AddEventHandler('sleek-death:client:onRespawn', function()
ToggleVoiceChat(true)
end)
-- Handle external revive requests
RegisterNetEvent('sleek-death:client:revive')
AddEventHandler('sleek-death:client:revive', function()
-- Call the Respawn function to revive the player
Respawn()
end)
function Notify(playerId, message)
TriggerClientEvent('chat:addMessage', playerId, message)
end
-------------------------------------------------------
-- DEATH SYSTEM EXPORTS AND FUNCTIONS
-------------------------------------------------------
-- Export to check if a player is dead
-- @param source - Player ID
-- @return boolean - true if player is dead, false otherwise
exports('IsPlayerDead', function(source)
return GetPlayerDeadState(source)
end)
-- Function to check if a player is dead
-- Integrates with ARS/OSP Ambulance system if enabled
-- @param source - Player ID
-- @return boolean - true if player is dead, false otherwise
function GetPlayerDeadState(source)
if Config.ArsAmbulance then
local data = lib.callback.await('ars_ambulancejob:getData', false, source)
return data.status.isDead
elseif Config.OspAmbulance then
-- Check if the player is dead using OSP Ambulance system
return exports['osp-ambulancejob']:isDead(source)
end
return false
end
-- Export to revive a player by server-side code
-- @param source - Player ID to revive
-- @return none
exports('RevivePlayer', function(source)
if Config.OspAmbulance then
-- Use OSP Ambulance revive method if available
exports['osp-ambulancejob']:RevivePlayer(source)
else
-- Fall back to our internal revive event
TriggerClientEvent('sleek-death:client:revive', source)
end
end)
-- Handles the alarm to ambulance personnel when a player dies
-- @param coords - Coordinates of the dead player
-- @return none
function AlarmAmbulance(coords)
-- QBCore
-- for key, player in pairs(GetPlayers()) do
-- local qbPlayer = QBCore.Functions.GetPlayer(player)
-- if qbPlayer and qbPlayer.PlayerData.job.name == 'ambulance' then
-- qbPlayer.Functions.Notify('Ambulance Alarm')
-- end
-- end
-- ESX
-- for key, player in pairs(GetPlayers()) do
-- local esxPlayer = ESX.GetPlayerFromId(player)
-- if esxPlayer and esxPlayer.job.name == 'ambulance' then
-- esxPlayer.showNotification('Ambulance Alarm')
-- end
-- end
-- CODESIGN
-- TriggerClientEvent('sleek-death:codesignAlert', -1, coords)
-- QUASAR
-- TriggerEvent('qs-dispatch:server:CreateDispatchCall', {
-- job = { 'ambulance' },
-- callLocation = vector3(coords.x, coords.y, coords.z),
-- callCode = { code = '<CALL CODE>', snippet = '<CALL SNIPPED EX: 10-10>' },
-- message = 'Ambulance Alarm',
-- flashes = false, -- You can set to true if you need call flashing sirens...
-- image = 'URL', -- Url for image to attach to the call
-- -- You can use the getSSURL export to get this url
-- blip = {
-- sprite = 488, --blip sprite
-- scale = 1.5, -- blip scale
-- colour = 1, -- blip colour
-- flashes = true, -- blip flashes
-- text = 'Ambulance Alarm', -- blip text
-- time = (20 * 1000) --blip fadeout time (1 * 60000) = 1 minute
-- }
-- })
-- ARS AMBULANCE
-- if Config.ArsAmbulance then
-- TriggerEvent('ars_ambulancejob:newCall', {
-- coords = vector3(coords.x, coords.y, coords.z),
-- description = 'Medical Emergency',
-- source = source,
-- anonymous = false
-- })
-- return
-- end
-- OSP AMBULANCE
-- if Config.OspAmbulance then
-- exports['osp-ambulancejob']:CreateDispatch({
-- coords = vector3(coords.x, coords.y, coords.z),
-- description = 'Medical Emergency',
-- source = source,
-- anonymous = false
-- })
-- return
-- end
end
-- Handle removing items from a player's inventory when they die
-- Supports both ESX and QB Core frameworks
-- @param source - Player ID
-- @return none
function RemoveItems(source)
if Config.framework == 'ESX' then
local esxPlayer = ESX.GetPlayerFromId(source)
for index = 1, #esxPlayer.inventory, 1 do
if esxPlayer.inventory[index].count > 0 then
esxPlayer.setInventoryItem(esxPlayer.inventory[index].name, 0)
end
end
elseif Config.framework == 'QB' then
local qbPlayer = QBCore.Functions.GetPlayer(source)
qbPlayer.Functions.ClearInventory()
end
end
-- Register a server event to handle client-side revival requests
-- @return none
RegisterNetEvent('sleek-death:server:requestRevive')
AddEventHandler('sleek-death:server:requestRevive', function(playerId)
-- You can add authorization checks here if needed
if Config.OspAmbulance then
-- Use OSP Ambulance revive method if available
exports['osp-ambulancejob']:RevivePlayer(playerId)
else
TriggerClientEvent('sleek-death:client:revive', playerId)
end
end)
-- Client event to handle the revival process
RegisterNetEvent('sleek-death:client:revive')
AddEventHandler('sleek-death:client:revive', function()
-- This event will be handled client-side by triggering the Respawn function
end)
If you want to edit the aesthetics or design. You have the HTML open so you can modify the style and everything as you want.
The script is RESPONSIVE for all resolutions as well.
Last updated