PDA

View Full Version : initializer problem


TheSimpleGuy
01/05/2016, 03:35 PM
How do I initialize an array inside an array in an enum?

enum ClassInfo
{
Name[128],
Description[128],
ScoreRequired,
Weapon[3], //must initialize
WeaponAmmo[3] //must initialze
};
new cInfo[][ClassInfo] =
{
{"Assault", "The most basic class of all the classes.", 0, 34, 34, 34, 100, 100, 100} // error
{"Assault", "The most basic class of all the classes.", 0, 34, 35, 36, 100, 100, 100}
{"Assault", "The most basic class of all the classes.", 0, 37, 38, 39, 100, 100, 100}
};


rtdm.pwn(63) : warning 227: more initiallers than enum fields
rtdm.pwn(63) : warning 227: more initiallers than enum fields
rtdm.pwn(63) : warning 227: more initiallers than enum fields
rtdm.pwn(63) : warning 227: more initiallers than enum fields
rtdm.pwn(63) : error 018: initialization data exceeds declared size
rtdm.pwn(66) : error 010: invalid function or declaration

I get why the errors are like that, but I really do not know how to solve my problem.

Gammix
01/05/2016, 03:38 PM
Weapon[3] is an array within so you have to use '{' brackets.

{"Assault", "The most basic class of all the classes.", 0, {34, 34, 34}, {100, 100, 100}}

Konstantinos
01/05/2016, 03:40 PM
You need to wrap them inbetween { }


new cInfo[][ClassInfo] =
{
{"Assault", "The most basic class of all the classes.", 0, {34, 34, 34}, {100, 100, 100}},
{"Assault", "The most basic class of all the classes.", 0, {34, 35, 36}, {100, 100, 100}},
{"Assault", "The most basic class of all the classes.", 0, {37, 38, 39}, {100, 100, 100}}
};


and you also forgot the , on the first two.

TheSimpleGuy
01/05/2016, 03:41 PM
Thank you very much guys. :)