Usage of loops
#3

Examples:
Set a value for all players.
pawn Код:
for (new i=0; i < MAX_PLAYERS; i++)
{
     if (IsPlayerConnected(i))
     {
           Value[i] = 1;
     }
}
[pawn]
for ( // create the loop
new i = 0; //create a new zero variable
i < MAX_PLAYERS; // same with if (i < MAX_PLAYERS)
i++ ) // code to execute after every run (Increments i)



2nd example:
(same)
pawn Код:
new i = 0;
while (i < MAX_PLAYERS)
{
     if (IsPlayerConnected(i))
     {
           Value[i] = 1;
     }
     i++;
}
3rd example:
(same)
pawn Код:
new i = 0;
until (i == MAX_PLAYERS)
{
     if (IsPlayerConnected(i))
     {
           Value[i] = 1;
     }
     i++;
}
Reply


Messages In This Thread
Usage of loops - by suhrab_mujeeb - 10.10.2011, 16:37
Re: Usage of loops - by Ash. - 10.10.2011, 16:42
Re: Usage of loops - by hittt - 10.10.2011, 16:56
Re: Usage of loops - by Gamer_Z - 10.10.2011, 16:59
Re: Usage of loops - by suhrab_mujeeb - 10.10.2011, 17:24
Re: Usage of loops - by hittt - 10.10.2011, 18:06
Re: Usage of loops - by suhrab_mujeeb - 11.10.2011, 13:22

Forum Jump:


Users browsing this thread: 1 Guest(s)