Creating enums - 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: Creating enums (
/showthread.php?tid=619084)
Creating enums -
EtayJ - 13.10.2016
I see that lots of tutorials and the wiki create enums this way:
PHP код:
enum E_MY_ARRAY
{
E_MY_ARRAY_MONEY,
E_MY_ARRAY_GUN
}
Prefix - 'e', capital letters and underlines, is it required? Would it be fine to do something like that?
PHP код:
enum playerInfo
{
money,
gun,
someExample
}
Re: Creating enums -
Vince - 13.10.2016
No, it is not required but it avoids confusion. It is customary to write constants in all upper case and the E_ prefix is used to denote that it's part of an enumerator. It is important to note that enum specifiers are not variables; in a sense, it is a structured list of definitions.
Re: Creating enums -
EtayJ - 13.10.2016
Quote:
Originally Posted by Vince
No, it is not required but it avoids confusion. It is customary to write constants in all upper case and the E_ prefix is used to denote that it's part of an enumerator. It is important to note that enum specifiers are not variables; in a sense, it is a structured list of definitions.
|
Thank you.
The enum itsels does not contain variables but when I do something like:
PHP код:
new playerInfo[enum]
Then playerInfo will contain a set of variables as we defined in the enum, am I right?
Re: Creating enums -
Gotham - 13.10.2016
Quote:
Originally Posted by EtayJ
Thank you.
The enum itsels does not contain variables but when I do something like:
PHP код:
new playerInfo[enum]
Then playerInfo will contain a set of variables as we defined in the enum, am I right?
|
Should be:
PHP код:
new playerInfo[MAX_PLAYERS][enumname];
and a simple tutorial of a simple enum:
PHP код:
enum enumname
{
things, // don't forget these commas , if it's the last one don't put a comma
things
}
new playerInfo[MAX_PLAYERS][enumname];
Re: Creating enums -
AmigaBlizzard - 13.10.2016
Little explanation about enums:
https://sampforum.blast.hk/showthread.php?tid=318307
Re: Creating enums -
EtayJ - 14.10.2016
Thank you