SA-MP Forums Archive
Maximum Number for For Loop - 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: Maximum Number for For Loop (/showthread.php?tid=671210)



Maximum Number for For Loop - grymtn - 16.12.2019

Hello All i have a loop to check some stuff. If i set a for loop like
Code:
for(new i=0; i<600000; i++)
this causes Command Crash and returns me Command Not Found. What is the maximum number i can have it checked?


Re: Maximum Number for For Loop - Joe Staff - 16.12.2019

For loops can be infinite, what's causing the crash is what you're using with it.


Re: Maximum Number for For Loop - grymtn - 16.12.2019

i used to use MAX_OBJECTS which is 1000 instead of 600000 only thing i changed in the command is that and when it was MAX_OBJECTS it worked fine.


Re: Maximum Number for For Loop - Joe Staff - 16.12.2019

Well since you haven't posted any code, I can only assume you're creating or modifying objects. The for loop does not have a limit, but objects do, hence the 'MAX_OBJECTS' defined value.


Re: Maximum Number for For Loop - InglewoodRoleplay - 16.12.2019

The for loop itself can't be causing a crash, but something that deals with the variable being incremented may be causing it to crash. Perhaps something you're doing is causing a stack overflow, I'd suggest compiling the script with debugging features and using something such as crashdetect so you can get a stack trace of what's going on once it crashes.

To compile with debugging features enabled:
pawn Code:
pawncc yourscript.pwn -;+ -(+ -d3
Crashdetect:
https://github.com/Zeex/samp-plugin-crashdetect