Raised This Month: $ Target: $400
 0% 

optimising plugins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 04-21-2013 , 15:11   optimising plugins
Reply With Quote #1

Just checking if i get it right.

Accoding to this V1 would be more optimised than V2?

V1
PHP Code:
    new team get_user_team(id)
    
    switch(
g_SpecDay)
    {
        case 
3: return PLUGIN_HANDLED
        
case 4:
        {
            if(
team == 1)
                return 
PLUGIN_HANDLED
        
}
        case 
27:
        {
            if(
team == 2)
                return 
PLUGIN_HANDLED
        
}
    } 
V2
PHP Code:
    if(g_SpecDay == 3)
    {
        return 
PLUGIN_HANDLED
    
}
    else if(
g_SpecDay == && get_user_team(id) == 1)
    {
        return 
PLUGIN_HANDLED
    
}
    else if((
g_SpecDay == || g_SpecDay == 7) && get_user_team(id) == 2)
    {
        return 
PLUGIN_HANDLED
    


Last edited by GhostMan; 04-21-2013 at 15:12.
GhostMan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-21-2013 , 15:15   Re: optimising plugins
Reply With Quote #2

Yes, you can put get_user_team in cases though, then it won't be called on case 3.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 04-21-2013 , 16:36   Re: optimising plugins
Reply With Quote #3

v1 is mor optimised, thats correct.

you dont need to store the team if you just need it in the switch

PHP Code:
    switch(g_SpecDay){
        case 
3: return PLUGIN_HANDLED
        
case 4: if (get_user_team(id) == 1) return PLUGIN_HANDLED
        
case 27: if (get_user_team(id) == 2) return PLUGIN_HANDLED
    

__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
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 10:49.


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