SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/07/2018, 02:14 PM   #1
djoudjou
Big Clucker
 
djoudjou's Avatar
 
Join Date: Jul 2014
Posts: 89
Reputation: 1
Default problem with iterate

My version of foreach : 0.4.3

Code:
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
djoudjou is offline   Reply With Quote
Old 12/07/2018, 02:18 PM   #2
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 744
Reputation: 39
Default Re: problem with iterate

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

PHP Code:
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;

__________________


Discord: Riggs #5210
JasonRiggs is offline   Reply With Quote
Old 12/07/2018, 02:22 PM   #3
djoudjou
Big Clucker
 
djoudjou's Avatar
 
Join Date: Jul 2014
Posts: 89
Reputation: 1
Default Re: problem with iterate

Same errors.
djoudjou is offline   Reply With Quote
Old 12/07/2018, 02:44 PM   #4
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 321
Reputation: 25
Default Re: problem with iterate

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
__________________
Banditul18 is offline   Reply With Quote
Old 12/07/2018, 02:51 PM   #5
djoudjou
Big Clucker
 
djoudjou's Avatar
 
Join Date: Jul 2014
Posts: 89
Reputation: 1
Default Re: problem with iterate

Fixed.
djoudjou is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Hash Problem & MYSQL Saving Problem Faqahat Scripting Help 3 18/04/2016 11:54 AM
[Scripting Problem] Player Spawn Problem! MaxTuner Scripting Help 6 07/08/2014 06:55 AM
[SOLVED] 3 problem's! (1 problem still unsolved, but stopped solving.) Mechscape Help Archive 9 24/12/2009 08:47 PM


All times are GMT. The time now is 03:07 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.