I wonder why you start with vehicleid 1, instead of 0, vehicle ids start with 0, not with one, so what you should be using is:
pawn Code:
for(new vehicleid=0; vehicleid < MAX_VEHICLES; vehicleid++)
unless you have a specific reason to start at 1.
not sure if this will fix it, but the rest of the code seems fine to me; this is the only thing I could find.
tho, I also wonder why you do this:
pawn Code:
new Float:PretendentDistance = range +1; // creates a variable that has the range + 1;
if(Distance <= range && Distance <= PretendentDistance) // checks if the vehicle is within the normal range, and within the range of the normal range +1;
if it inside the normal range then obviously it's also inside the range + 1; so I don't really understand why you do that.
also, you should change this
pawn Code:
new Float:p_X;
new Float:p_Y;
new Float:p_Z;
new Float:Distance;
new Float:PretendentDistance = range +1;
new Pretendent;
to this.
pawn Code:
new
Float:p_X,
Float:p_Y,
Float:p_Z,
Float:Distance,
Float:PretendentDistance = range +1,
Pretendent
;