SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/12/2019, 12:03 AM   #1
grymtn
Huge Clucker
 
Join Date: Jun 2013
Posts: 272
Reputation: 26
Default Maximum Number for For Loop

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?
grymtn is offline   Reply With Quote
Old 16/12/2019, 12:06 AM   #2
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: Maximum Number for For Loop

For loops can be infinite, what's causing the crash is what you're using with it.
Joe Staff is offline   Reply With Quote
Old 16/12/2019, 12:15 AM   #3
grymtn
Huge Clucker
 
Join Date: Jun 2013
Posts: 272
Reputation: 26
Default Re: Maximum Number for For Loop

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.
grymtn is offline   Reply With Quote
Old 16/12/2019, 12:48 AM   #4
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: Maximum Number for For Loop

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.
Joe Staff is offline   Reply With Quote
Old 16/12/2019, 01:57 AM   #5
InglewoodRoleplay
Big Clucker
 
Join Date: Oct 2013
Posts: 67
Reputation: 8
Default Re: Maximum Number for For Loop

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
InglewoodRoleplay 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
How to change The Maximum number of Vehicles ? EgyptForLife Scripting Help 5 08/09/2014 07:01 PM
Error: Your message is so long, or reached the maximum letters number. AnonScripter Scripting Help 10 02/06/2014 09:50 AM
Maximum number of filterscripts problem Red_Dragon. Scripting Help 12 19/04/2013 08:50 PM
Maximum number of objects? Mr.GeEk Help Archive 2 26/07/2011 05:58 PM
MSGBOX the maximum number of characters? billy4601 Help Archive 6 19/03/2010 08:14 PM


All times are GMT. The time now is 04:39 AM.


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