Convert to foreach
#1

Hello,

I don't understand how use inlucde "foreach", someone can convert the next code to foreach:
PHP код:
    foreach (new Player)
    {
    for (new 
o=0o<100o++)SendClientMessage(i,white," ");
    } 
Im talking about this:
PHP код:
for (new o=0o<100o++)SendClientMessage(i,white," "); 
someone can convert this to foreach, I don't know how.
thanks for all!
Reply
#2

pawn Код:
foreach (new i : Player)
{
    SendClientMessage(i,white," ");  
}
Basically,
the "foreach (new i : Player)" is the "for (new o=0; o<100; o++)"

But, i guess you need to change the
Код:
"new i : ..."
into
Код:
"new o : ..."
..
Reply
#3

It's not really useful to use foreach in this specific occasion. For a clearchat function (which I assume this is) you could simply use SendClientMessageToAll in a normal loop of 50 iterations.
Reply
#4

Are you sure about that? I'll not have to create more loop for clean chat?
Reply
#5

But normal loop leads to lags in server.
Reply
#6

Once I clean the chat server, it takes at least a second and a half and it's distracting the regular process of the game.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)