SA-MP Forums Archive
Help with "/adestroycars" would be appreciated. - 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: Help with "/adestroycars" would be appreciated. (/showthread.php?tid=97092)



Help with "/adestroycars" would be appreciated. - Marclang - 12.09.2009

Hi,

Please help me with this, don't post anything flaming or insulting me as you'll just be ignored.

Genuine replies only, please.

Your help would be appreciated.

pawn Код:
dcmd_adestroycars(playerid, params[])
{
  #pragma unused params
    if(pStats[playerid][pAdmin] >= 3)
    {
    for(new i = 0;i < Spawned; i++)
    {
            Spawned--;
            DestroyVehicle(AdminSpawned[i]);
            printf("[DEBUG] Car %d despawned. Spawned rate is at %d.", AdminSpawned[i], Spawned);
        }
        SendClientMessage(playerid, COLOR_WHITE, "Destroyed all admin-spawned vehicles.");
    }
    else
    {
      SendClientMessage(playerid, COLOR_WHITE, BAD_ADMIN_MESSAGE);
    }
    return 1;
}
new AdminSpawned[100];
new Spawned = 1



Re: Help with "/adestroycars" would be appreciated. - Calgon - 12.09.2009

What's wrong with it?


Re: Help with "/adestroycars" would be appreciated. - Marclang - 12.09.2009

It only destroys 23% of the cars.


Re: Help with "/adestroycars" would be appreciated. - JaTochNietDan - 12.09.2009

pawn Код:
for(new i = 0;i < Spawned; i++)
    {
            Spawned--;
For that simple reason ,

Everytime the loop runs, the "Spawned" value is less.


Re: Help with "/adestroycars" would be appreciated. - Marclang - 12.09.2009

so how do I fix it?


Re: Help with "/adestroycars" would be appreciated. - JaTochNietDan - 12.09.2009

Quote:
Originally Posted by Marclang
so how do I fix it?
Well you're destroying all of them right? So like so:

pawn Код:
dcmd_adestroycars(playerid, params[])
{
     #pragma unused params
    if(pStats[playerid][pAdmin] >= 3)
    {
        for(new i = 0;i < Spawned; i++)
        {
            DestroyVehicle(AdminSpawned[i]);
            printf("[DEBUG] Car %d despawned. Spawned rate is at %d.", AdminSpawned[i], Spawned);
        }
        SendClientMessage(playerid, COLOR_WHITE, "Destroyed all admin-spawned vehicles.");
        Spawned = 0; // Or whatever the default value is
    }
    else
    {
      SendClientMessage(playerid, COLOR_WHITE, BAD_ADMIN_MESSAGE);
    }
    return 1;
}



Re: Help with "/adestroycars" would be appreciated. - Marclang - 12.09.2009

Thank you for your help.