[OPU question] Which one is better?
#5

Well foreach basically does the following for you:

pawn Код:
foreach(Player, i)
{
is the same as:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
It's quicker to use foreach, and much more efficient, hence its wide usage throughout sa-mp servers. There's a full thread explaining its uses. Also, I would have to say that creating a loop within OnPlayerUpdate for EVERY player connected, would have to cause much more usage when compared to using the simple 'playerid'. That's general knowledge I am speaking of, although I have no sufficient evidence to actually back up my claim such as how usage is generated etc.
Reply


Messages In This Thread
[OPU question] Which one is better? - by newbienoob - 06.04.2013, 13:33
Re: [OPU question] Which one is better? - by iJumbo - 06.04.2013, 13:35
Re: [OPU question] Which one is better? - by MP2 - 06.04.2013, 13:45
Re: [OPU question] Which one is better? - by newbienoob - 06.04.2013, 13:53
Re: [OPU question] Which one is better? - by Threshold - 06.04.2013, 13:56
Re: [OPU question] Which one is better? - by newbienoob - 06.04.2013, 14:03
Re: [OPU question] Which one is better? - by SuperViper - 06.04.2013, 14:07
Re: [OPU question] Which one is better? - by newbienoob - 06.04.2013, 14:15
Re: [OPU question] Which one is better? - by MP2 - 06.04.2013, 14:58

Forum Jump:


Users browsing this thread: 4 Guest(s)