Run time error 4: "Array index out of bounds"
#1

I have the function, SaveData which is called every 100 seconds.

This is the function.
Код:
public SaveData()
{
        foreach(Player, x)
		{
			savePlayerData(x);
		}
		for(new xh = 0; xh < MAX_HOUSES; xh++)
		{
            saveHouse(xh);
		}
		for(new xf = 0; xf < MAX_GROUPS; xf++)
		{
            saveGroup(xf);
		}
		for(new xc = 0; xc < MAX_CLANS; xc++)
		{
            saveClan(xc);
		}
		for(new xf = 0; xf < MAX_BUSINESSES; xf++)
		{
            saveBusiness(xf);
		}
		for(new xf = 0; xf < MAX_ASSETS; xf++)
		{
            saveAsset(xf);
		}
		for(new ff = 0; ff < 999; ff++)
		{
            saveDealer(ff);
		}
}
Now, when the that function is called, I get this error:
Код:
[01:41:01] [debug] Run time error 4: "Array index out of bounds"
[01:41:01] [debug]  Accessing element at index 612 past array upper bound 611
[01:41:01] [debug] AMX backtrace:
[01:41:01] [debug] #0 0008e970 in ?? (612) from orion.amx
[01:41:01] [debug] #1 00170180 in public SaveData () from orion.amx
I have no idea why.
These are the defines.
Код:
#define                 MAX_HOUSES                              69
#define                 MAX_GROUPS                              69
#define                 MAX_CLANS                               69
#define                 MAX_ASSETS                              (10)
#define                 MAX_BUSINESSES                          69
I really need this one fixed, thanks!
Also, when I was testing this out there we're the following things:
Код:
251 vehicle,
22 businesses,
41 houses,
1 player,
2 assets (total in the database).
Reply
#2

Comment out certain sections of the code and try to locate where it's exactly producing the error.
Reply
#3

You're going through 999 on the last save?

PHP код:
#define                 MAX_ASSETS                              (10) 
Why the brackets?
Reply
#4

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You're going through 999 on the last save?

PHP код:
#define                 MAX_ASSETS                              (10) 
Why the brackets?
I thought that it would look better xD, I don't think that that's the problem. Aso there are max 999 dealer vehicles, that's why its 999.
Reply
#5

Compile with -d3 flag: https://github.com/Zeex/samp-plugin-...ith-debug-info
Start the server and wait for SaveData to be called. Post the new logs.

The problem is definitely in saveDealer as it's the only one with parameter value of 612. You probably have an array with size of 612 instead of 999 in that.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Compile with -d3 flag: https://github.com/Zeex/samp-plugin-...ith-debug-info
Start the server and wait for SaveData to be called. Post the new logs.

The problem is definitely in saveDealer as it's the only one with parameter value of 612. You probably have an array with size of 612 instead of 999 in that.
Compiling with that flag gets me the following errors.

Код:
Old 12/04/2016, 07:10 PM	  #1
danielpalade
Big Clucker

 
Join Date: Aug 2013
Posts: 169
Reputation: 1
Default What are these errors about?
What are these errors?
Code:
C:\Program Files (x86)\Compiler\include\sscanf2.inc(305) : warning 218: old style prototypes used with optional semicolumns
C:\Program Files (x86)\Compiler\include\sscanf2.inc(365) : warning 218: old style prototypes used with optional semicolumns
C:\Program Files (x86)\Compiler\include\YSI\y_debug.inc(395) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_debug.inc(395) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(393) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(393) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(437) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(437) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(658) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(658) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(958) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(958) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(966) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_amx.inc(966) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(198) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(198) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(227) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(227) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(228) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(228) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(239) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(239) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(249) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(249) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(255) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(255) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(274) : error 036: empty statement
C:\Program Files (x86)\Compiler\include\YSI\y_hooks/impl.inc(274) : error 036: empty statement
Reply
#7

Nvm, fixed it! Thanks to everyone
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)