Changing normal loop with foreach - 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)
+--- Thread: Changing normal loop with foreach (
/showthread.php?tid=519639)
Changing normal loop with foreach -
Battlezone - 15.06.2014
Hi, i've just switched to foreach since it has a more efficient loop, but i can't convert this loop to a foreach loop
pawn Код:
for(new i = 0; i < sizeof (IsPlayerCapturing[]); ++i)
{
if(IsPlayerCapturing[playerid][i] == true)
{
LeavingZONE(playerid, i);
SendClientMessage(killerid, COLOR_PINK, "[NOTICE]: You have prevented the ennemy from capturing this zone, +1XP!");
SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
IsPlayerCapturing[playerid][i] = false;
}
}
Re: Changing normal loop with foreach -
Konstantinos - 15.06.2014
Use foreach for players loop, you don't need it for the above and neither you've to create an iterator for that. The way you do it is just fine.
Re: Changing normal loop with foreach -
Battlezone - 15.06.2014
Thanks !