View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-17-2012 , 13:27   Re: [DEV] TF2 Item Info v1.8 (15.05.12)
Reply With Quote #10

Quote:
Originally Posted by Leonardo View Post
I'll fix it if you tell me how to get size of an enum~
Quoting asherkin from another thread:

Quote:
Originally Posted by asherkin View Post
An enum = a list of named values, i.e.
Code:
enum AnEnum
{ 
    AnEnum_FirstValue,
    AnEnum_SecondValue,
    AnEnum_ThirdValue,
    AnEnum_FourthValue,
    AnEnum_FifthValue,
};
Now, if you print the values of each, you get:
AnEnum_FirstValue = 0
AnEnum_SecondValue = 1
AnEnum_ThirdValue = 2
AnEnum_FourthValue = 3
AnEnum_FifthValue = 4

This works with arrays because the name of the enum evaluates to the next number that would be assigned to an entry in it (AnEnum = 5),
so if you do
Code:
new AnArray[AnEnum];
you get an array with 5 members
In fact, this should work regardless because even sparse enums (with skipped values) will have a large enough array to store all values if you use the enum name. I actually just learned this today...
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline