How to check the nearest vehicle
#5

Quote:
Originally Posted by GooMan
Посмотреть сообщение
pawn Код:
public Naechstecar(playerid, Float:radius)
{
    new Float:SpielerX, Float:SpielerY, Float:SpielerZ, Float:CarX, Float:CarZ, Float:CarY;
    GetPlayerPos(playerid, SpielerX, SpielerY, SpielerZ);
    for(new i = 1; i < MAX_VEHICLES; i++)
    {
        GetVehiclePos(i, CarX, CarY, CarZ);
        if((floatabs(SpielerX-CarX)<radius)&&(floatabs(SpielerY-CarY)<radius)&&(floatabs(SpielerZ-CarZ)<radius))
        {
            return i;
        }
    }
    return false;
}
^^
This will actually get the first car that is in radius of 5 points from the player, not the nearest.
And use..
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, radius, CarX, CarY, CarZ))
.. it's faster.
Reply


Messages In This Thread
How to check the nearest vehicle - by Mystique - 09.07.2010, 10:36
AW: How to check the nearest vehicle - by GooMan - 09.07.2010, 10:37
Re: How to check the nearest vehicle - by Mystique - 09.07.2010, 11:32
Re: How to check the nearest vehicle - by Hiddos - 09.07.2010, 11:33
Re: AW: How to check the nearest vehicle - by CaHbKo - 09.07.2010, 12:42

Forum Jump:


Users browsing this thread: 5 Guest(s)