Raised This Month: $ Target: $400
 0% 

optimising this "if"


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Speed!
BANNED
Join Date: Jan 2009
Old 02-05-2009 , 12:39   optimising this "if"
Reply With Quote #1

i know that this is terribly unoptimised, and i have to execute this veerryyy often.
PHP Code:
static level
    
if (g_ammopacks[id] < 50)
        
level 1
    
else if (g_ammopacks[id] > 50 && g_ammopacks[id] < 125)
        
level 2
    
else if (g_ammopacks[id] > 125 && g_ammopacks[id] < 450)
        
level 3
    
else if (g_ammopacks[id] > 450 && g_ammopacks[id] < 800)
        
level 4
    
else if (g_ammopacks[id] > 800 && g_ammopacks[id] < 1250)
        
level 5
    
else if (g_ammopacks[id] > 1250 && g_ammopacks[id] < 2500)
        
level 6
    
else if (g_ammopacks[id] > 2500 && g_ammopacks[id] < 5000)
        
level 7
    
else if (g_ammopacks[id] > 5000 && g_ammopacks[id] < 10000)
        
level 8
    
else if (g_ammopacks[id] > 10000 && g_ammopacks[id] < 20000)
        
level 9
    
else if (g_ammopacks[id] > 20000)
        
level 10 
is this possible with a switch of something better?
Speed! 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 01:51.


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