SA-MP Forums Archive
Question - 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)
+--- Thread: Question (/showthread.php?tid=299153)



Question - Kostas' - 24.11.2011

I am making something with Pickups and I need a little help.
I have 10 pickups
pawn Код:
new
    Money_Collection[10];
pawn Код:
public OnFilterScriptInit()
{
    Money_Collection[0] = CreatePickup(1276, 2, -416.6939, 1398.7, 25.5071);
    Money_Collection[1] = CreatePickup(1276, 2, -465.1799, 1631.848, 3.4946);
    Money_Collection[2] = CreatePickup(1276, 2, -588.3328, 2013.401, 9.2775);
    Money_Collection[3] = CreatePickup(1276, 2, -29.741, 1434.613, 15.2435);
    Money_Collection[4] = CreatePickup(1276, 2, 296.169, 1428.594, 33.8512);
    Money_Collection[5] = CreatePickup(1276, 2, 187.2332, 1119.576, 11.7862);
    Money_Collection[6] = CreatePickup(1276, 2, -236.4455, 774.1738, 31.7022);
    Money_Collection[7] = CreatePickup(1276, 2, -553.7753, 798.212, 4.8487);
    Money_Collection[8] = CreatePickup(1276, 2, -374.6487, 1118.784, 24.5878);
    Money_Collection[9] = CreatePickup(1276, 2, -575.619, 1220.348, 23.8204);
    // Rest Of Code
    return 1;
}
And I want OnFilterScriptExit()
to destroy all the pickups. But how can I do that, because on the variable I have [10] and I cannot do it like this.
pawn Код:
public OnFilterScriptExit()
{
    DestroyPickup(Money_Collection);
    return 1;
}



Re: Question - Pharrel - 24.11.2011

no, you have to destroy one by one or make a loop (which is not recommended)


Re: Question - Kostas' - 24.11.2011

But I don't want to destroy them one by one, because if players collect them all the Money_COllection, they will win a prize!
So, I prefer the loop. But how can I make it.
pawn Код:
for(new i=1; i<11; i++)  {
// Then ?
}



Re: Question - SmiT - 24.11.2011

pawn Код:
for ( new i = 0; i < sizeof ( Money_Collection ); i ++ )
    {
        DestroyPickup( Money_Collection[ i ] );
    }



Re: Question - Pharrel - 24.11.2011

pawn Код:
for(new i=0; i<10; i++)
    DestroyPickup(Money_Collection[i]);



Re: Question - Kostas' - 24.11.2011

Thank you both!