View Single Post
MatheusMARAN
Junior Member
Join Date: Apr 2010
Location: Paraná, BR
Old 03-28-2011 , 04:13   Re: [Addon] Monster XP
Reply With Quote #31

PHP Code:
    if ( equal(monsterModel"models/agrunt.mdl") ) {
            
monsterName "Alien Grunt"
            
xp get_pcvar_num(AgrXP)
        }
        else if ( 
equal(monsterModel"models/apache.mdl") ) {
            
monsterName "Apache"
            
xp get_pcvar_num(ApaXP)
        }
        else if ( 
equal(monsterModel"models/barney.mdl") ) {
            
monsterName "Barney"
            
xp get_pcvar_num(BarXP)
        }
        else if ( 
equal(monsterModel"models/big_mom.mdl") ) {
            
monsterName "Big Momma"
            
xp get_pcvar_num(BigXP)
        }
        else if ( 
equal(monsterModel"models/bullsquid.mdl") ) {
            
monsterName "Bull Squid"
            
xp get_pcvar_num(BulXP)
        }
        else if ( 
equal(monsterModel"models/controller.mdl") ) {
            
monsterName "Controller"
            
xp get_pcvar_num(ConXP)
        }
        else if ( 
equal(monsterModel"models/garg.mdl") ) {
            
monsterName "Gargantua"
            
xp get_pcvar_num(GarXP)
        }
        else if ( 
equal(monsterModel"models/headcrab.mdl") ) {
            
monsterName "Head Crab"
            
xp get_pcvar_num(HeaXP)
        }
        else if ( 
equal(monsterModel"models/houndeye.mdl") ) {
            
monsterName "Hound Eye"
            
xp get_pcvar_num(HouXP)
        }
        else if ( 
equal(monsterModel"models/hassassin.mdl") ) {
            
monsterName "Human Assassin"
            
xp get_pcvar_num(HasXP)
        }
        else if ( 
equal(monsterModel"models/hgrunt.mdl") ) {
            
monsterName "Human Grunt"
            
xp get_pcvar_num(HgrXP)
        }
        else if ( 
equal(monsterModel"models/scientist.mdl") ) {
            
monsterName "Scientist"
            
xp get_pcvar_num(SciXP)
        }
        else if ( 
equal(monsterModel"models/islave.mdl") ) {
            
monsterName "Slave"
            
xp get_pcvar_num(IslXP)
        }
        else if ( 
equal(monsterModel"models/w_squeak.mdl") ) {
            
monsterName "Snark"
            
xp get_pcvar_num(SnaXP)
        }
        else if ( 
equal(monsterModel"models/zombie.mdl") ) {
            
monsterName "Zombie"
            
xp get_pcvar_num(ZomXP)
        }
        else {
            return
        } 
Replace it with:
PHP Code:
        switch ( monsterModel ) {
            case 
"models/agrunt.mdl": {
                
monsterName "Alien Grunt"
                
xp get_pcvar_num(AgrXP)
            }
            case 
"models/apache.mdl": {
                
monsterName "Apache"
                
xp get_pcvar_num(ApaXP)
            }
            case 
"models/barney.mdl": {
                
monsterName "Barney"
                
xp get_pcvar_num(BarXP)
            }
            case 
"models/big_mom.mdl": {
                
monsterName "Big Momma"
                
xp get_pcvar_num(BigXP)
            }
            case 
"models/bullsquid.mdl": {
                
monsterName "Bull Squid"
                
xp get_pcvar_num(BulXP)
            }
            case 
"models/controller.mdl": {
                
monsterName "Controller"
                
xp get_pcvar_num(ConXP)
            }
            case 
"models/garg.mdl": {
                
monsterName "Gargantua"
                
xp get_pcvar_num(GarXP)
            }
            case 
"models/headcrab.mdl": {
                
monsterName "Head Crab"
                
xp get_pcvar_num(HeaXP)
            }
            case 
"models/houndeye.mdl": {
                
monsterName "Hound Eye"
                
xp get_pcvar_num(HouXP)
            }
            case 
"models/hassassin.mdl": {
                
monsterName "Human Assassin"
                
xp get_pcvar_num(HasXP)
            }
            case 
"models/hgrunt.mdl": {
                
monsterName "Human Grunt"
                
xp get_pcvar_num(HgrXP)
            }
            case 
"models/scientist.mdl": {
                
monsterName "Scientist"
                
xp get_pcvar_num(SciXP)
            }
            case 
"models/islave.mdl": {
                
monsterName "Slave"
                
xp get_pcvar_num(IslXP)
            }
            case 
"models/w_squeak.mdl": {
                
monsterName "Snark"
                
xp get_pcvar_num(SnaXP)
            }
            case 
"models/zombie.mdl": {
                
monsterName "Zombie"
                
xp get_pcvar_num(ZomXP)
            }
            default: { return }
        } 
That code runs faster and is cleaner as well.
__________________
Kewl sign goes here
MatheusMARAN is offline
Send a message via MSN to MatheusMARAN