Spawn vehicle & Destoy vehicle
#1

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.
Reply
#2

try this

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

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

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

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.
Reply
#6

Thanks yom, Works great
Reply
#7

How Install the Script ?
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)