qbx_ambulancejob

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.

qbx_ambulancejob/server/main.lua
local function alertAmbulance(src, text)
    local ped = GetPlayerPed(src)
    local coords = GetEntityCoords(ped)
    local players = exports.qbx_core:GetQBPlayers()
    
    local playerProperty = exports['vms_housing']:GetPlayerCurrentProperty(source)
    if playerProperty then
        local property = exports['vms_housing']:GetProperty(playerProperty)
        if property.object_id then
            local building = exports['vms_housing']:GetProperty(property.object_id)
            if building.type == 'building' then
                property = building
            end
        end
        if property.metadata?.exit then
            coords = property.metadata.exit
        end
    end
    
    for _, v in pairs(players) do
        if v.PlayerData.job.type == 'ems' and v.PlayerData.job.onduty then
            TriggerClientEvent('hospital:client:ambulanceAlert', v.PlayerData.source, coords, text)
        end
    end
end

Kicking a player out of the property after respawning

qbx_ambulancejob/server/hospital.lua
local function respawn(src)
    local player = exports.qbx_core:GetPlayer(src)

    exports['vms_housing']:DropPlayerFromProperty(src)

    -- Rest of the code
end

Last updated

Was this helpful?