Vehicle In front of Vehicle
#1

How to determine if there is two vehicles near a player facing front

pawn Код:
> | <
> = vehicle a
| = player
< = vehicle b

or atleast two vehicles facing each other
Reply
#2

You could compare GetPlayerFacingAngle to the angle between player and vehicle using atan2()
Reply
#3

I'm guessing this.would work:
pawn Код:
stock IsVehicleFacingVehicle(vehicleone, vehicletwo)
{
    new Float:angle1, Float:angle2;
    GetVehicleZAngle(vehicleone, angle1);
    GetVehicleZAngle(vehicletwo, angle2);
    if(angle1 > angle2)
    {
        if((angle1 - angle2) > 175 && (angle1 - angle2) < 185) return 1;
    }
    else
    {
        if((angle2 - angle1) > 175 && (angle2 - angle1) < 185) return 1;
    }
    return 0;
}
I'm sorry I you get any errors, I'm trying to script this on my phone. This took me like 20 minutes. xD

Edit: Also you could add a distance.check between the vehicles if.necessary.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)