Creating enums
#1

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

Reply
#2

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.
Reply
#3

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?
Reply
#4

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]; 
Reply
#5

Little explanation about enums:
https://sampforum.blast.hk/showthread.php?tid=318307
Reply
#6

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)