Thanks for posting the function, here's what i figured out.
entity_range() returns the distance between two entities in a float datatype, i really don't know if this function checks if the two ents are valid, ignoring the player you should check if
ferencere or distancemax entity is valid before doing anything.
PHP Code:
if(entity_range(id, ferencere) > maxdistance && entity_range(id, distancemax) > maxdistancem)
->
if(is_valid_ent(ferencere) && is_valid_ent(distancemax) && entity_range(id, ferencere) > maxdistance && entity_range(id, distancemax) > maxdistancem)
not pretty sure since idk all the part of the global code that is used there.
__________________