foreach and loop?
#1

What's the difference between foreach and for(new ?
Reply
#2

foreach is more faster than the normal loop (that's my knowledge about this)
Reply
#3

alright, another question

when I use this

Код:
foreach(new i : pInfo)
I get these errors
Код:
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1211) : error 017: undefined symbol "Iterator@pInfo"
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1211) : warning 215: expression has no effect
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1211) : error 001: expected token: ";", but found ")"
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1211) : error 029: invalid expression, assumed zero
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1211) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
But when I replace "pInfo" with Player it compiles ?
Reply
#4

Foreach will only go through online Players, that's why it is faster. Foreach include has many other advantages too not just player's loop. Other loops, well that you can do in any way you like.

PHP код:
foreach(new Player
Reply
#5

pInfo and Player are two completely different things, as pInfo could be an array, and Player means any playerid of connected players.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)