SA-MP Forums Archive
Why am I getting these errors? - 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: Why am I getting these errors? (/showthread.php?tid=590030)



[SOLVED] Why am I getting these errors? - unSatisfied - 24.09.2015

Why doesn't the following code work? How can I fix this?

Код:
#define MAX_FACTIONS 10
enum _FactionData
{
        Weapons[47]
};

new FactionData[MAX_FACTIONS][_FactionData];
main()
{
        FactionData[0][Weapons[0]] = 1;
}
Errors:

error 028: invalid subscript (not an array or too many subscripts): "Weapons"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

EDIT: The fix seems to be to replace FactionData[0][Weapons[0]] = 1; with FactionData[0][Weapons][0] = 1; Can anyone explain why it isn't the way I originally coded it?


AW: Why am I getting these errors? - Kaliber - 24.09.2015

Because it's an enum.

And when you uses an Array in an enum it adds a new dimension in your array.

Thats why you have to do:

PHP код:
FactionData[0][Weapons][0] = 1



Re: AW: Why am I getting these errors? - unSatisfied - 25.09.2015

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Because it's an enum.

And when you uses an Array in an enum it adds a new dimension in your array.

Thats why you have to do:

PHP код:
FactionData[0][Weapons][0] = 1
Ah okay I see, thanks for the explanation.