My solution for others with the same problem

function IsPedInFight(ped)
    local peds = {} local combat = false
    local peds = GetPedNearbyPeds(ped, 0)
    if IsPedInMeleeCombat(ped) or HasPedBeenDamagedByWeapon(ped, 0, 1) or HasPedBeenDamagedByWeapon(ped, 0, 2) then
        return true
    else
        for i = 0, peds, 1 do
            if IsPedInCombat(ped, i) then
                combat = true
                return true
            end
        end
        if combat == true then return true
        else return false end
    end
end
1 Like