Looping through returns nothing after using dynamic routes to get the entry type and category
{% if not entries %} never executes, even if i enter complete nonsense in the url.


You’re not ensuring that segmentCategory is a valid category slug anywhere. If it’s not, then category will get set to null, which will basically prevent it from affecting the following relatedTo param.

So right after grabbing the category you should make sure it exists;

{% set category = craft.categories.slug(segmentCategory).first() %}
{% if not category %}
  {% exit 404 %}
{% endif %}



  the array entries is never outputs anything


I think this is because your relatedTo parameter isn’t set up correctly. If the used/new categories are being assigned to the entries via a Categories field on the entry, then the category should be set to the targetElement property, not sourceElement, since the category is the target element of the relation. And you can just get rid of the current targetElement stuff, which should have been sourceElement, but is redundant and doesn’t need to be specified anyway.

{% set entries = craft.entries({
    type: segmentEntryType,
    relatedTo: { targetElement: category }
}) %}



  Ok, now i get the posts, but if i pass an invalid string to the segmentEntryType the template still loads.


This conditional:

{% if not entries %}


should be:

{% if not entries|length %}


(At this point in your template, entries will be a defined ElementCriteriaModel regardless of whether it matches any entries. Including the length filter in your conditional will force it to execute the DB query and return the actual results.)