Looping functions
#1

Is there anyway to loop functions to shorten the code? At the moment, I am destroying 241 objects from Object0 to Object241, which means 242 lines of code. Can it be shortened in anyway?

Код:
DestroyPlayerObject(playerid, Object0);
Reply
#2

create the objects in an array, like:
PHP код:
new SomeArray[10];
//creating the objects
SomeArray[0] = Createobj.....
SomeArray[1] = cre.....
//and so on till
SomeArray[9] = Creat.....
//then you can use a loop to destroy them.
for(new i=0i<10i++)
{
DestroyObject(SomeArray[i]);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)