Destroy all spawned vehicles 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: Destroy all spawned vehicles problem (
/showthread.php?tid=161583)
Destroy all spawned vehicles problem -
Danny - 20.07.2010
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
Re: Destroy all spawned vehicles problem -
Last_Stand_Guardian - 20.07.2010
The vehicle spawn command would also be helpful.
Just to see where the
pawn Код:
spawnedveh[vehicleid] = 1;
is set.
=D
Re: Destroy all spawned vehicles problem -
tanush - 20.07.2010
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
Re: Destroy all spawned vehicles problem -
Danny - 20.07.2010
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;
}
Re: Destroy all spawned vehicles problem -
Last_Stand_Guardian - 20.07.2010
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;
}
Re: Destroy all spawned vehicles problem -
Danny - 20.07.2010
It's solved now, thanks!