Raised This Month: $ Target: $400
 0% 

Help with Optimization!


Post New Thread Reply   
 
Thread Tools Display Modes
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 07-31-2010 , 13:40   Re: Help with Optimization!
Reply With Quote #21

Quote:
Originally Posted by Alucard^ View Post
Something like this?

Code:
#define MAX_POWERS 5 enum {     NO_POWER = 0,     POWER_1,     POWER_2,     POWER_3 }; new g_Power[33]; public function(id) {     g_Power[id] = random_num(NO_POWER, POWER_3); } public FwdTakeDamage(id, iInflictor, iAttacker, Float:fDamage, iDamagebits) {     switch(g_Power[id])     {         case NO_POWER:  // stuff         case POWER_1:   // stuff         case POWER_2:   // sutff         case POWER_3:   // stuff     } }
Ya thats what i was trying to explain to him....but u cant set 2 human classes on one player because it is not in bits....
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
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 offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 07-31-2010 , 14:12   Re: Help with Optimization!
Reply With Quote #23

Quote:
Originally Posted by Bugsy View Post
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:
    } 
simple , awesome , really thanks , + for you.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
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 23:13.


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