Function for cars
#1

Good morning.

I want to know if there is a function to determine if a vehicle is next to us?

And if no, do you would one for me?

thank you
Reply
#2

Well I found this"
pawn Code:
stock FindClosestVehicle(playerid)
{
    new
        Float:x, Float:y, Float:z,
        closest = -1;

    for(new a = 0; a < MAX_VEHICLES; a++)
    {
        GetVehiclePos(a, x, y, z);

        if(a != YOUR_VEHICLEID_OR_ARRAY/VARIBLE && IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
        {
            closest = a;
        }
    }
    if(closest != -1) return closest;
   
    return INVALID_VEHICLE_ID;
}
Ran a loop through all vehicles, checked for the vehicle near to you and then saved the result for further processing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)