SA-MP Forums Archive
[Snippet]Easy loop(macro) - 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: [Snippet]Easy loop(macro) (/showthread.php?tid=90306)



[Snippet]Easy loop(macro) - yezizhu - 07.08.2009

Hi all, this is a snippet for easy loop.
Код:
#define looper(%1,%2,%3,%4) \
for(new %1 = (%2);(%1)<(%3);%1++) if(%4)
Example:
Код:
looper(i,0,MAX_PLAYERS,(IsPlayerConnected(i))){
  SendClientMessage(playerid,422,"hello world");
}
Same as
Код:
for(new i = 0;i < MAX_PLAYERS;i++){
  if(IsPlayerConnected(i)){
      SendClientMessage(playerid,422,"hello world");
  }
}
Use looper is easier, and write less lines than for loop.
Any comment is everything~


Re: [Snippet]Easy loop(macro) - paytas - 07.08.2009

http://forum.sa-mp.com/index.php?topic=12197.0


Re: [Snippet]Easy loop(macro) - yezizhu - 07.08.2009

Quote:
Originally Posted by paytas
Thanks now both here and there.