22.08.2010, 12:32
Hello. I need some kind of function that it would check for example how far vehicle is from pick up. Or how much vehicle has run. I hope you understand me.
forward Float:GetDistanceBetweenVehicleToPoint(vehicleid,Float:px,Float:py,Float:pz);
public Float:GetDistanceBetweenVehicleToPoint(vehicleid,Float:px,Float:py,Float:pz);
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsVehicleConnected(p1) )
{
return -1.00;
}
GetVehiclePos(p1,x1,y1,z1);
x2 = px;
y2 = py;
z2 = pz;
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
stock IsVehicleConnected(vehicleid) //By Sacky (edited by Gabriel "Larcius" Cordes)
{
new Float:x1,Float:y1,Float:z1;
GetVehiclePos(vehicleid,x1,y1,z1);
if(x1==0.0 && y1==0.0 && z1==0.0)
{
return 0;
}
return 1;
}