06.06.2014, 04:49
hello.
how i can get a closest vehicle without the current vehicle id?
for e.g. i am in a vehicle (id 2) and near me there is a vehicle (id 3).
when i am using this, i always get id 2. how i can get id 3?
how i can get a closest vehicle without the current vehicle id?
for e.g. i am in a vehicle (id 2) and near me there is a vehicle (id 3).
when i am using this, i always get id 2. how i can get id 3?
PHP код:
stock GetClosestVehicle(playerid, Float:radius)
{
new Float:CarX, Float:CarZ, Float:CarY, Float:Dis, Float:Dis2,vehicleid;
Dis = 99999.99;
vehicleid = INVALID_VEHICLE_ID;
for(new i = 0; i < MAX_VEHICLES; i++)
{
GetVehiclePos(i, CarX, CarY, CarZ);
Dis2 = GetPlayerDistanceFromPoint(playerid, CarX, CarY, CarZ);
if(Dis2 < Dis && Dis2 < radius)
{
Dis = Dis2;
vehicleid = i;
}
}
return vehicleid;
}