AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   enum (https://forums.alliedmods.net/showthread.php?t=50476)

tlc660 01-27-2007 07:57

enum
 
Code:

enum Test{
    A = 0,
    B = 1,
    C = 2,
    D = 4
}

how to get the enum' value?
i have try Test.A but not working

[ --<-@ ] Black Rose 01-27-2007 11:16

Re: enum
 
Code:
enum Test {     A,     B,     C,     D } new array[Test] server_print("%d", array[C]) // will print 0

tlc660 01-27-2007 12:29

Re: enum
 
you mean just direct using the member?

that mean i cant have 2 enum with same member name?
like:
Code:

enum testA{
  A,
  B,
  C
}
enum testB{
  C,
  D,
  E
}


schnitzelmaker 01-27-2007 14:10

Re: enum
 
Yes and No,enums are global and the Compiler dont know which member you mean.
If you have 2 enums with same member name you need a specific ident to the enum you want.

Here examples what i mean
Code:
e1[testA:C] = 10 e2[testB:C] = 20 console_print(0,"test:%d,%d",e1[testA:C],e2[testB:C])

tlc660 01-28-2007 14:48

Re: enum
 
thanks schnitzelmaker, also the answer at another enum topic :wink:


All times are GMT -4. The time now is 22:24.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.