Tips & Tricks - 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)
+---- Forum: Discussion (
https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Tips & Tricks (
/showthread.php?tid=216730)
Re: Tips & Tricks -
Y_Less - 09.06.2018
The wiki doesn't use a colon. YSI doesn't use a colon. pawn-lang.pdf doesn't use a colon. I've literally never seen any code that uses a colon, and I'm amazed it even compiles with a colon.
Frankly, I'm not even sure why you're asking. You've found that using a colon means that the enum can't be used in many situations, and not using a colon does the same thing, so why even pursue the clearly inferior route?
I did just do some experimentation, I think this is what's happening:
PHP код:
enum E_THING (*= 3)
{
E_A
}
That is an enum called "E_THING" that increases every value 3-fold.
PHP код:
enum E_THING:(+= 77)
{
E_A
}
That is an anonymous enum, which means that you can't do things like `new arr[E_THING]`, because that enum doesn't exist with that name. Instead, it is the same as doing:
PHP код:
enum (+= 77)
{
E_A
}
But with a tag override on the increment. Which is interesting, because that means that all the enum elements still have the TAG `E_THING`, but the enum called `E_THING` doesn't exist.
Edit: Actually, the tagging without being usable as array sizes has use.
Edit 2: After some discussion on discord, this also works:
Which is a nameless (sizeless) enum with a tag of `e_TAG`.
However, totally unrelated to this point. Your original question was about using this in arrays. If you do:
PHP код:
enum E_NUM (<<= 1)
{
E_NUM_0 = 1,
E_NUM_1,
E_NUM_2,
}
Then the total size (the value of `E_NUM`) will be 8, not 3, because it is still subject to the same shifting rules.