Vehicle in Rage of Vehicle? -
Banane mit Gelb - 26.05.2013
Hey, how can I check if is a vehicle in rage of another vehicle ?
Re: Vehicle in Rage of Vehicle? -
Littlehelper - 26.05.2013
what do you mean?
Re: Vehicle in Rage of Vehicle? -
Pottus - 26.05.2013
He means is V1 in range of V2, which is simply getting each vehicles position calculating the distance between the two then checking if they are in the specified range.
pawn Код:
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;
}
Re: Vehicle in Rage of Vehicle? -
zxc1 - 26.05.2013
Searched a bit and found this:
pawn Код:
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));
}
Untested.
AW: Vehicle in Rage of Vehicle? -
Banane mit Gelb - 26.05.2013
ocmd:test(playerid,params[])
{
if(GetDistanceBetweenVehicles(vehicleid,carid,<20) ;
{
SendClientMessage(player,white,"Test");
}
}
return 1;
}
How must I use it ?
Re: Vehicle in Rage of Vehicle? -
Pottus - 26.05.2013
Quote:
Originally Posted by zxc1
Searched a bit and found this:
pawn Код:
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)); }
Untested.
|
He asked for the range not the distance.
AW: Vehicle in Rage of Vehicle? -
Banane mit Gelb - 26.05.2013
yeah
AW: Vehicle in Rage of Vehicle? -
Banane mit Gelb - 26.05.2013
noboy can help me ?