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

Getting that error on this line:

pawn Код:
new ItemName[MAX_ITEMS][11] = {"Wood", "Stone", "Steel", "Gun powder", "Plastic", "Flint", "Rubber", "Tin", "Cloth", "Skin", "Meat", "Fish", "Aspirin", "Antibiotic", "Flask", "Alcohol"};
My first time to use such arrays, usually I used stock which would return name so may someone tell me what's wrong?
Reply
#2

show me the MAX_ITEMS define
Reply
#3

pawn Код:
#define MAX_ITEMS           (18)
Reply
#4

Maybe try this?
pawn Код:
new ItemName[MAX_ITEMS][] = {
{"Wood"},
{"Stone"},
{"Steel"},
{"Gun powder"},
{"Plastic"},
{"Flint"},
{"Rubber"},
{"Tin"},
{"Cloth"},
{"Skin"},
{"Meat"},
{"Fish"},
{"Aspirin"},
{"Antibiotic"},
{"Flask"},
{"Alcohol"}
};
Reply
#5

ok so basically you are defining the array but not using storing the values in it

a short example with enum:
PHP код:
enum itemInfo {  // enums used for the items
    
iname[256]
}; 
PHP код:
new ItemName[][itemInfo] = { // you left the items unlimited as you can see i haven't enter any value in []

{"Wood"}, 
{
"Stone"}, 
{
"Steel"

}; 
here i have entered 3 rows with only 1 column , which was iname(itemname) under iteminfo enum
where you are trying to use array for 18 rows and 11 columns

Must be somthing like

PHP код:
new ItemName[MAX_ITEMS][11] = {
{
0,1,2,3,4,5,6,7,8,9,10}, // row 1
{0,1,2,3,4,5,6,7,8,9,10}, // row 2
{0,1,2,3,4,5,6,7,8,9,10}, // row 3
.
.
.
{
0,1,2,3,4,5,6,7,8,9,10// row n
}; 
Reply
#6

Quote:
Originally Posted by biker122
Посмотреть сообщение
Maybe try this?
pawn Код:
new ItemName[MAX_ITEMS][] = {
{"Wood"},
{"Stone"},
{"Steel"},
{"Gun powder"},
{"Plastic"},
{"Flint"},
{"Rubber"},
{"Tin"},
{"Cloth"},
{"Skin"},
{"Meat"},
{"Fish"},
{"Aspirin"},
{"Antibiotic"},
{"Flask"},
{"Alcohol"}
};
As this guy showed you the perfect code, but still there's something wrong with it
you have defined 18 values in MAX_Items, and this code is useing 16..
you will face error
Reply
#7

I don't know what and how, I just tried to compile his given code in my script and I didn't recieve any warnings/errors.
And yeah, I just noticed that out, Fred1993!
Reply
#8

11 was supposed to be string size for it
Gun powder has 10 letters along with antibiotic so I made size for it 11 as bigger isn't needed yet
Reply
#9

Quote:
Originally Posted by LocMax
Посмотреть сообщение
11 was supposed to be string size for it
If you want to add string size, use the enum method i explained. that will help.
just add MAX_ITEMS in []

Example:

PHP код:
enum itemInfo {  // enums used for the items
    
iname[256]
};
new 
ItemName[MAX_ITEMS][itemInfo] = { 
{
"Wood"}, 
{
"Stone"}, 
{
"Steel"}  //add your items name here
}; 
Reply
#10

Not working
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)