26.05.2013, 15:45
Hey, how can I check if is a vehicle in rage of another vehicle ?
stock IsVehicleInRangeOfVehicle(VehicleID_1, VehicleID_2, Float:range)
{
if(IsVehicleValid(VehicleID_1) && IsVehicleValid(VehicleID_2))
{
new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
GetVehiclePos(VehicleID_1, x1, y1, z1);
GetVehiclePos(VehicleID_2, x2, y2, z2);
if(range <= floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) ) return 1;
}
return 0;
}
forward Float:GetDistanceBetweenVehicles(vehicleid,carid);
public Float:GetDistanceBetweenVehicles(vehicleid,carid)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
GetVehiclePos(vehicleid,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));
}
Searched a bit and found this:
pawn Код:
|