Callback to check the nearest vehicle
#4

pawn Код:
forward Float:GetDisBetweenPlayerAndCar(p1ayerid,carid);
forward GetClosestVehicle(carid);
pawn Код:
public GetClosestVehicleToPlayer(playerid)
{
    new x,Float:dis,Float:dis2,car;
    car = 0;
    dis = 99999.99;
    for ( x = 0; x < MAX_VEHICLES; x++ )
    {
        dis2 = GetDisBetweenPlayerAndCar(playerid,x);
        if(dis2 < dis && dis2 < 8.0)
        {
            dis = dis2;
            car = x;
        }
    }
    return car;
}
pawn Код:
public Float:GetDisBetweenPlayerAndCar(p1ayerid,carid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1ayerid))
    {
        return -1.00;
    }
    GetPlayerPos(p1ayerid,x1,y1,z1);
    GetVehiclePos(carid,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
Reply


Messages In This Thread
Callback to check the nearest vehicle - by dirkblok - 07.09.2010, 16:44
Re: Callback to check the nearest vehicle - by mick88 - 07.09.2010, 17:36
Re: Callback to check the nearest vehicle - by dirkblok - 08.09.2010, 06:19
Re: Callback to check the nearest vehicle - by Voldemort - 08.09.2010, 06:33
Re: Callback to check the nearest vehicle - by LarzI - 08.09.2010, 06:39
Re: Callback to check the nearest vehicle - by Voldemort - 08.09.2010, 06:47
Re: Callback to check the nearest vehicle - by LarzI - 08.09.2010, 06:52

Forum Jump:


Users browsing this thread: 1 Guest(s)