29.11.2010, 09:30
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.

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));
}
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!