SA-MP Forums Archive
Car remove 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: Car remove command? (/showthread.php?tid=155439)



Car remove command? - bajskorv123 - 18.06.2010

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?


Re: Car remove command? - Despare - 18.06.2010

Could you post the vehicle spawning command?


Re: Car remove command? - bajskorv123 - 18.06.2010

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



Re: Car remove command? - Despare - 18.06.2010

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.


Re: Car remove command? - bajskorv123 - 18.06.2010

Whatever just it works


Re: Car remove command? - Despare - 18.06.2010

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



Re: Car remove command? - bajskorv123 - 18.06.2010

Thanks


Re: Car remove command? - Despare - 18.06.2010

Did it work?


Re: Car remove command? - Nero_3D - 18.06.2010

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