SA-MP Forums Archive
error 052: multi-dimensional arrays must be fully initialized - 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: error 052: multi-dimensional arrays must be fully initialized (/showthread.php?tid=613835)



SOLVED! - Shady - 01.08.2016

Hello,

I was working on my server, but I had some issues while complying/complie the script. Actually, the issue came from my rank system which I do not know what's wrong with it. I have never faced any of these errors before, so It'd be appreciated if you helped me to fix the problem/issue. I'll be writing the details below, so you can help me. Marked with Red is the line which I do receive the errors from.

Error:
pawn Код:
E:\Programming\gamemodes\csmp.pwn(3062) : error 052: multi-dimensional arrays must be fully initialized
Codes:
pawn Код:
removed



Re: error 052: multi-dimensional arrays must be fully initialized - FuNkYTheGreat - 01.08.2016

Removed On Request ( Because OF Copy Cats )


Re: error 052: multi-dimensional arrays must be fully initialized - Vince - 01.08.2016

If you declare it with 500 ranks then you also have to initialize it with 500 ranks. I recommend you let the compiler calculate the amount; keep the brackets empty (i.e. new RankInfo[][rInfo]) and use sizeof if you need to know its size.


Re: error 052: multi-dimensional arrays must be fully initialized - Shady - 01.08.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
If you declare it with 500 ranks then you also have to initialize it with 500 ranks. I recommend you let the compiler calculate the amount; keep the brackets empty (i.e. new RankInfo[][rInfo]) and use sizeof if you need to know its size.
Thanks man, it is okay now.

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Try this
Код:
removed
You too, thanks.


Re: error 052: multi-dimensional arrays must be fully initialized - Shady - 01.08.2016

Well, I am getting AMX Backtrace errors after I updated my codes to Funky's.

Errors from server logs:
pawn Код:
[15:55:43] [debug] AMX backtrace:
[15:55:43] [debug] #0 0002bd94 in ?? (0) from csmp.amx
[15:55:43] [debug] #1 00011c78 in public OnPlayerUpdate (0) from csmp.amx
[15:55:43] [debug] Run time error 4: "Array index out of bounds"
[15:55:43] [debug]  Accessing element at index 18 past array upper bound 17
[15:55:43] [debug] AMX backtrace:
[15:55:43] [debug] #0 0002bd94 in ?? (0) from csmp.amx
[15:55:43] [debug] #1 00011c78 in public OnPlayerUpdate (0) from csmp.amx
pawn Код:
deleted



Re: error 052: multi-dimensional arrays must be fully initialized - [XST]O_x - 01.08.2016

Change the loop to this:
pawn Код:
for(new x = sizeof(RankInfo)-1; x >= 0; x--)
The error is caused because you have 18 elements, indexed at 0 to 17, and you're accessing index 18 which is the 19th element which doesn't exist yet.


Re: error 052: multi-dimensional arrays must be fully initialized - Konstantinos - 01.08.2016

This is incorrect:
pawn Код:
for(new x = 18; x != 0; x--)
The size of the array is 18 and that makes 0-17 as valid indexes. Your loops goes (backwards) from 18-1. Change to:
pawn Код:
for(new x = sizeof RankInfo - 1; x != -1; x--)
@[XST]O_x: "x" still starts at 18 and the first index will never be accessed.


Re: error 052: multi-dimensional arrays must be fully initialized - [XST]O_x - 01.08.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
This is incorrect:
pawn Код:
for(new x = 18; x != 0; x--)
The size of the array is 18 and that makes 0-17 as valid indexes. Your loops goes (backwards) from 18-1. Change to:
pawn Код:
for(new x = sizeof RankInfo - 1; x != -1; x--)
@[XST]O_x: "x" still starts at 18 and the first index will never be accessed.
Yes. I forgot to decrease 1


Re: error 052: multi-dimensional arrays must be fully initialized - Shady - 01.08.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
This is incorrect:
pawn Код:
for(new x = 18; x != 0; x--)
The size of the array is 18 and that makes 0-17 as valid indexes. Your loops goes (backwards) from 18-1. Change to:
pawn Код:
for(new x = sizeof RankInfo - 1; x != -1; x--)
@[XST]O_x: "x" still starts at 18 and the first index will never be accessed.
Thank you, Konstantinos.

This problem has been solved.