Help for a command
#3

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;
}
Reply


Messages In This Thread
Help for a command - by HailPutin - 12.03.2015, 20:31
Re: Help for a command - by Smileys - 12.03.2015, 22:43
Re: Help for a command - by FOTIS6 - 12.03.2015, 23:39

Forum Jump:


Users browsing this thread: 1 Guest(s)