SA-MP Forums Archive
Objects looping. - 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: Objects looping. (/showthread.php?tid=567505)



Objects looping. - Karan007 - 14.03.2015

Hey guys,

how can i loop only some specific objects and destroys it when i perform a command?

If you helped me you will be repped!

Thanks in advance.
~karan007


Re: Objects looping. - Pottus - 14.03.2015

You want to delete a specific object id ?


Re: Objects looping. - CalvinC - 14.03.2015

You have to declare them when creating them, a global array is best to do this.
pawn Код:
new MyObject[3]; // Declares the array we're going to use for our objects

public OnGameModeInit()
{
    MyObject[0] = CreateObject( ... );
    MyObject[1] = CreateObject( ... );
    MyObject[2] = CreateObject( ... );
    // Creates 3 objects, and defines them
}

CMD:mycommand(playerid, params[])
{
    for(new i = 0; i < 3; i ++) // Loops 2 times
    {
        DestroyObject(MyObject[i]); // Destroys the objects
    }
}



Re: Objects looping. - Karan007 - 14.03.2015

Thanks alot! it works!

Giving you reps later as i don't have one right now lol.