20.03.2016, 14:41
You are checking if the player is in range, but obviously you want to check for vehicles in range. SA-MP instead offers GetVehicleDistanceFromPoint to check if a vehicle is within range of a point.
Likewise, you can still do something like this if you prefer the old method:
pawn Код:
CMD:range(playerid, params[])
{
if(pInfo[playerid][pAdmin] < 3)
return 0;
new Float: range;
if( sscanf(params, "f", range) || range < 0.0)
return SendUsageError( playerid, "/range [Range Distance]" );
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 1, j = GetVehiclePoolSize(); i <= j; i ++)
{
if(GetVehicleDistanceFromPoint(i, x, y, z) <= range)
{
if(!IsValidVehicle(i))
{
continue;
}
if(spawnedcar[i])
{
DestroyVehicle(i);
spawnedcar[i] = 0;
}
else
{
SetVehicleToRespawn(i);
}
}
}
}
pawn Код:
IsVehicleInRangeOfPoint(vehicleid, Float: radius, Float: x, Float: y, Float: z) {
if(GetVehicleDistanceFromPoint(vehicleid, x, y, z) <= radius)
return true;
return false;
}

