# qb-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="qb-ambulancejob/server/main.lua"><code class="lang-lua">RegisterNetEvent('hospital:server:ambulanceAlert', function(text)
    local src = source
    local ped = GetPlayerPed(src)
    local coords = GetEntityCoords(ped)
    local players = QBCore.Functions.GetQBPlayers()
    
<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>            coords = property.metadata.exit
</strong><strong>        end
</strong><strong>    end
</strong>    
    for _, v in pairs(players) do
        if v.PlayerData.job.name == 'ambulance' and v.PlayerData.job.onduty then
            TriggerClientEvent('hospital:client:ambulanceAlert', v.PlayerData.source, coords, text)
        end
    end
end)
</code></pre>

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

<pre class="language-lua" data-title="qb-ambulancejob/server/main.lua"><code class="lang-lua">RegisterNetEvent('hospital:server:RespawnAtHospital', function(hospitalIndex)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)

<strong>    exports['vms_housing']:DropPlayerFromProperty(src)
</strong>
    -- Rest of the code
end)
</code></pre>
