Raised This Month: $ Target: $400
 0% 

Is it possible to optimize this?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BannedUser!
BANNED
Join Date: Feb 2010
Old 02-01-2010 , 19:02   Is it possible to optimize this?
Reply With Quote #1

PHP Code:
                static id
                id 
attacker
                
switch (get_user_weapon(attacker))
                {
                    case 
CSW_TMPdamage *= 1
                    
case CSW_KNIFEdamage *= 3
                    
case CSW_MAC10:
                    {
                        if (
Lvl[id] >= 5)
                            
damage *= 3
                    
}
                    case 
CSW_UMP45:
                    {
                        if (
Lvl[id] >= 10)
                            
damage *= 3
                    
}
                    case 
CSW_M4A1:
                    {
                        if (
Lvl[id] >= 15)
                            
damage *= 2.5
                    
}
                    case 
CSW_AK47:
                    {
                        if (
Lvl[id] >= 40)
                            
damage *= 2
                    
}
                    case 
CSW_SCOUT:
                    {
                        if (
Lvl[id] >= 60)
                            
damage *= 3
                    
}
                    case 
CSW_M3:
                    {
                        if (
Lvl[id] >= 100)
                            
damage *= 2.5
                    
}
                    case 
CSW_P90:
                    {
                        if (
Lvl[id] >= 140)
                            
damage *= 3
                    
}
                    case 
CSW_SG552:
                    {
                        if (
Lvl[id] >= 220)
                            
damage *= 3
                    
}
                    case 
CSW_GALIL:
                    {
                        if (
Lvl[id] >= 240)
                            
damage *= 4
                    
}
                    case 
CSW_XM1014:
                    {
                        if (
Lvl[id] >= 280)
                            
damage *= 3.5
                    
}
                    case 
CSW_MP5NAVY:
                    {
                        if (
Lvl[id] >= 300)
                            
damage *= 4
                    
}
                    case 
CSW_M249:
                    {
                        if (
Lvl[id] >= 350)
                            
damage *= 4
                        
if (g_survivor[id])
                            
damage *= 4
                    
}
                    case 
CSW_FAMAS:
                    {
                        if (
Lvl[id] >= 380)
                            
damage *= 5
                    
}
                    case 
CSW_AWP:
                    {
                        if (
Lvl[id] >= 430)
                        {
                            if (
g_awpfire[id])
                                
damage *= 5
                            
else if (g_awpfrost[id])
                                
damage *= 3
                        
}
                    }
                    case (
CSW_AUG):
                    {
                        if (
Lvl[attacker] >= 480)
                            
damage *= 30
                    
}
                    case 
CSW_SG550:
                    {
                        if (
Lvl[id] >= 480)
                            
damage *= 5
                    
}
                    case 
CSW_FIVESEVENdamage *= 2
                    
case CSW_USP:
                    {
                        if (
Lvl[id] >= 5)
                            
damage *= 3
                    
}
                    case 
CSW_DEAGLE:
                    {
                        if (
Lvl[id] >= 20)
                            
damage *= 2
                    
}
                    case 
CSW_GLOCK18:
                    {
                        if (
Lvl[id] >= 40)
                            
damage *= 4
                    
}
                    case 
CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    }
                    case 
CSW_ELITE:
                    {
                        if (
Lvl[id] >= 300)
                            
damage *= 4
                    
}
                } 
BannedUser! is offline
AfteR.
Veteran Member
Join Date: Dec 2008
Location: λ
Old 02-01-2010 , 19:10   Re: Is it possible to optimize this?
Reply With Quote #2

I dont really understand what are you trying to do with this my "dear" today-banned user.:

PHP Code:
                    case CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    } 
AfteR. is offline
BannedUser!
BANNED
Join Date: Feb 2010
Old 02-01-2010 , 19:38   Re: Is it possible to optimize this?
Reply With Quote #3

Quote:
Originally Posted by AfteR. View Post
I dont really understand what are you trying to do with this my "dear" today-banned user.:

PHP Code:
                    case CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    } 
I use the name BannedUser! In any games, forums, etc.

PHP Code:
                    case CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    } 
That you changed?
BannedUser! is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-01-2010 , 21:14   Re: Is it possible to optimize this?
Reply With Quote #4

Remove:

PHP Code:
 if (!g_p228[id]) 
__________________
fysiks is offline
BannedUser!
BANNED
Join Date: Feb 2010
Old 02-02-2010 , 01:50   Re: Is it possible to optimize this?
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Remove:

PHP Code:
 if (!g_p228[id]) 
Thanks.
BannedUser! is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-02-2010 , 01:59   Re: Is it possible to optimize this?
Reply With Quote #6

What you could do is instead, keep an array of the multipliers, along with an array of the necessary level.

Code:
if( Lvl[id] >= WeapLvl[weapon] )
   damage *= WeapMult[weapon];
Which could possibly remove the entire switch statement. (Though a couple weapons seem to have something else, so you could branch them off separately)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
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 07:28.


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