AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   optimization for equali (https://forums.alliedmods.net/showthread.php?t=228696)

Debesėlis 10-25-2013 10:43

optimization for equali
 
How to optimize that code? :D

PHP Code:

        if ( equaliName"fy_") || equaliName"awp_") || 
            
equaliName"cs_deagle5" ) || equaliName"cs_max" ) || 
            
equaliName"cs_pf_dust" ) || equaliName"cs_pf_train" ) || 
            
equaliName"aim_") || equaliName"35hp_") || 
            
equaliName"de_dust2_3x3") || equaliName"de_mirage_2x2") || 
            
equaliName"de_nuke_2x2") || equaliName"de_inferno_2x2") || 
            
equaliName"de_tuscan_2x2") || equaliName"de_snow_2x2") || 
            
equaliName"de_dust2_2x2" ) || equaliName"mini_dust2" ) ) 

Can i use it like this?
PHP Code:

equaliName"_2x2"


DWIGHTpN 10-25-2013 10:54

Re: optimization for equali
 
Code:

new const maps[][] = {
 "cs_deagle5",
 "bla..."
} // etc

public function() {
        for(new i;i<sizeof maps;i++) {
              if( containi(maps[i], "_2x2") != -1 ) {
                // do..
                break;
              }
          }
}


Debesėlis 10-25-2013 11:14

Re: optimization for equali
 
Can you check my code? i think i'm doing something wrong.

PHP Code:

new const smallmaps[][] = {
    
"aim_",
    
"fy_",
    
"35hp_",
    
"awp_",
    
"cs_max",
    
"de_dust2_3x3",
    
"cs_pf_dust",
    
"cs_pf_train",
    
"cs_deagle5",
    
"mini_dust2"
}

new const 
bigmaps[][] = {
    
"de_",
    
"cs_office",
    
"cs_italy"


if now is small map server will use set_task ?
PHP Code:

            for ( new isizeof smallmapsi++ )
            {
                if ( 
containismallmaps], "_2x2") != -)
                    
set_task10.0"InfoMapBig" );
            } 

if now is big map ( de_ ) and isn't de_dust2_2x2 then use set_task ...
PHP Code:

            for ( new isizeof bigmapsi++ )
            {
                for ( new 
isizeof smallmapsi++ )
                    if ( 
containismallmaps], "_2x2") != -) return;
                
                
set_task10.0"InfoMapSmall" );
            } 


DWIGHTpN 10-25-2013 11:46

Re: optimization for equali
 
use task for what?

You want to advertise admins when is small map on server and so much players?
Explain what do you want :)

Debesėlis 10-25-2013 12:03

Re: optimization for equali
 
task going for map change.

This code will check nice if map is big and isn't _2x2 ?
Quote:

Originally Posted by Debesėlis (Post 2052767)
if now is big map ( de_ ) and isn't de_dust2_2x2 then use set_task ...
PHP Code:

            for ( new isizeof bigmapsi++ )
            {
                for ( new 
isizeof smallmapsi++ )
                    if ( 
containismallmaps], "_2x2") != -) return;
                
                
set_task10.0"InfoMapSmall" );
            } 



do i need to us break; ?
Quote:

Originally Posted by DWIGHTpN (Post 2052758)
Code:

              if( containi(maps[i], "_2x2") != -1 ) {
                // do..
                break;



DWIGHTpN 10-25-2013 12:25

Re: optimization for equali
 
If you want to see if the actual map on server is small or big, check it out..
Code:

new const smallmaps[][] = {
    "aim_",
    "fy_",
    "35hp_",
    "awp_",
    "cs_max",
    "de_dust2_3x3",
    "cs_pf_dust",
    "cs_pf_train",
    "cs_deagle5",
    "mini_dust2"
}

new const bigmaps[][] = {
    "de_",
    "cs_office",
    "cs_italy"
}

new bool:IsSmallMap;

public plugin_init() {
        new map_name[64];
        get_mapname( map_name, charsmax( map_name ) );
        for(new i;i<sizeof smallmaps;i++)
            if( containi(map_name, smallmaps[i]) != -1 ) {
                  IsSmallMap= true;
                  break; // get out from for()
          }
}

Quote:

task going for map change.
This isn't correct, if you change map, all plugins (including tasks) will restart.

alan_el_more 10-25-2013 12:27

Re: optimization for equali
 
The best method is using tries

ConnorMcLeod 10-25-2013 12:51

Re: optimization for equali
 
If you check this only once in plugin_init, it's not really important.

But anyway, you should also say what you want to do with this information.

Debesėlis 10-25-2013 12:56

Re: optimization for equali
 
Quote:

Originally Posted by alan_el_more (Post 2052797)
The best method is using tries

can you please give me any example?

Debesėlis 10-25-2013 12:59

Re: optimization for equali
 
Quote:

Originally Posted by ConnorMcLeod (Post 2052812)
If you check this only once in plugin_init, it's not really important.

But anyway, you should also say what you want to do with this information.

I want change the map when in server is more or less than (example 10 players). What i need is get current map (small this map or no).

In big map (de_dust2) i need to check that is (de_) map and isn't small (_2x2) then change the map to small.


All times are GMT -4. The time now is 23:18.

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