# qb-ambulancejob

## in `qb-ambulancejob/client/death.lua` CTRL + F and look for:

```lua
AddEventHandler('gameEventTriggered', function(event, data)
```

* at the beginning of the function add following:
* ```lua
  if LocalPlayer.state.inDeathmatch == true then return end
  ```
* Your event should look like this:

<figure><img src="https://2644204359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fso4Bz1A5MlataovyRdlF%2Fuploads%2FPVUB3xlcmOx322nPwKDg%2Fqb%20amb.png?alt=media&#x26;token=05b835c4-0946-447b-a85b-a34c1c71a439" alt=""><figcaption></figcaption></figure>

## in `qb-ambulancejob/client/main.lua` CTRL + F and look for :&#x20;

```lua
local hit, bone = GetPedLastDamageBone(ped)
```

* replace whole thread with this:

```lua
CreateThread(function()
    while true do
        if not LocalPlayer.state.inDeathmatch or LocalPlayer.state.inDeathmatch == false then
            local ped = PlayerPedId()
            local health = GetEntityHealth(ped)
            local armor = GetPedArmour(ped)

            if not playerHealth then
                playerHealth = health
            end

            if not playerArmor then
                playerArmor = armor
            end

            local armorDamaged = (playerArmor ~= armor and armor < (playerArmor - Config.ArmorDamage) and armor > 0) -- Players armor was damaged
            local healthDamaged = (playerHealth ~= health) -- Players health was damaged

            local damageDone = (playerHealth - health)

            if armorDamaged or healthDamaged then
                local hit, bone = GetPedLastDamageBone(ped)
                local bodypart = Config.Bones[bone]
                local weapon = GetDamagingWeapon(ped)

                if hit and bodypart ~= 'NONE' then
                    local checkDamage = true
                    if damageDone >= Config.HealthDamage then
                        if weapon then
                            if armorDamaged and (bodypart == 'SPINE' or bodypart == 'UPPER_BODY') or weapon == Config.WeaponClasses['NOTHING'] then
                                checkDamage = false -- Don't check damage if the it was a body shot and the weapon class isn't that strong
                                if armorDamaged then
                                    TriggerServerEvent("hospital:server:SetArmor", GetPedArmour(ped))
                                end
                            end

                            if checkDamage then
                                if IsDamagingEvent(damageDone, weapon) then
                                    CheckDamage(ped, bone, weapon, damageDone)
                                end
                            end
                        end
                    elseif Config.AlwaysBleedChanceWeapons[weapon] then
                        if armorDamaged and (bodypart == 'SPINE' or bodypart == 'UPPER_BODY') or weapon == Config.WeaponClasses['NOTHING'] then
                            checkDamage = false -- Don't check damage if the it was a body shot and the weapon class isn't that strong
                        end
                        if math.random(100) < Config.AlwaysBleedChance and checkDamage then
                            ApplyBleed(1)
                        end
                    end
                end

                CheckWeaponDamage(ped)
            end

            playerHealth = health
            playerArmor = armor

            if not isInHospitalBed then
                ProcessDamage(ped)
            end
        end
        Wait(100)
    end
end)
```
