Destroy all spawned vehicles problem
#1

Hi,
I have made a command, its should be able to destroy all spawned vehicles, but this is my problem: he only destroys the car that is spawned first. Can anybody help me? Here you see the code:

Код:
dcmd_dasv(playerid, cmdtext[]) {
	#pragma unused cmdtext
	for(new c;c<MAX_VEHICLES;c++)
    {
        if(spawnedveh[c] == 1)
        {
            DestroyVehicle©;
            SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR,"You have succesfully destroyed all spawned vehicles.");
            return 1;
		}
	}
}
Greetz,
Danny
Reply
#2

The vehicle spawn command would also be helpful.
Just to see where the
pawn Код:
spawnedveh[vehicleid] = 1;
is set.
=D
Reply
#3

ouch why would you like to do that lol, hmmmmm try removing DestroyVehicle and add SetVehicleHealth...

if it dont work ill try to find another way
Reply
#4

Here you see it:
Код:
dcmd_spawnveh(playerid, params[]) {
    if(adminlevel[playerid] == 0) {
    	SendClientMessage(playerid, COLOR_GREY,"You are not autorized to use this command!"); return 1;
	}
 	new model, c1,c2;
  	if(sscanf(params, "iii", model, c1, c2))
	{
		SendClientMessage(playerid, 0xFF0000AA, "USAGE: /spawnveh [model] [color1] [color2]"); return 1;
	}
	new stringc[128];
	new pvw;
	new pin;
 	new Float:myX, Float:myY, Float:myZ;
	GetPlayerPos(playerid, myX, myY, myZ);
	pvw = GetPlayerVirtualWorld(playerid);
	pin = GetPlayerInterior(playerid);
 	format(stringc, sizeof(stringc), "You have spawned carid %d with color %d and %d",model,c1,c2);
  	sp = CreateVehicle(model, myX, myY, myZ, 0.0, c1, c2, 99999999);
  	SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, stringc);
  	SetVehicleVirtualWorld(sp, pvw);
  	LinkVehicleToInterior(sp, pin);
	spawnedveh[sp] = 1;
 	SetPlayerPos(playerid, myX, myY, myZ+2.0);
   	return true;
}
Reply
#5

The problem is the return value in the for loop.
Try:
pawn Код:
dcmd_dasv(playerid, cmdtext[])
{
        #pragma unused cmdtext
        for(new c;c<MAX_VEHICLES;c++)
        {
               if(spawnedveh[c] == 1) DestroyVehicle(c);
        }
        SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR,"You have succesfully destroyed all spawned vehicles.");
        return 1;
}
Reply
#6

It's solved now, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)