SA-MP Forums Archive
Foreach doesn't work. - 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: Foreach doesn't work. (/showthread.php?tid=431033)



Foreach doesn't work. - JaKe Elite - 16.04.2013

I've problem.
I've used foreach for a long time. I discover this problem since 1 year ago.
I stopped using foreach because of this problem.

It doesn't work. I'm not sure. But i think it only works for my id.
Or for id 0.

i use

pawn Код:
foreach(Player, i)
Any ideas?


Re: Foreach doesn't work. - DaRk_RaiN - 16.04.2013

Replace it with this
pawn Код:
foreach (new i : Player)



Re: Foreach doesn't work. - JaKe Elite - 16.04.2013

^^

I've tried that but still the same.
It doesn't work.


Re: Foreach doesn't work. - Syntax - 16.04.2013

Well, my question is, do you get any errors? Do you have the following line at the top of your file?:

pawn Код:
#include <foreach>
Elaborate your situation, do not just say that you have problems with foreach. Hope you found a solution.


Re: Foreach doesn't work. - dr.lozer - 16.04.2013

Update all your YSI inc file to latest version.


Re: Foreach doesn't work. - JaKe Elite - 17.04.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
Are you using the latest version from YSI? Are you sure the hooks are called?
Yes i'm using YSI 3.1.

Let me try to debug the code.


Re: Foreach doesn't work. - JaKe Elite - 17.04.2013

sorry for double posting.
I've question. Since i saw it uses some YSI includes.
Does it means i need to load these used YSI includes first before foreach?
Because i put #include <foreach> below all YSI include that i use in the script.


Re: Foreach doesn't work. - Scenario - 17.04.2013

I recently discovered that if you don't load YSI with a game-mode that the system won't initialize. So, for example, loading bare.amx and a new FS you've coded with foreach won't work because YSI isn't "on."

To combat this problem, I load up all of the YSI includes I used in my testing GM (which is basically a modified version of bare.amx); now I can load, unload, and reload FS's with no problem.


Re: Foreach doesn't work. - JaKe Elite - 17.04.2013

^^

That didn't work for me.


Re: Foreach doesn't work. - JaKe Elite - 17.04.2013

i think i've discovered the problem.
did foreach counts NPC as player? If it isn't.
Then that is the reason why it is not listing up in /admins.

I've to make sure first if it is fixed yet.

Question: Did foreach counts NPC as player?