Vehicle help
#2

If I were you, then I'd check the closest vehicle of a player:
pawn Код:
new
    vehicleid = GetClosestVehicle(playerid);

if (vehicleid != INVALID_VEHICLE_ID)
{
    // "vehicleid" stores the closest vehicle's ID.
}
pawn Код:
stock GetClosestVehicle(playerid)
{
    new
        vehicleid;
   
    if ((vehicleid = GetPlayerVehicleID(playerid))) return vehicleid;

    new
        Float: px,
        Float: py,
        Float: pz,
        Float: distance = 999.0,
        Float: tmp;
   
    vehicleid = INVALID_VEHICLE_ID;
    GetPlayerPos(playerid, px, py, pz);
    for (new v = 1; v != MAX_VEHICLES; ++v)
    {
        if ((tmp = GetVehicleDistanceFromPoint(v, px, py, pz)) < distance)
        {
            distance = tmp;
            vehicleid = v;
        }
    }
    return vehicleid;
}
Reply


Messages In This Thread
Vehicle help - by jeffery30162 - 28.03.2014, 21:30
Re: Vehicle help - by Konstantinos - 28.03.2014, 22:12

Forum Jump:


Users browsing this thread: 1 Guest(s)