👾Events / Exports

This page contains an example of a exports to integrate the death screen on your scripts.

StartDeathScreen

Use this exports to start the death screen timer.

Example Usage:

AddEventHandler("esx:onPlayerDeath", function(data)
    exports["cfx-praryo-deathscreen"]:StartDeathScreen({
        time = 10
    })
end)

ToggleUIMaximize

You can use this exports if you want to toggle maximize / minimize of the death screen on your other scripts.

Example Usage:

RegisterCommand("toggleDeathScreen", function()
     exports["cfx-praryo-deathscreen"]:ToggleUIMaximize()
end)

RemoveDeathScreen

Use this exports to reset and hide the current displayed death screen.

Example Usage:

RegisterCommand("removeDeathScreen", function()
     exports["cfx-praryo-deathscreen"]:RemoveDeathScreen()
end)

Spawn Events

This event will be triggered once a player confirmed the spawn location.

// Client Event
AddEventHandler("cfx-praryo-deathscreen:cl_events:spawnPlayer", function(data)
    local position = data.position
    
end)

// Server Event
RegisterNetEvent("cfx-praryo-deathscreen:sv_events:spawnPlayer", function(data)
    local playerId = source
    local position = data.position
    
end)

Example Usage:

function RespawnPed(ped, coords)
    SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false)
    NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, coords.w, true, false)
    SetPlayerInvincible(ped, false)
    ClearPedBloodDamage(ped)
    SetEntityInvincible(cache.ped, false)
	
    TriggerServerEvent('esx:onPlayerSpawn')
    TriggerEvent('esx:onPlayerSpawn')
	
    SetEntityHealth(cache.ped, GetEntityMaxHealth(cache.ped))
end

AddEventHandler("cfx-praryo-deathscreen:cl_events:spawnPlayer", function(data)
    local position = data.position
    local x = position.x
    local y = position.y
    local z = position.z
    local h = position.w
	
    RespawnPed(cache.ped, position)
end)

Last updated