SA-MP Forums Archive
[HELP] About "for" (maybe all loops) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] About "for" (maybe all loops) (/showthread.php?tid=268635)



[HELP] About "for" (maybe all loops) - Diagram - 13.07.2011

First of all forgive me with making double topics when the last one is pretty much unsolved yet.

I tried using a loop with "for" and then put another code down there, but after the loop finishes the code below the loop sometimes can't be executed.

What I meant maybe is well-explained by an example :
pawn Код:
for(new i = 1; i <= 20; i++)
{
      // do something in here
}
SendClientMessage(playerid, WHITE, "asd");
Note that this is only an example.
With this code, the SendClientMessage won't be executed. Am I doing the loop wrong, or is there another reason why this happens often?
Thanks in advance.


Re: [HELP] About "for" (maybe all loops) - LetsOWN[PL] - 13.07.2011

You tried to put this [pawn]SendClientMessage(playerid, WHITE, "asd");[/quote] above this "for"?


Re: [HELP] About "for" (maybe all loops) - Macluawn - 13.07.2011

it depends on what sort of code you use in the loop.


Re: [HELP] About "for" (maybe all loops) - Diagram - 13.07.2011

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
You tried to put this [pawn]SendClientMessage(playerid, WHITE, "asd");above this "for"?
This is just an example. In my real code I used some ini system to load a few files containing a few similar datas needed for the code below, and it won't work sadly.

Quote:
Originally Posted by Macluawn
Посмотреть сообщение
it depends on what sort of code you use in the loop.
Such as?
I'm actually using Double-O-Files inside the loop, how does it affect the loop?


Re: [HELP] About "for" (maybe all loops) - Macluawn - 13.07.2011

check if the array, in which you are saving data, is large enough to contain the values.


Re: [HELP] About "for" (maybe all loops) - [HiC]TheKiller - 13.07.2011

You are most probably returning a value during that loop which is causing anything after it, not to be parsed.


Re: [HELP] About "for" (maybe all loops) - Diagram - 13.07.2011

Quote:
Originally Posted by Macluawn
Посмотреть сообщение
check if the array, in which you are saving data, is large enough to contain the values.
All of them are integers actually.

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
You are most probably returning a value during that loop which is causing anything after it, not to be parsed.
I'm not sure about this, though I did deleted return 1 and it still won't work.
DOF has also OnParseFile which I'm not using. Prefer using the same techniques as dini.
More explanation?


Re: [HELP] About "for" (maybe all loops) - Diagram - 13.07.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
That's not what they asked - the fact that you are using "<=" rather than "<" leads me to believe this may well be the problem. Check your indexes.
Oh my goodness, this really solved all the problems!
Thanks so much everybody!