SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 24/06/2017, 08:32 AM   #61
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,948
Reputation: 504
Default Re: foreach 0.4.1 standalone include

Quote:
Originally Posted by Gammix View Post
Hey, is there way to access indexes of a foreach loop.

Lets say my iterator consists following elements:
PHP Code:
524532763145924010
// total elements = 10 
Now i want the loop to start from 76 (i.e. 4th index), but is there any way other than using "continue" inside the loop?
AFAIK , foreach sorts array and the values are index for internal array (iterator@name[]). So 76 wont be the 4th index

PHP Code:

main
()
{
    new 
Iterator:samp<93>;
    
    
Iter_Add(samp5);
    
Iter_Add(samp24);
    
Iter_Add(samp53);
    
Iter_Add(samp2);
    
Iter_Add(samp76);
    
Iter_Add(samp31);
    
Iter_Add(samp45);
    
Iter_Add(samp92);
    
Iter_Add(samp40);
    
Iter_Add(samp10);
    
    for(new 
=76;i!=93;i=Iterator@samp[i])
    {
        
printf("%d",i);
    }

will print
Code:
76
92

Last edited by SyS; 24/06/2017 at 09:28 AM.
SyS is offline   Reply With Quote
Old 24/06/2017, 10:39 AM   #62
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,766
Reputation: 840
Default Re: foreach 0.4.1 standalone include

Hey, thanks. I figured i can make my own modifications to foreach for making it work my way. For now i'll use normal loops since they are easy for the task i am currently working on.
__________________

Follow me on Github: Follow me on Spotify: Donate on Paypal:

Gammix is online now   Reply With Quote
Old 27/06/2017, 06:43 AM   #63
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,940
Reputation: 538
Default Re: foreach 0.4.1 standalone include

So currently the only issue is gmxing?

I'll work on that.
Kar is offline   Reply With Quote
Old 06/08/2017, 02:28 AM   #64
Jastak
Huge Clucker
 
Jastak's Avatar
 
Join Date: Jan 2015
Location: Esparta
Posts: 276
Reputation: 17
Default Re: foreach 0.4.1 standalone include

Hello I have a problem, that is when I try to declare a new IteratorArray gives me the following error (<- EDIT, SORRY)

Code:
(718) : error 001: expected token: "-identifier-", but found "-integer value-"
The line is..

Code:
new IteratorArray:InEdificio[MAX_EDIFICIORENTA]<MAX_PLAYERS>;
I just want to know why this happens?
__________________
The Lag is real!
Jastak is offline   Reply With Quote
Old 07/08/2017, 12:34 AM   #65
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,940
Reputation: 538
Default Re: foreach 0.4.1 standalone include

Quote:
Originally Posted by Jastak View Post
Hello I have a problem, that is when I try to declare a new IteratorArray gives me the following error (<- EDIT, SORRY)

Code:
(718) : error 001: expected token: "-identifier-", but found "-integer value-"
The line is..

Code:
new IteratorArray:InEdificio[MAX_EDIFICIORENTA]<MAX_PLAYERS>;
I just want to know why this happens?
Tested

Code:
new Iterator:InEdificio[1000]<MAX_PLAYERS>;
And it compiles fine for me.
Kar is offline   Reply With Quote
Old 27/08/2017, 01:04 AM   #66
Unrea1
Gangsta
 
Unrea1's Avatar
 
Join Date: Oct 2013
Location: Venezuela
Posts: 792
Reputation: 126
Default Re: foreach 0.4.1 standalone include

Add support for vehicles, good job.
__________________
Unrea1 is offline   Reply With Quote
Old 02/10/2017, 08:27 PM   #67
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,940
Reputation: 538
Default Re: foreach 0.4.1 standalone include

Update your foreach include.

https://github.com/karimcambridge/SAMP-foreach/releases
Kar 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
Foreach include SkyLoKi Scripting Help 8 06/03/2015 03:48 PM
when i include foreach thats what i get.. KillerStrike23 Scripting Help 2 21/05/2014 01:26 PM
[Pedido] Include foreach Krusheer Português/Portuguese 0 26/04/2014 03:45 PM
[Ajuda] include foreach minimessi10 Português/Portuguese 7 27/03/2014 07:22 PM
[Pedido] Include SII foreach fackbook Português/Portuguese 5 16/01/2013 04:25 PM


All times are GMT. The time now is 10:17 AM.


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