Enum bits for menu options
Hi!
I want to create a options menu for players to turn on/off things in my server, and I want to create a enumeration with all options, to see if it's on and off. The best way to do it is with bits? like: PHP Code:
|
Re: Enum bits for menu options
You are going in the right direction now just create an array with 33 cells for players to store the data.
PHP Code:
|
Re: Enum bits for menu options
Right, made it!
Now I want to create a const to give "names" to that option in the menu, is this the right way? PHP Code:
PHP Code:
|
Re: Enum bits for menu options
just a note :
Code:
Code:
|
Re: Enum bits for menu options
Quote:
|
Re: Enum bits for menu options
The charsmax is a macro which contains the same thing you've used. Basically it's the same, but amxx already gives you a format to make it easier to write, so you can use it, its up to you.
|
Re: Enum bits for menu options
Code:
Code:
Code:
Code:
Code:
|
Re: Enum bits for menu options
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 = 1PHP Code:
You would also need to define your Options names like this: PHP Code:
|
Re: Enum bits for menu options
You could do it in a different way:
PHP Code:
But you get the point. |
Re: Enum bits for menu options
I don't see a benefit in using bit-sums here, unless I am missing something. The only exception would be is if you did not need to associate an item with it's string name; in this case bitsums can save you a bit of coding. The below will be much easier to understand if you are just starting.
PHP Code:
|
| All times are GMT -4. The time now is 17:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.