Raised This Month: $ Target: $400
 0% 

Enum bits for menu options


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-08-2019 , 12:27   Re: Enum bits for menu options
Reply With Quote #1

Associating a selection with a string really only works when using an integer-sized enum since it's an identical association. 0 in the enum corresponds to index 0 in the string array, and so on. This is not as easily done using bit-fields. Technically this will work if you allowed only 1 Option selection per player, but when allowing multiple, this will not work without checking if each individual bit exists and adding the option name to the string.

Your enum:
Code:
Option1 = 1
Option2 = 2
Option3 = 4
Option4 = 8
Option5 = 16
PHP Code:
new const MenuOptionsOptions ][] = 
This will result in an array sized at [ 32 * string size ] while you would only use [ 5 * string size ], which is a waste of memory.

You would also need to define your Options names like this:
PHP Code:
new const MenuOptionsOptions ][] = 
{
    
"",
    
"Option 1",  // 1
    
"Option 2",  // 2
    
"",
    
"Option 3",  // 4
    
"",
    
"",
    
"",
    
"Option 4",  // 8
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"Option 5",  // 16
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
"",
    
""
}; 
IMO, at your skill level you may be better off using an array of integers to store which option(s) a player has selected. I'm not saying what you want is not doable, but I'm not sure you will be able to do this yourself.
__________________

Last edited by Bugsy; 09-08-2019 at 12:30.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:29.


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