!LOOP! - 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: !LOOP! (
/showthread.php?tid=598836)
!LOOP! -
JokeyL - 17.01.2016
foreach(new i : Player) or foreach(Player, i) or for(new or 0.3.7 PoolSize AND WHY?
Re: !LOOP! -
yvoms - 17.01.2016
foreach(new i : Player) - optimalization of code.
Re: !LOOP! -
JokeyL - 17.01.2016
Okay. Can you tell me something about other loops?
i.e for(new + IsPlayerConnected and PoolSize + IsPlayerConnected
Re: !LOOP! -
JokeyL - 17.01.2016
No answers?
Re: !LOOP! -
SickAttack - 17.01.2016
pawn Code:
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
{
if(!IsPlayerConnected(i))
{
continue;
}
// Do something with the player here.
}
Re: !LOOP! -
JokeyL - 17.01.2016
PoolSize is better then foreach?
Re: !LOOP! -
JokeyL - 17.01.2016
So?..
Re: !LOOP! -
SickAttack - 17.01.2016
Use what you want, they are pretty much the same.
Re: !LOOP! -
JokeyL - 17.01.2016
Okay, thank you so much.
Respuesta: Re: !LOOP! -
IzadorO - 17.01.2016
Looping through the players with for(new is better if your server is constantly full.
Other than that, I'd go with foreach(new i : Player)