SA-MP Forums Archive
problem with iterate - 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: problem with iterate (/showthread.php?tid=656298)



problem with iterate - djoudjou - 12.07.2018

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


Re: problem with iterate - JasonRiggs - 12.07.2018

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;




Re: problem with iterate - djoudjou - 12.07.2018

Same errors.


Re: problem with iterate - Banditul18 - 12.07.2018

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


Re: problem with iterate - djoudjou - 12.07.2018

Fixed.