16.03.2010, 18:55
This will loop for 21 players - IDs: 0-20
This will loop for 22 players - IDs: 0-21
The only difference in this code from the first one is that i've used <= so this means if i is smaller than 21 or equal to 21.
And i suggest to you to use ******'s foreach include - it's faster than normal for loop and you don't have to use IsPlayerConnected function because foreach already has this check in its code.
foreach include - http://forum.sa-mp.com/index.php?topic=117573.0
Example with foreach:
pawn Код:
for(new i = 0; i < 21; i++)
{
if(IsPlayerConnected(i)) SendClientMessage(i, 0xAA000AA, "HAHA!");
}
pawn Код:
for(new i = 0; i <= 21; i++)
{
if(IsPlayerConnected(i)) SendClientMessage(i, 0xAA000AA, "HAHA!");
}
And i suggest to you to use ******'s foreach include - it's faster than normal for loop and you don't have to use IsPlayerConnected function because foreach already has this check in its code.
foreach include - http://forum.sa-mp.com/index.php?topic=117573.0
Example with foreach:
pawn Код:
foreach(Player, i) SendClientMessage(i, 0xAA000AA, "HAHA!");