Cikle in foreach.
#1

Hi,

Can i do cikle in foreach?

Код:
foreach(new i : Player)
{
for(new x = 0; x < MAX_PLAYERS; x ++)
{

}
}
Reply
#2

I don't get what you mean. Cikle is supposed to be loop? It's used as:
pawn Код:
foreach(new i : Player)
{
    // code for player with playerid equal to i
}
Reply
#3

No... First i will do foreach, to search a player, and then i need do another cikle, to search another players with another variables.
Reply
#4

So you want to check about 2 players at the same time?

pawn Код:
foreach(new i : Player)
{
    foreach(new j : Player)
    {
        // Player i and Player j.. do something..
    }
}
Reply
#5

Yea like that. But when i use 2 foreach like that my server get off.
Reply
#6

You mean the server shuts down? Load crashdetect plugin and compile with debug info. Re-compile your scripts and run the server. If it stops again, post the server log.

I've used double foreach in the past and I had no problems with it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)