Car remove command?
#1

Yeah im trying to fix my friends script, and i created a car command for him so he can spawn infinite cars, but he also wants a command to remove all the cars, but not all cars just the ones thats spawned with the car command, for all players too, not only for the one who type remove command.

How can i fix this?
Reply
#2

Could you post the vehicle spawning command?
Reply
#3

pawn Код:
if(strcmp(cmd, "/car", true)==0)
{
  if(AdminLevel[playerid] == 5))
  {
    new tmp[128], tmp2[128], tmp3[128];
    new Float:x, Float:y, Float:z;
    tmp = strtok(cmdtext, idx); tmp2 = strtok(cmdtext, idx); tmp3 = strtok(cmdtext, idx);
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(strval(tmp), x+2, y+2, z, 0, strval(tmp2), strval(tmp3), 60);
  }
  else return SendClientMessage(playerid, red, "Your not high enough level to use this command");
  return 1;
}
Reply
#4

Quote:
Originally Posted by [NWA
Hannes ]
pawn Код:
if(strcmp(cmd, "/car", true)==0)
{
  if(AdminLevel[playerid] == 5))
  {
    new tmp[128], tmp2[128], tmp3[128];
    new Float:x, Float:y, Float:z;
    tmp = strtok(cmdtext, idx); tmp2 = strtok(cmdtext, idx); tmp3 = strtok(cmdtext, idx);
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(strval(tmp), x+2, y+2, z, 0, strval(tmp2), strval(tmp3), 60);
  }
  else return SendClientMessage(playerid, red, "Your not high enough level to use this command");
  return 1;
}
Do you mind if I were to recreate the command? I have a better way of building a vehicle and destroying them.
Reply
#5

Whatever just it works
Reply
#6

Try this.

Код:
new CarsCreated[100];
new CarCreated= 0;
Код:
	if(strcmp(cmd, "/car", true) == 0)
	{
		if(IsPlayerConnected(playerid))
		{
			if (AdminLevel[playerid] == 5))
			{
				SendClientMessage(playerid, red, "Your not high enough level to use this command");
				return 1;
			}
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /car [carid]");
				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: /car [carid]");
				return 1;
			}
			new Float:X,Float:Y,Float:Z;
			GetPlayerPos(playerid, X,Y,Z);
			new carid = CreateVehicle(car, X,Y,Z, 0.0, 0, 0, 60000);
			CarsCreated[CarCreated] = carid;
			CarCreated ++;
		}
		return 1;
	}

	if(strcmp(cmd, "/destroycar", true) == 0)
	{
		if(AdminLevel[playerid] == 5))
		{
			SendClientMessage(playerid, red, "Your not high enough level to use this command");
			return 1;
		}
		for(new i = 0; i < sizeof(CarsCreated); i++)
		{
			if(CarsCreated[i] != 0)
			{
				DestroyVehicle(CarsCreated[i]);
				CarsCreated[i] = 0;
			}
		}
		return 1;
	}
Reply
#7

Thanks
Reply
#8

Did it work?
Reply
#9

nice daniel but some parts arent necessary

pawn Код:
new First_Spawned_Car;
pawn Код:
if(strcmp(cmd, "/car", true) == 0)
    {
        if (AdminLevel[playerid] < 5)
            return SendClientMessage(playerid, red, "Your not high enough level to use this command");
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
            return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /car [carid]");
        new car = strval(tmp);
        if(car < 400 || car > 611)
            return SendClientMessage(playerid, COLOR_GREY, " Vehicle Number can't be below 400 or above 611!");
        new Float:X, Float:Y, Float:Z, Float:A;
        GetPlayerFacingAngle(playerid, A);
        GetPlayerPos(playerid, X, Y, Z);
        X += 5 * floatsin(-A, degrees);
        Y += 5 * floatcos(-A, degrees);
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp))
        {
            new color_1 = strval(tmp);
            new color_2 = strval(strtok(cmdtext, idx));
            if(!First_Spawned_Car) return (First_Spawned_Car = CreateVehicle(car, X, Y, Z, -A, color_1, color_2, -1));
            return CreateVehicle(car, X, Y, Z, -A, color_1, color_2, -1);  
        }
        if(!First_Spawned_Car) return (First_Spawned_Car = CreateVehicle(car, X, Y, Z, -A, -1, -1, -1));
        return CreateVehicle(car, X, Y, Z, -A, -1, -1, -1);
    }
pawn Код:
if(strcmp(cmd, "/destroycar", true) == 0)
    {
        if(AdminLevel[playerid] < 5)
            return SendClientMessage(playerid, red, "Your not high enough level to use this command");
        for(; First_Spawned_Car <= MAX_VEHICLES; First_Spawned_Car++)
            DestroyVehicle(First_Spawned_Car);
        return !(First_Spawned_Car = 0);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)