error 052: multi-dimensional arrays must be fully initialized
#1

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
Reply
#2

Removed On Request ( Because OF Copy Cats )
Reply
#3

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.
Reply
#4

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.
Reply
#5

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
Reply
#6

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.
Reply
#7

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.
Reply
#8

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
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)