SA-MP Forums Archive
/Destroycars problem - 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: /Destroycars problem (/showthread.php?tid=221697)



/Destroycars problem - Sandek - 05.02.2011

when i write /destroycars then will destroy all cars in server not just that what makes Admin..
So i wannt when i type /Destroycars to destroy just created vehicles
pleas help me!
Thanks
Really Sory For my English...i Know is very bad
cod:
Код:
if(strcmp(cmd, "/destroycars", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] < 1340)
			{
			    SendClientMessage(playerid, COLOR_GRAD1, "   Niste ovlasteni da koristite tu komandu!");
			    return 1;
			}
			for(new i = 0; i < sizeof(CreatedCars); i++)
			{
				if(i != 0)
				{
			    	DestroyVehicle(i);
				}
			}
			SendClientMessage(playerid, COLOR_GREY, "   Sva stvorena vozila su unistena !");
		}
		return 1;
	}



Re: /Destroycars problem - Dumb - 05.02.2011

I cant understand... use translate better.


Re: /Destroycars problem - xRyder - 05.02.2011

That's because you use loop. And your looping through all vehicles.
Try this code:
pawn Код:
if(strcmp(cmd, "/destroycars", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehicle = GetPlayerVehicleID(playerid);
            if(PlayerInfo[playerid][pAdmin] < 1340) return SendClientMessage(playerid, COLOR_GRAD1, "Niste ovlasteni da koristite tu komandu!");
            DestroyVehicle(vehicle);
            SendClientMessage(playerid, COLOR_GREY, "Vozilo je unisteno!");
        }
    }
    return 1;
}



Re: /Destroycars problem - Sandek - 05.02.2011

Thats better yes.... but can you make code that i can just destroy created vehicles not all??


Re: /Destroycars problem - xRyder - 06.02.2011

Do you have a command for creating cars?

[Cro]: Imas li komandu za stvaranje vozila?
[Offtopic]: Uvijek mozes pitat svoja pitanja ovdje ako ti engleski bas i ne ide.


Re: /Destroycars problem - Sandek - 06.02.2011

Ryder I have command /veh
Код:
if(strcmp(cmd, "/veh", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if (PlayerInfo[playerid][pAdmin] < 1337)
			{
			    SendClientMessage(playerid, COLOR_GREEN, "   niste ovlasteni da koristite tu komandu!");
			    return 1;
			}
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREEN, "Koriscenje: /veh [id vozila] [boja1] [boja2]");
				return 1;
			}
			new car;
			car = strval(tmp);
			if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "   ID vozila ne moze biti ispod 400 ili preko 611 !"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREEN, "Koriscenje: /veh [id vozila] [boja1] [boja2]");
				return 1;
			}
			new color1;
			color1 = strval(tmp);
			if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "   ID Boje ne moze biti ispod 0 ili preko 126 !"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREEN, "Koriscenje: /veh [id vozila] [boja1] [boja2]");
				return 1;
			}
			new color2;
			color2 = strval(tmp);
			if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "   ID Boje ne moze biti ispod 0 ili preko 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), "   Vozilo %d je stvoreno.", carid);
			SendClientMessage(playerid, COLOR_GREY, string);
		}
		return 1;
	}