GetNearestVehicle modification
#1

hello everyone,

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;
}
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
Reply


Messages In This Thread
GetNearestVehicle modification - by Jstylezzz - 04.08.2012, 04:38
Re: GetNearestVehicle modification - by [KHK]Khalid - 04.08.2012, 04:44
Re: GetNearestVehicle modification - by Jstylezzz - 04.08.2012, 04:46
Respuesta: Re: GetNearestVehicle modification - by HarlemSAMP - 04.08.2012, 04:54

Forum Jump:


Users browsing this thread: 1 Guest(s)