> For the complete documentation index, see [llms.txt](https://piotreq-scripts.gitbook.io/piotreq-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://piotreq-scripts.gitbook.io/piotreq-scripts/assets-and-guides/ambulance-job-v2/api/server-side.md).

# Server Side

## Revive Player

Use one of following events to revive player

```lua
-- Any of these events will work :)
local targetId = 1 -- replace with existing player id
TriggerClientEvent('p_ambulancejob/client/death/revive', targetId)
TriggerClientEvent('esx_ambulancejob:revive', targetId)
TriggerClientEvent('hospital:client:RevivePlayer', targetId)
TriggerClientEvent('hospital:client:Revive', targetId)
```

targetId: `number`

* Existing player server ID

***

## Kill Player

Use one of following events to kill player

```lua
-- Any of these events will work :)
local targetId = 1 -- replace with existing player id
TriggerClientEvent('p_ambulancejob/client/death/kill', targetId)
TriggerClientEvent('hospital:client:KillPlayer', targetId)
```

targetId: `number`

* Existing player server ID

***

## getDispatchAlerts

Use following export to get all active alerts on dispatch

```lua
exports['p_ambulancejob']:getDispatchAlerts()
```

Return:

* alerts: `table {id: number, player: number, code: string, title: string, message: string, coords: vec3, expire: number, blip: {sprite: number, scale: number, color: number}}`&#x20;

***

## isDead / dead

Use following state bag to check if player is dead

```lua
local targetId = 2 -- replace with existing player id

Player(targetId).state.isDead
Player(targetId).state.dead -- compatibility with other ambulance jobs

-- both of them return true / false

Player(targetId).state.deathType

-- this one return stage: "death" | "bleeding" | "recovering" | "none"
```

***

## onDeathStateChange

You can use this event handler to follow players death state

```lua
RegisterNetEvent('p_ambulancejob/onDeathStateChange', function(deathType, deathData)
end)
```

* deathType: `"death" | "bleeding" | "recovering" | "none"`
* deathData: `{victimCoords: vec3, killerCoords: vec3 | nil, distance: number | nil, killer: number | nil, cause: number, weapon: number, weaponLabel: string | nil}`

***

## Check Pulse

Use following statebags to check player pulse

```lua
local targetId = 2 -- replace with existing player id
Player(targetId).state.pulse -- number
Player(targetId).state.criticalPulse -- true / false
```

***

## getPlayerInsurance

Use following export to get player insurance data

```lua
local playerId = 1 -- replace with existing target
local insurance = exports['p_ambulancejob']:getPlayerInsurance(playerId)
print(json.encode(insurance, { indent = true }))
```

Return:

* insurance: `{name: string, duration: number [os.time], timeLeft: number [difference between expire time and current time]}`

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://piotreq-scripts.gitbook.io/piotreq-scripts/assets-and-guides/ambulance-job-v2/api/server-side.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.
