SA-MP Forums Archive
Spawn vehicle & Destoy vehicle - 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: Spawn vehicle & Destoy vehicle (/showthread.php?tid=45306)



Spawn vehicle & Destoy vehicle - stefanlg - 30.07.2008

pawn Код:
new CreatedCars[100];
new CreatedCar = 0;
pawn Код:
if(strcmp(cmd, "/veh", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new car;
            car = strval(tmp);
            if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "  Vehicle Number can't be below 400 or above 611!"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color1;
            color1 = strval(tmp);
            if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "  Color Number can't be below 0 or above 126!"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color2;
            color2 = strval(tmp);
            if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "  Color Number can't be below 0 or above 126!"); return 1; }
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid, X,Y,Z);
            new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 60000);
            CreatedCars[CreatedCar] = carid;
            CreatedCar ++;
            format(string, sizeof(string), "  Vehicle %d spawned.", carid);
            SendClientMessage(playerid, COLOR_GREY, string);
        }
        return 1;
    }
if(strcmp(cmd, "/destroycars", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            for(new i = 0; i < sizeof(CreatedCars))
            {
                if(i != 0)
                {
                DestroyVehicle(i);
                }
            }
            SendClientMessage(playerid, COLOR_GREY, "  Created Vehicles destroyed !");
        }
        return 1;
    }
The command to Create Vehicles works fine.
The Command to delete created vehicles doesn't work. It deleted all the cars in game. But i want it to delete only the cars i have created.


Re: Spawn vehicle & Destoy vehicle - Streetplaya - 30.07.2008

try this

pawn Код:
for(new i = 1; i <= sizeof(CreatedCars); i++)
        {
            DestroyVehicle(i);
        }



Re: Spawn vehicle & Destoy vehicle - yom - 30.07.2008

pawn Код:
for (new i = 0; i < sizeof CreatedCars; i++)
  DestroyVehicle(CreatedCars[i]);



Re: Spawn vehicle & Destoy vehicle - Streetplaya - 30.07.2008

nope, vehicle id's start with 1, do they?


Re: Spawn vehicle & Destoy vehicle - yom - 30.07.2008

Quote:
Originally Posted by Streetplaya
nope, vehicle id's start with 1, do they?
You don't understand.. he want to destroy only vehicles he created with his command and nothing else.


Re: Spawn vehicle & Destoy vehicle - stefanlg - 30.07.2008

Thanks yom, Works great



Re: Spawn vehicle & Destoy vehicle - Jessy69 - 24.01.2010

How Install the Script ?


Re: Spawn vehicle & Destoy vehicle - Streetplaya - 25.01.2010

Quote:
Originally Posted by Jessy69
How Install the Script ?
Dude, you're bumping a thread that's almost 2 years old.