View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-31-2010 , 13:51   Re: Help with Optimization!
Reply With Quote #22

If you are using multiple flags and want to use switch(), you can do:
PHP Code:
    //Set both Glow and Gravity powers on player
    
SetFlagid Glow Gravity );
    
    switch ( 
g_WeaponFlagsid ] )
    {
        case ( 
Glow ): //Called if player has ONLY glow power
        
case ( Gravity ): //Called if player has ONLY gravity power
        
case ( Glow Gravity ): //Called since player has both flags. Cant have any other, though.
        
default: 
    }
    
    
ClearFlagsid );

    
//You can also remove flag(s) for the switch statement comparison:
    
    //Below is how to do so with multiple flags:
    
g_WeaponFlagsid ] & ~( Freeze Explode Crush );

    
//Set flags for player.
    
SetFlagid Freeze Glow Gravity );

    
//This will eliminate only the Freeze flag for this comparison
    
switch ( g_WeaponFlagsid ] & ~Freeze )
    {
        case ( 
Glow ): 
        case ( 
Gravity ): 
        case ( 
Glow Gravity ): //this code will be called
        
default:
    } 
__________________

Last edited by Bugsy; 07-31-2010 at 13:57.
Bugsy is online now