SA-MP Forums Archive
getvehicleid - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: getvehicleid (/showthread.php?tid=403062)



getvehicleid - Scofield62 - 28.12.2012

Hi all! I got a question that is all about there is a way to get the id of a vehicle that i'm not sitting in it or no one sitting in it! Example: get vehicle id what is in this circle-> float, float:y... So i add the coordinates and get the vehicle id what is in that circle. Sorry for my bad english, thanks for helping.


Re: getvehicleid - Scofield62 - 29.12.2012

Nobody know?


Re: getvehicleid - Konstantinos - 29.12.2012

pawn Код:
stock GetClosestVehicle(playerid, Float: fRadius) // by RyDeR`
{
    new
        iClosestID = INVALID_VEHICLE_ID,
        Float: fFinalDistance,
        Float: fDistance,
        Float: fX,
        Float: fY,
        Float: fZ;
    GetPlayerPos(playerid, fX, fY, fZ);
    fFinalDistance = fRadius;

    for(new i; i != MAX_VEHICLES; i++)
    {
        if((fDistance = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fFinalDistance)
        {
            fFinalDistance = fDistance;
            iClosestID = i;
        }
    }
    return iClosestID;
}



Re: getvehicleid - Scofield62 - 29.12.2012

Thank you so much!