GetPlayerNearVehicle???
#1

Hey, I need some help with checking if people are within a X distance from a vehicle. I don't understand if you would put GetClosestVehicle? I need some maor ideas.
Reply
#2

You want their distance to a vehicle? Well all you need is getdistance then

pawn Код:
Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
    return Float:floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
Example of using it like you want to:

pawn Код:
new Float:x[2],Float:y[2],Float:z[2],distance;
GetVehiclePos(vehicleid,x[0],y[0],z[0]);
GetPlayerPos(playerid,x[1],y[1],z[1]);
distance = floatround(GetDistance(x[0],y[0],z[0],x[1],y[1],z[1]));

printf("Distance to car: %d",distance);

if(distance < 5000) // He's less than 5000 from the car!
Hope that helps!
Reply
#3

Thank you very much JaToch!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)