> For the complete documentation index, see [llms.txt](https://praryo.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://praryo.gitbook.io/documentation/paid-resources/cfx-praryo-deathscreen/events-exports.md).

# Events / Exports

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

### StartDeathScreen

{% hint style="info" %}
Use this exports to start the death screen timer.
{% endhint %}

`Example Usage:`

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

### ToggleUIMaximize

{% hint style="info" %}
You can use this exports if you want to toggle maximize / minimize of the death screen on your other scripts.
{% endhint %}

`Example Usage:`

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

### RemoveDeathScreen

{% hint style="info" %}
Use this exports to reset and hide the current displayed death screen.
{% endhint %}

`Example Usage:`

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

## Spawn Events

{% hint style="info" %}
This event will be triggered once a player confirmed the spawn location.
{% endhint %}

```lua
// 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:`

```lua
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)

```
