problem with iterate
#1

My version of foreach : 0.4.3

Код:
stock GetRandomPlayerInWorld(world, playerid = -1)
{
    static Iterator:StaticList<MAX_PLAYERS>;
    if (Iter_Size(StaticList) == 0)
    {
        if(playerid != -1)
		{
        	foreach (new i : Player) if(PlayerInfo[i][LoggedIn] == true && PlayerInfo[i][pWorld] == world && i != playerid)
            	Iter_Add(i);
        }
        else
        {
        	foreach (new i : Player) if(PlayerInfo[i][LoggedIn] == true && PlayerInfo[i][pWorld] == world)
            	Iter_Add(i);
		}
    }

    new ret = Iter_Random(StaticList);
    Iter_Remove(StaticList, ret);
    return ret;
}
Quote:

error 017: undefined symbol "Iter_Size"
error 017: undefined symbol "Itter_Add"
error 017: undefined symbol "Itter_Add"

Thank's for help
Reply
#2

I guess it's because u didn't add a bracket after foreach, try this?

PHP код:
stock GetRandomPlayerInWorld(worldplayerid = -1)
{
    static 
Iterator:StaticList<MAX_PLAYERS>;
    if (
Iter_Size(StaticList) == 0)
    {
        if(
playerid != -1)
        {
            foreach (new 
Player)
                {
                     if(
PlayerInfo[i][LoggedIn] == true && PlayerInfo[i][pWorld] == world && != playerid)
                     
Iter_Add(i);
                 }
        }
        else
        {
            foreach (new 
Player
               {
                     if(
PlayerInfo[i][LoggedIn] == true && PlayerInfo[i][pWorld] == world)
                     
Iter_Add(i);
                }
         }
    }

    new 
ret Iter_Random(StaticList);
    
Iter_Remove(StaticListret);
    return 
ret;

Reply
#3

Same errors.
Reply
#4

Well i dont think the standalone version of the foreach have Iter_Size function so better use y_iterate
Also you spell Iter_Add wrong also it have another argument for iterator beside the number you want to add
Reply
#5

Fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)