04.08.2012, 04:38
hello everyone,
I have a small question regarding this stock code:
It is working, that is not the problem, but when i am inside the vehicle, and use this function, offcoarse it returns the vehicle i am in, because it is the closest to me.
What i want to achieve here, is that it skips the vehicle the player is sitting in (if sitting in one), so it get's the closest vehicle to a vehicle(the vehicle the player is not sitting in).
I hope someone understands me, i can explain things chaotic sometimes, i know, but i hope someone can help me.
Thanks in advance
I have a small question regarding this stock code:
pawn Код:
stock GetNearestVehicle(playerid, Float:dis)
{
new Float:L, Float:O, Float:II;
if(GetPlayerPos(playerid, L, O, II))
{
new vehicleid = INVALID_VEHICLE_ID;
for(new v, Float:temp, Float:VL, Float:VO, Float:VII; v != MAX_VEHICLES; v++)
{
if(GetVehiclePos(v, VL, VO, VII))
{
VL -= L, VO -= O, VII -= II;
temp = VL * VL + VO * VO + VII * VII;
if(temp < dis) dis = temp, vehicleid = v;
}
}
dis = floatpower(dis, 0.5);
return vehicleid;
}
return INVALID_VEHICLE_ID;
}
What i want to achieve here, is that it skips the vehicle the player is sitting in (if sitting in one), so it get's the closest vehicle to a vehicle(the vehicle the player is not sitting in).
I hope someone understands me, i can explain things chaotic sometimes, i know, but i hope someone can help me.
Thanks in advance