# ESX

Edit `client/main.lua` in `esx_ambulancejob` :

Replace this part:

```lua
CreateThread(function()
  local text, timeHeld

  -- early respawn timer
  while earlySpawnTimer > 0 and isDead do
    Wait(0)
    text = TranslateCap('respawn_available_in', secondsToClock(earlySpawnTimer))

    DrawGenericTextThisFrame()
    BeginTextCommandDisplayText('STRING')
    AddTextComponentSubstringPlayerName(text)
    EndTextCommandDisplayText(0.5, 0.8)
  end

  -- bleedout timer
  while bleedoutTimer > 0 and isDead do
    Wait(0)
    text = TranslateCap('respawn_bleedout_in', secondsToClock(bleedoutTimer))

    if not Config.EarlyRespawnFine then
      text = text .. TranslateCap('respawn_bleedout_prompt')

      if IsControlPressed(0, 38) and timeHeld > 120 then
        RemoveItemsAfterRPDeath()
        break
      end
    elseif Config.EarlyRespawnFine and canPayFine then
      text = text .. TranslateCap('respawn_bleedout_fine', ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount))

      if IsControlPressed(0, 38) and timeHeld > 120 then
        TriggerServerEvent('esx_ambulancejob:payFine')
        RemoveItemsAfterRPDeath()
        break
      end
    end

    if IsControlPressed(0, 38) then
      timeHeld += 1
    else
      timeHeld = 0
    end

    DrawGenericTextThisFrame()

    BeginTextCommandDisplayText('STRING')
    AddTextComponentSubstringPlayerName(text)
    EndTextCommandDisplayText(0.5, 0.8)
  end

  if bleedoutTimer < 1 and isDead then
    RemoveItemsAfterRPDeath()
  end
end)
```

With:

```lua
CreateThread(function()
  if bleedoutTimer < 1 and isDead then
    RemoveItemsAfterRPDeath()
  end
end)
```

And this part:

```lua
function OnPlayerDeath()
  ESX.CloseContext()
  ClearTimecycleModifier()
  SetTimecycleModifier("REDMIST_blend")
  SetTimecycleModifierStrength(0.7)
  SetExtraTimecycleModifier("fp_vig_red")
  SetExtraTimecycleModifierStrength(1.0)
  SetPedMotionBlur(PlayerPedId(), true)
  TriggerServerEvent('esx_ambulancejob:setDeathStatus', true)
  StartDeathTimer()
  StartDeathCam()
  isDead = true
  StartDeathLoop() 
  StartDistressSignal()
end
```

With:

```lua
function OnPlayerDeath()
  ESX.CloseContext()
  ClearTimecycleModifier()
  SetTimecycleModifier("REDMIST_blend")
  SetTimecycleModifierStrength(0.7)
  SetExtraTimecycleModifier("fp_vig_red")
  SetExtraTimecycleModifierStrength(1.0)
  SetPedMotionBlur(PlayerPedId(), true)
  TriggerServerEvent('esx_ambulancejob:setDeathStatus', true)
  StartDeathTimer()
  StartDeathCam()
  isDead = true
  StartDeathLoop() 
end
```

Finally, add this code snippet at the end of the file:

```lua
AddEventHandler("esx_ambulancejob:RespawnAtHospital", function()
  if not Config.EarlyRespawnFine then
    RemoveItemsAfterRPDeath()
  else
      ESX.TriggerServerCallback('esx_ambulancejob:checkBalance', function(canPay)
        if canPay then
          TriggerServerEvent('esx_ambulancejob:payFine')
          RemoveItemsAfterRPDeath()
        end
      end)
    end
end)
```

Everything is now ready, Please restart your server.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ayccoes-assets.gitbook.io/ayccoes-assets/ayc-deathscreen/installation/esx.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
