09.09.2016, 09:53
(
Last edited by Dayrion; 10/09/2016 at 11:00 AM.
)
PHP Code:
stock IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
new Float:x1,
Float:y1,
Float:z1;
CreateCircle(0, x, y, z, range*0.01, x1, y1, z1);
GetVehiclePos(vehicleid, x, y, z);
new Float:dist = GetDistanceBetween2Points(x, y, z, x1, y1, z1);
if(dist < range)
return true;
else
return false;
}
stock GetNearestVehicleByCoord(Float:x, Float:y, Float:z, Float:precision = 2.0)
{
new vehicle = INVALID_VEHICLE_ID;
for(new i=1; i<MAX_VEHICLES; i++)
{
new Float:vehDist = GetVehicleDistanceFromPoint(i, x, y, z);
if(vehDist == 0.0)
{
if(i > GetVehiclePoolSize()) return vehicle;
else continue;
}
if(vehDist > precision) continue;
else precision = vehDist, vehicle = i;
}
return vehicle;
}
stock Float:GetDistanceBetween2Points(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
return VectorSize(x1-x2, y1-y2, z1-z2);
}
CMD:exemple(playerid)
{
new Float:x,
Float:y,
Float:z;
GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
if(IsVehicleInRangeOfPoint(1, 10, x, y, z))
return SCM(playerid, GREEN, "In range!");
else
return SCM(playerid, RED, "Out of range");
}