# esx\_ambulancejob

{% hint style="info" %}
**Notification to EMS**

The following code detects the current property, and when a player sends a death message inside the property, it transmits the coordinates of the house entrance.
{% endhint %}

<pre class="language-lua" data-title="esx_ambulancejob/server/main.lua"><code class="lang-lua">RegisterNetEvent('esx_ambulancejob:onPlayerDistress')
AddEventHandler('esx_ambulancejob:onPlayerDistress', function()
    local source = source
    local injuredPed = GetPlayerPed(source)
    local injuredCoords = GetEntityCoords(injuredPed)
    
<strong>    local playerProperty = exports['vms_housing']:GetPlayerCurrentProperty(source)
</strong><strong>    if playerProperty then
</strong><strong>        local property = exports['vms_housing']:GetProperty(playerProperty)
</strong><strong>        if property.object_id then
</strong><strong>            local building = exports['vms_housing']:GetProperty(property.object_id)
</strong><strong>            if building.type == 'building' then
</strong><strong>                property = building
</strong><strong>            end
</strong><strong>        end
</strong><strong>        if property.metadata?.exit then
</strong><strong>            injuredCoords = property.metadata.exit
</strong><strong>        end
</strong><strong>    end
</strong>    
    if deadPlayers[source] then
        deadPlayers[source] = 'distress'
        local Ambulance = ESX.GetExtendedPlayers("job", "ambulance")
        for _, xPlayer in pairs(Ambulance) do
            xPlayer.triggerEvent('esx_ambulancejob:PlayerDistressed', source, injuredCoords)
        end
    end
end)
</code></pre>

{% hint style="info" %}
**Kicking a player out of the property after respawning**
{% endhint %}

<pre class="language-lua" data-title="esx_ambulancejob/server/main.lua"><code class="lang-lua">ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(source, cb)
    local xPlayer = ESX.GetPlayerFromId(source)
    
<strong>    exports['vms_housing']:DropPlayerFromProperty(source)
</strong>
    -- Rest of the code
end)
</code></pre>


---

# 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://docs.vames-store.com/assets/vms_housing/guides/ambulance-integration/esx_ambulancejob.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.
