for (new i=0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
Value[i] = 1;
}
}
new i = 0;
while (i < MAX_PLAYERS)
{
if (IsPlayerConnected(i))
{
Value[i] = 1;
}
i++;
}
new i = 0;
until (i == MAX_PLAYERS)
{
if (IsPlayerConnected(i))
{
Value[i] = 1;
}
i++;
}
new string[64];
// syntax for 'for' loop:
// for ( <executed code once, for example declare an variable, more code can be done with comma's ex: new a,b,c,a=b=c=0>; <statement which is true, if false loop exits>; <code executed every loop call, for example: a= a+1>)
for(new counter_variable = 0; counter_variable /*is less*/ < /*than*/ 64 /* our string is 64 chars long */; ++counter_variable)
{
}
for(new counter_variable = 0; counter_variable /*is less*/ < /*than*/ 64 /* our string is 64 chars long */; ++counter_variable)
{
if(string[counter_variable] /* get the string at position |counter_variable| */ == 'a' /* matches "a" , CASE SENSETIVE */)
{
}
}
for(new counter_variable = 0; counter_variable /*is less*/ < /*than*/ 64 /* our string is 64 chars long */; ++counter_variable)
{
if(string[counter_variable] /* get the string at position |counter_variable| */ == 'a' /* matches "a" , CASE SENSETIVE */)
{
}
return 1;// this will preven the whole loop, whatever you return, the loop will be executed only once or not at all (because the statement matters too)
}
stock function()
{
for(new counter_variable = 0; counter_variable /*is less*/ < /*than*/ 64 /* our string is 64 chars long */; ++counter_variable)
{
if(string[counter_variable] /* get the string at position |counter_variable| */ == 'a' /* matches "a" , CASE SENSETIVE */)
{
return counter_variable; // loop will end, everything below will not be executed, so -1 won't be returned, but the position of the first 'a' will get returned
}
}
return -1//not found
}
for(new variable = 1; variable > 0; ++variable)
{
//will teoretically never end, however if 2^31 is reached, it will be ended because of an integer overflow
}
while(statement)//if statement is false (0) while will stop looping
{//do
//this
}
stock function()
{
new counter_variable = 64;//set to 64, however now it will return the position of the LAST 'a'
while(--counter_variable)
{
if(string[counter_variable] /* get the string at position |counter_variable| */ == 'a' /* matches "a" , CASE SENSETIVE */)
{
return counter_variable; // loop will end, everything below will not be executed, so -1 won't be returned, but the position of the first 'a' will get returned
}
}
return -1//not found
}
|
Examples:
pawn Код:
|
|
Never heard of the until one, that looks easy. Though I will work on it, now I am going to die for some hours. I mean sleep.
|
#define until(%1) while(!(%1))