Giter VIP home page Giter VIP logo

samp-foreach's Introduction

SA-MP-foreach

foreach standalone include (non y_iterate version).

Y_Less dropped support for this version of foreach.

This version of foreach is 19 (0.4.4). This is the standalone version, so it does not require YSI. Use this version if you do not want to include YSI.

Installation with sampctl

sampctl package install karimcambridge/SAMP-foreach

Then simply include into code:

#include <foreach>

foreach option with more iterators out of the box

https://github.com/Open-GTO/foreach

samp-foreach's People

Contributors

gitter-badger avatar kar2k avatar karimcambridge avatar nexiustailer avatar southclaws avatar ziggi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

samp-foreach's Issues

Scope of this include

Hi,

Firstly, thanks for adding me to the repository (somewht out of the blue - I was not expecting that at all), and thanks for maintaining this (working on two subtly different ones was a pain, and frequently resulted in regressions or bugs in one but not the other).

Anyway, as you added me here, I'm wondering where you are taking this version? y_iterate has moved on a lot since this version was forked. A lot of the changes probably can't be back-ported easilly as they would introduce huge extra dependencies (especially the new yield keyword); however, the other one is now very well tested, so I was wondering how much of that newer stuff you wanted to pull in, and how much you wanted me for that?

Infinite loop bug is still exist

Hey.
I think this is not my fault.

new Iterator:ServerItems<500>;
public Timer_2()
{
	foreach(new serveritemid : ServerItems)
	{
		count[serveritemid]++;
		if(count[serveritemid] == 2)
		{
			new current = serveritemid;
			Iter_SafeRemove(ServerItems, current, serveritemid);
			printf("removing %d || next: %d || current serverItems %d", current, serveritemid, Iter_Count(ServerItems));
		}
		printf("current id %d || current serverItems %d", serveritemid, Iter_Count(ServerItems));
	}
}

output:


[2017/10/01 21:56:25] current id 0 || current serverItems 7
[2017/10/01 21:56:25] current id 1 || current serverItems 7
[2017/10/01 21:56:25] current id 2 || current serverItems 7
[2017/10/01 21:56:25] current id 3 || current serverItems 7
[2017/10/01 21:56:25] current id 4 || current serverItems 7
[2017/10/01 21:56:25] current id 5 || current serverItems 7
[2017/10/01 21:56:25] current id 6 || current serverItems 7
[2017/10/01 21:56:27] removing 0 || next: 500 || current serverItems 6
[2017/10/01 21:56:27] current id 500 || current serverItems 6
[2017/10/01 21:56:27] removing 1 || next: 500 || current serverItems 5
[2017/10/01 21:56:27] current id 500 || current serverItems 5
[2017/10/01 21:56:27] removing 2 || next: 0 || current serverItems 4
[2017/10/01 21:56:27] current id 0 || current serverItems 4
[2017/10/01 21:56:27] removing 3 || next: 1 || current serverItems 3
[2017/10/01 21:56:27] current id 1 || current serverItems 3
[2017/10/01 21:56:27] removing 4 || next: 2 || current serverItems 2
[2017/10/01 21:56:27] current id 2 || current serverItems 2
[2017/10/01 21:56:27] removing 5 || next: 3 || current serverItems 1
[2017/10/01 21:56:27] current id 3 || current serverItems 1
[2017/10/01 21:56:27] removing 6 || next: 4 || current serverItems 0
[2017/10/01 21:56:27] current id 4 || current serverItems 0
[2017/10/01 21:56:30] current id 2 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0

`

i tried to follow that method that you can see in this topic http://forum.sa-mp.com/showthread.php?t=570937

The reason that won't work is that the loop needs to use the current slot to get
the next slot, but we just removed the current slot so it is no longer valid for
getting the next slot. Instead, we use "Iter_SafeRemove", which takes an
additional parameter to store the next slot in BEFORE the current slot is
removed:

foreach (new i : MyIter)
{
	new
		cur = i;
	if (cur == 5)
	{
		Iter_SafeRemove(MyIter, cur, i);
	}
         printf("%d", i);
}
[2017/10/01 22:27:06] 0
[2017/10/01 22:27:06] 1
[2017/10/01 22:27:06] 2
[2017/10/01 22:27:06] 3
[2017/10/01 22:27:06] 4
[2017/10/01 22:27:06] 4 // twice?
[2017/10/01 22:27:06] 6
[2017/10/01 22:27:09] 0
[2017/10/01 22:27:09] 1
[2017/10/01 22:27:09] 2
[2017/10/01 22:27:09] 3
[2017/10/01 22:27:09] 4
[2017/10/01 22:27:09] 6

and it wont crash. But if i add some condition like theese;

	foreach (new i : MyIter)
	{
		count[i]++;
		if(count[i] == 2)
		{
			new	cur = i;
			Iter_SafeRemove(MyIter, cur, i);
		}
		printf("%d", i);
	}

the result will be

[2017/10/01 22:20:51] 0
[2017/10/01 22:20:51] 1
[2017/10/01 22:20:51] 2
[2017/10/01 22:20:51] 3
[2017/10/01 22:20:51] 4
[2017/10/01 22:20:51] 5
[2017/10/01 22:20:51] 6
[2017/10/01 22:20:53] 500
[2017/10/01 22:20:53] 500
[2017/10/01 22:20:53] 0
[2017/10/01 22:20:53] 1
[2017/10/01 22:20:53] 2
[2017/10/01 22:20:53] 3
[2017/10/01 22:20:53] 4
[2017/10/01 22:20:56] 2

foreach error "IteratorArray"

Hola tengo un problema, que es cuando intento declarar un nuevo IteratorArray me da el siguiente error

(718) : error 001: expected token: "-identifier-", but found "-integer value-"

The line is..

new IteratorArray:InEdificio[MAX_EDIFICIORENTA]<MAX_PLAYERS>;

I just want to know why this happens?

FOREACH_NO_BOTS not working

I dont need NPC and Characters iterators and i use FOREACH_NO_BOTS but from last updates its not working anymore

F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(619) : error 017: undefined symbol "Bot@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(619) : error 017: undefined symbol "Bot@YSII_Ag" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(620) : error 017: undefined symbol "Character@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(620) : error 017: undefined symbol "Character@YSII_Ag" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(718) : error 017: undefined symbol "Bot@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(718) : error 017: undefined symbol "Bot@YSII_Ag" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(719) : error 017: undefined symbol "Character@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(719) : error 017: undefined symbol "Character@YSII_Ag"

Give me this errors , any way to fix it? Or i need to get rid of define?

Redefinition warning

Tried to compile your standalone version of foreach but got two warnings. Stated below.

warning 201: redefinition of constant/macro (symbol "_Y_ITER_C2:sizeof%0(%1)@YSII_Ag-1;_:(%2=_Y_ITER_ARRAY:%3(%4)@YSII_Ag[%5])!=%9_Y_ITER_ARRAY_SIZE(%6);)")
warning 201: redefinition of constant/macro (symbol "_Y_ITER_C3:%0[%1]@YSII_Cg,%2[%3]@YSII_Ag[%4]={%5}")

Tried resorting my #include order but to no avail.

EDIT: Above fixed, found another warning after above was fixed.

error 031: unknown directive (at line 224)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.