initializer problem - 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: initializer problem (
/showthread.php?tid=606227)
initializer problem -
TheSimpleGuy - 01.05.2016
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.
Re: initializer problem -
Gammix - 01.05.2016
Weapon[3] is an array within so you have to use '{' brackets.
pawn Код:
{"Assault", "The most basic class of all the classes.", 0, {34, 34, 34}, {100, 100, 100}}
Re: initializer problem -
Konstantinos - 01.05.2016
You need to wrap them inbetween { }
pawn Код:
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.
Re: initializer problem -
TheSimpleGuy - 01.05.2016
Thank you very much guys.