Raised This Month: $ Target: $400
 0% 

Optimization


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 01-23-2017 , 16:35   Re: Optimization
Reply With Quote #5

Unfortunately you can't use a switch because get_user_flags() will return a bitsum. So it will never be EQUAL TO ADMIN_KICK, it will INCLUDE ADMIN_KICK.
You could use this:
Code:
switch ( get_user_flags(id) & ( ADMIN_KICK | ADMIN_SLAY ) ) {     case ADMIN_KICK : {} // Only kick     case ADMIN_SLAY : {} // Only slay     case ( ADMIN_KICK | ADMIN_SLAY ) : {} // Both     default : {} // Neither }
But I'm sure you can see that it's just not good enough. You immediately have to create one more option. And for every option added, the number of options around grows exponentially since you have to take consideration for all the different combinations of options.
Also, if you are considering converting it to cvars to be able to change the different levels required more easily by the end user, switches are out completely.

If you have all of these in multiple locations I would say that your menu system is not dynamic enough. You can definitely make it more dynamic and end up with one handler with just one message.
But if you find it hard to create that kind of advanced menu, then I would suggest a stock.

In the end it's a function that is called whenever someone uses a command or a menu which is rare in general. You do not have to worry about performance at all and should use the method that makes the code easy to work with without breaking readability.
__________________

Last edited by Black Rose; 01-23-2017 at 16:43.
Black Rose is offline
 



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 20:50.


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