14.07.2016, 15:40
Hi all,
I have the following command:
However, unfortunately when I print the contents of vehicleid on executing the command right next to a vehicle, it only prints the value of 0, which means this isn't working.
Pulling my hair out with this...any ideas?
I have the following command:
Код:
stock GetClosestVehicle(playerid, Float:range){
new Float:p_X;
new Float:p_Y;
new Float:p_Z;
new Float:Distance;
new Float:PretendentDistance = range +1;
new Pretendent;
GetPlayerPos(playerid, p_X, p_Y, p_Z);
for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++){
Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
if(Distance <= range && Distance <= PretendentDistance){
Pretendent = vehicleid;
PretendentDistance = Distance;
}
}
return Pretendent;
}
new vehicleid = GetClosestVehicle(playerid, 10.0);
Pulling my hair out with this...any ideas?


