AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   optimising plugins (https://forums.alliedmods.net/showthread.php?t=213993)

GhostMan 04-21-2013 15:11

optimising plugins
 
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
    



ConnorMcLeod 04-21-2013 15:15

Re: optimising plugins
 
Yes, you can put get_user_team in cases though, then it won't be called on case 3.

Leon M. 04-21-2013 16:36

Re: optimising plugins
 
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
    




All times are GMT -4. The time now is 10:49.

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