SA-MP Forums Archive
command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: command (/showthread.php?tid=187752)



command - dark_clown - 04.11.2010

can anyone give me like a /destroycar, so it destroy's the closest car, NOT when im in it
it destroys the closest car, is it possible?


Re: command - WillyP - 04.11.2010

Quote:
Originally Posted by dark_clown
Посмотреть сообщение
can anyone give me like a /destroycar, so it destroy's the closest car, NOT when im in it
it destroys the closest car, is it possible?
Yeah, It's possible.

This forum requires that you wait 120 seconds between posts. Please try again in 87 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 3 seconds.


Re: command - dark_clown - 04.11.2010

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
Yeah, It's possible.

This forum requires that you wait 120 seconds between posts. Please try again in 87 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 3 seconds.
can u gimme one?


Re: command - WillyP - 04.11.2010

Yeah sure, give me a couple of minutes.

EDIT:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/destroycar", cmdtext, true, 10) == 0)
    {
        for(new v = 0; v < MAX_VEHICLES; v++)
        {
            GetClosestVehicle(v);
            DestroyVehicle(v);
        }
        return 1;
    }
    return 0;
}

stock GetClosestVehicle(playerid, &Float:dis = (Float:0x7F800000))
{
  dis = (Float:0x7F800000);
  new Float:X, Float:Y, Float:Z;
  if(GetPlayerPos(playerid, X, Y, Z)) {
    new vehicleid = INVALID_VEHICLE_ID;
    for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++) {
      if(GetVehiclePos(v, VX, VY, VZ)) {
        VX -= X, VY -= Y, VZ -= Z;
        temp = VX * VX + VY * VY + VZ * VZ;
        if(temp < dis) dis = temp, vehicleid = v;
      }
    }
    dis = floatpower(dis, 0.5);
    return vehicleid;
  }
  return INVALID_VEHICLE_ID;
}