12.03.2015, 23:39
That should work. Didn't test it, didn't even compile it so if there are any errors report them here or fix them yourself.
Code:
#define DESTROY_VEHICLE_DISTANCE 50.0
COMMAND:fire(playerid, params[])
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(IsValidVehicle(i))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(GetVehicleDistanceFromPoint(i, x, y, z) < DESTROY_VEHICLE_DISTANCE && IsVehicleOccupied(i))
{
SetVehicleHealth(i, 0);
SendClientMessage(playerid, -1, "Nearby vehicles are destroyed");
}
}
}
return 1;
}
stock IsVehicleOccupied(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(vehicleid == GetPlayerVehicleID(i)) return true;
}
return false;
}

